fix(core-flows, medusa): don't allow negative line item quantity (#13508)

* fix(core-flows,medusa): don't allow negative line item quantity

* fix: greater than 0

* feat: add test

* wip: update update item flow to remove item when qty is 0

* fix: paralelize

* fix: when argument

* fix: emit event
This commit is contained in:
Frane Polić
2025-09-16 11:54:20 +02:00
committed by GitHub
parent 25634b0382
commit 8565dcfc46
6 changed files with 238 additions and 65 deletions
@@ -7,7 +7,7 @@ export const StoreGetCartsCart = createSelectParams()
const ItemSchema = z.object({
variant_id: z.string(),
quantity: z.number(),
quantity: z.number().gt(0),
metadata: z.record(z.unknown()).nullish(),
})
@@ -65,7 +65,7 @@ export const StoreCalculateCartTaxes = createSelectParams()
export type StoreAddCartLineItemType = z.infer<typeof StoreAddCartLineItem>
export const StoreAddCartLineItem = z.object({
variant_id: z.string(),
quantity: z.number(),
quantity: z.number().gt(0),
metadata: z.record(z.unknown()).nullish(),
})
@@ -73,7 +73,7 @@ export type StoreUpdateCartLineItemType = z.infer<
typeof StoreUpdateCartLineItem
>
export const StoreUpdateCartLineItem = z.object({
quantity: z.number(),
quantity: z.number().gte(0), // can be 0 to remove the item from the cart
metadata: z.record(z.unknown()).nullish(),
})