reaction
reaction copied to clipboard
Discounts re calculation is broken on cart quantity change
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
- Add some item to card
- Apply discount code (method discount)
- 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