reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.34k stars 2.17k forks source link

Discounts re calculation is broken on cart quantity change #6486

Closed redscare closed 1 year ago

redscare commented 3 years ago

Issue Description

Whenever any cart item quantity is changed and cart has discount code applied to it, discount amount is getting broken. The reason for that is that here https://github.com/reactioncommerce/api-plugin-discounts/blob/trunk/src/queries/getDiscountsTotalForCart.js#L26 we pass cartId to discount processor, which will fetch card from DB and calculate the discount. However, item quantity is not yet updated in DB at this moment.

Steps to Reproduce

  1. Add some item to card
  2. Apply discount code (method discount)
  3. In cart change item quantity

Possible Solution

Pass whole Cart object here https://github.com/reactioncommerce/api-plugin-discounts/blob/trunk/src/queries/getDiscountsTotalForCart.js#L26 instead of id

Versions

brent-hoover commented 2 years ago

Iceboxing because this likely be removed with Promotions work

brent-hoover commented 1 year ago

Closing this as it is a bug in the existing discount code implementation that is being deprecated