diff --git a/.changeset/cold-foxes-lie.md b/.changeset/cold-foxes-lie.md new file mode 100644 index 0000000000..5a2cef8780 --- /dev/null +++ b/.changeset/cold-foxes-lie.md @@ -0,0 +1,5 @@ +--- +"@bigcommerce/catalyst-core": patch +--- + +Fix cart summary Discounts row not showing manual discounts applied via the Management Checkout API diff --git a/core/app/[locale]/(default)/cart/page-data.ts b/core/app/[locale]/(default)/cart/page-data.ts index c6e47636dc..1d88b721e9 100644 --- a/core/app/[locale]/(default)/cart/page-data.ts +++ b/core/app/[locale]/(default)/cart/page-data.ts @@ -28,6 +28,10 @@ export const PhysicalItemFragment = graphql(` currencyCode value } + discountedAmount { + currencyCode + value + } selectedOptions { __typename entityId @@ -87,6 +91,10 @@ export const DigitalItemFragment = graphql(` currencyCode value } + discountedAmount { + currencyCode + value + } selectedOptions { __typename entityId diff --git a/core/app/[locale]/(default)/cart/page.tsx b/core/app/[locale]/(default)/cart/page.tsx index bc07f3d473..29f91be420 100644 --- a/core/app/[locale]/(default)/cart/page.tsx +++ b/core/app/[locale]/(default)/cart/page.tsx @@ -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>((acc, c) => { acc.push({ @@ -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, })}`,