feat(core-flows,types,utils,medusa): Update existing line items when adding the same variant to cart (#7470)

* feat(core-flows,types,utils,medusa): Update existing line items when adding the same variant to cart

* chore: split steps into 2 for add-to-cart

* chore: split steps into 2 for add-to-cart

* chore: iterate safely

* chore: parallelize upsert
This commit is contained in:
Riqwan Thamir
2024-05-27 17:54:11 +02:00
committed by GitHub
parent 81c27e3524
commit 7baedf73d5
16 changed files with 339 additions and 49 deletions
@@ -45,6 +45,7 @@ export const defaultStoreCartFields = [
"items.variant_sku",
"items.variant_barcode",
"items.variant_title",
"items.metadata",
"items.created_at",
"items.updated_at",
"items.title",
@@ -8,6 +8,7 @@ export const StoreGetCartsCart = createSelectParams()
const ItemSchema = z.object({
variant_id: z.string(),
quantity: z.number(),
metadata: z.record(z.unknown()).optional().nullable(),
})
export type StoreCreateCartType = z.infer<typeof StoreCreateCart>
@@ -62,7 +63,7 @@ export type StoreAddCartLineItemType = z.infer<typeof StoreAddCartLineItem>
export const StoreAddCartLineItem = z.object({
variant_id: z.string(),
quantity: z.number(),
metadata: z.record(z.unknown()).optional(),
metadata: z.record(z.unknown()).optional().nullable(),
})
export type StoreUpdateCartLineItemType = z.infer<