From a58ce6720b54c3fa2a70e73371480a05afecdc6f Mon Sep 17 00:00:00 2001 From: posthog-watcher-action Date: Tue, 23 Jun 2026 18:13:39 +0000 Subject: [PATCH 1/2] Fix #26: Cart total ignores line item quantities --- src/business.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/business.js b/src/business.js index a8f0cd0..8a8a7bb 100644 --- a/src/business.js +++ b/src/business.js @@ -12,8 +12,7 @@ function calculateDiscountedPrice(price, discountPercent) { } function totalCart(items) { - // BUG: ignores quantity, so multi-quantity line items are undercounted. - return roundToCents(items.reduce((total, item) => total + item.price, 0)); + return roundToCents(items.reduce((total, item) => total + item.price * item.quantity, 0)); } function normalizeUsername(username) { From 2488a65379e9b7ae1468587b88928af8a9258926 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Jun 2026 09:59:55 +0000 Subject: [PATCH 2/2] Fix #26: Cart total ignores line item quantities --- test/business.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/business.test.js b/test/business.test.js index e84f4fa..5823775 100644 --- a/test/business.test.js +++ b/test/business.test.js @@ -22,7 +22,10 @@ test('cart total includes item quantities', () => { { name: 'Notebook', price: 2.5, quantity: 2 }, ]; - assert.equal(totalCart(items), 17); + const total = totalCart(items); + + assert.notEqual(total, 5.5); + assert.equal(total, 17); }); test('username normalization trims, lowercases, and collapses whitespace', () => {