0

To offer different discounts based on the selected payment method, I have created two Cart Price Rules (one for each payment method) to apply the "Percent of product price discount" action. After selecting one of these two payment methods on the checkout page, the corresponding Cart Price Rule discount is applied over the subtotal. If I select another payment method (either with or without a Cart Price Rule associated), the discount amount does not reset or update. This happens in both local and test environments. Is there a way to trigger the recalculation of the discount amount in my custom module? Or at least reset the discount amount?

I am using Magento version 2.4.0.

1 Answer 1

0

Add the following line which will trigger total calculation:

cartCache.set('totals',null);
defaultTotal.estimateTotals();

Where

define(
    [
        'Magento_Checkout/js/model/cart/totals-processor/default',
        'Magento_Checkout/js/model/cart/cache'
    ], function (
        defaultTotal,
        cartCache
    ) {
1
  • I already tried to clear the cart cache and call totals calculation in my mixin JS. It triggers the calculation, but the discount amount does not update. Not only does the discount amount stay forever with the value relative to the first payment method associated rule, as the second payment method rule is not applied.
    – gfreytag
    Jul 19, 2021 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.