Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-foxes-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Fix cart summary Discounts row not showing manual discounts applied via the Management Checkout API
8 changes: 8 additions & 0 deletions core/app/[locale]/(default)/cart/page-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const PhysicalItemFragment = graphql(`
currencyCode
value
}
discountedAmount {
currencyCode
value
}
selectedOptions {
__typename
entityId
Expand Down Expand Up @@ -87,6 +91,10 @@ export const DigitalItemFragment = graphql(`
currencyCode
value
}
discountedAmount {
currencyCode
value
}
selectedOptions {
__typename
entityId
Expand Down
11 changes: 9 additions & 2 deletions core/app/[locale]/(default)/cart/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ export default async function Cart({ params }: Props) {
const totalCouponDiscount =
checkout?.coupons.reduce((sum, coupon) => sum + coupon.discountedAmount.value, 0) ?? 0;

const totalLineItemDiscount = [
...cart.lineItems.physicalItems,
...cart.lineItems.digitalItems,
].reduce((sum, item) => sum + item.discountedAmount.value, 0);

const totalDiscount = cart.discountedAmount.value + totalLineItemDiscount;

const giftCertificatesSummary =
checkout?.giftCertificates.reduce<Array<{ code: string; used: number }>>((acc, c) => {
acc.push({
Expand Down Expand Up @@ -278,10 +285,10 @@ export default async function Cart({ params }: Props) {
currency: cart.currencyCode,
}),
},
cart.discountedAmount.value > 0
totalDiscount > 0
? {
label: t('CheckoutSummary.discounts'),
value: `-${format.number(cart.discountedAmount.value, {
value: `-${format.number(totalDiscount, {
style: 'currency',
currency: cart.currencyCode,
})}`,
Expand Down
Loading