Skip to content

Commit d1af33d

Browse files
committed
Fix changeLineItemQuantity action on the Cart
1 parent 7528ac2 commit d1af33d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/repositories/cart.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,15 @@ export class CartRepository extends AbstractResourceRepository<'cart'> {
242242
})
243243
}
244244

245-
const shouldDelete = !quantity || quantity >= lineItem.quantity
246-
if (shouldDelete) {
245+
if (quantity === 0) {
247246
// delete line item
248247
resource.lineItems = resource.lineItems.filter(
249248
(x) => x.id !== lineItemId
250249
)
251250
} else {
252-
// decrease quantity and update total price
253251
resource.lineItems.forEach((x) => {
254252
if (x.id === lineItemId && quantity) {
255-
x.quantity -= quantity
253+
x.quantity = quantity
256254
x.totalPrice.centAmount = calculateLineItemTotalPrice(x)
257255
}
258256
})

0 commit comments

Comments
 (0)