Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where the discount value displayed in the cart gets the tax subtracted twice when displaying prices excluding tax. #1824

Open
wants to merge 4 commits into
base: canary
Choose a base branch
from
Open
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/brave-zebras-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphcommerce/magento-cart": patch
---

Fix issue where the discount value displayed in the cart gets the tax subtracted twice when displaying prices excluding tax.
13 changes: 5 additions & 8 deletions packages/magento-cart/components/CartTotals/CartTotals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ const parts = [
const { withState } = extendableComponent<OwnerProps, typeof name, typeof parts>(name, parts)

/**
* ⚠️ WARNING: The current CartTotals rely heavily on how Magento is configured. It kinda works for
* the demo, but we need additional fields from the API to get this working as expected:
* ⚠️ WARNING: The discount value of the cart will sometimes be incorrect when:
* 1. Catalog Prices are set to Including Tax
* 2. Apply Discount Tax is set to: After discount
* 3. Price display settings is set to: Excluding tax
*
* @see https://github.com/magento/magento2/issues/33848
*/
Expand Down Expand Up @@ -86,12 +88,7 @@ export function CartTotals(props: CartTotalsProps) {
)}

{prices?.discounts?.map((discount) => {
const value = inclTax
? (discount?.amount.value ?? 0) * -1
: (discount?.amount.value ?? 0) *
((prices.subtotal_excluding_tax?.value ?? 1) /
(prices.subtotal_including_tax?.value ?? 1)) *
-1
const value = (discount?.amount.value ?? 0) * -1

return (
<Box
Expand Down
Loading