We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
changeLineItemQuantity
1 parent 7528ac2 commit d1af33dCopy full SHA for d1af33d
src/repositories/cart.ts
@@ -242,17 +242,15 @@ export class CartRepository extends AbstractResourceRepository<'cart'> {
242
})
243
}
244
245
- const shouldDelete = !quantity || quantity >= lineItem.quantity
246
- if (shouldDelete) {
+ if (quantity === 0) {
247
// delete line item
248
resource.lineItems = resource.lineItems.filter(
249
(x) => x.id !== lineItemId
250
)
251
} else {
252
- // decrease quantity and update total price
253
resource.lineItems.forEach((x) => {
254
if (x.id === lineItemId && quantity) {
255
- x.quantity -= quantity
+ x.quantity = quantity
256
x.totalPrice.centAmount = calculateLineItemTotalPrice(x)
257
258
0 commit comments