1

I have a controller that is called by ajax in the cart page. A gift card amount is passed to the controller and a function then updates the quote grand total based on that amount.

    protected function applyGiftCard($giftCardCode, $giftCardSecurityCode, $giftCardAmount): array
    {
        $quote = $this->checkoutSession->getQuote();
        $grand_total = $quote->getGrandTotal();
        $new_grand_total = $grand_total - $giftCardAmount;
        $quote->setGrandTotal($new_grand_total);
        $quote->setBaseGrandTotal($new_grand_total);
        $quote->save();

        $this->checkoutSession->getQuote()->collectTotals()->save();
        return array();
    }

I can see that the Grand total has been updated in the quote data.

In the success function of the ajax I call

let deferred = $.Deferred();
getTotalsAction([], deferred);

The loading mask is shown but on complete the total has not updated.

Can anyone help to get the front end totals to update?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.