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

Gift card being applied inconsistently in cart and order #5005

Closed
Arsenalist opened this issue Sep 10, 2023 · 6 comments
Closed

Gift card being applied inconsistently in cart and order #5005

Arsenalist opened this issue Sep 10, 2023 · 6 comments

Comments

@Arsenalist
Copy link
Contributor

Arsenalist commented Sep 10, 2023

To reproduce:

  • set gift_card_taxable to false in regions table
  • create gift card
  • apply gift card to a product which has taxes and shipping
  • place order
  • expected: order.gift_card_total === cart.gift_card_total
  • actual: order.gift_card_total !== cart.gift_card_total

Discord Link: https://discord.com/channels/876835651130097704/1150475042669465692

Medusa version (including plugins): 1..14
Node.js version: 16

Cart screen
image

Order screen
image

Stripe is getting charged
image

Database: Postgres 12
Operating system: Linux

This piece of code in cart.ts decorateTotals() does not check if region has gift card taxable when calculating gift cardable amount:

    const giftCardTotal = await this.newTotalsService_.getGiftCardTotals(
      cart.subtotal - cart.discount_total,
      {
        region: cart.region,
        giftCards: cart.gift_cards,
      }
    )

While this one in order.ts createFromCart() does:

      const giftCardableAmount =
        (cart.region?.gift_cards_taxable
          ? cart.subtotal! - cart.discount_total!
          : cart.total! + cart.gift_card_total!) || 0 // we re add the gift card total to compensate the fact that the decorate total already removed this amount from the total

I also don't think this is correct decorateTotals() is correct since gift card applies to whole amount in the cart, not just subtotal-discount_total. I mentioned that in Discord as well.

@Arsenalist
Copy link
Contributor Author

Submitted this: #5015

@Arsenalist Arsenalist changed the title Gift card being applied inconsistently in cart and order (cart is correct, order is not) Gift card being applied inconsistently in cart and order Sep 14, 2023
@adrien2p
Copy link
Member

@olivermrbl mentionning you here so that you have the full context of the origin of the pr

@Arsenalist
Copy link
Contributor Author

For the record, I believe the correct behaviour is for the gift card to cover everything (sub total, tax, shipping). So Stripe should not be getting charged at all if gift card is worth like $40

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Dec 23, 2024
Copy link
Contributor

github-actions bot commented Jan 3, 2025

This issue was closed because it has been stalled for 3 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@SalahAdDin
Copy link

@Arsenalist any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants