chore: properly clear cart with correct data shape (#3500)

This commit is contained in:
Jarrod Flesch
2023-10-09 16:29:15 -04:00
committed by GitHub
parent ffed34cf27
commit 0bbd7137cd

View File

@@ -1,6 +1,6 @@
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 }) => {
const { payload } = req
@@ -18,7 +18,9 @@ export const clearUserCart: AfterChangeHook<Order> = async ({ doc, req, operatio
collection: 'users',
id: orderedBy,
data: {
cart: [] as User['cart'],
cart: {
items: [],
},
},
})
}