chore: properly clear cart with correct data shape (#3500)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import type { AfterChangeHook } from 'payload/dist/collections/config/types'
|
import type { AfterChangeHook } from 'payload/dist/collections/config/types'
|
||||||
|
|
||||||
import type { Order, User } from '../../../payload-types'
|
import type { Order } from '../../../payload-types'
|
||||||
|
|
||||||
export const clearUserCart: AfterChangeHook<Order> = async ({ doc, req, operation }) => {
|
export const clearUserCart: AfterChangeHook<Order> = async ({ doc, req, operation }) => {
|
||||||
const { payload } = req
|
const { payload } = req
|
||||||
@@ -18,7 +18,9 @@ export const clearUserCart: AfterChangeHook<Order> = async ({ doc, req, operatio
|
|||||||
collection: 'users',
|
collection: 'users',
|
||||||
id: orderedBy,
|
id: orderedBy,
|
||||||
data: {
|
data: {
|
||||||
cart: [] as User['cart'],
|
cart: {
|
||||||
|
items: [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user