3

I'm having a bit of trouble trying to get the Order Summary to update on the Magento 2 checkout

I have a block on the payment step of the checkout with a special offer item. It has an add to basket button which adds the product via ajax to the quote. This all works correctly without issue, the problem i'm currently having is trying to update the order summary in the sidebar without reloading the page. I've had a search around but not managed to find anything yet.

enter image description here

After adding to basket I've triggered a refresh of the window.checkoutConfig and i can see the data in there. enter image description here

Does anybody have any insight on how i can trigger an update of the Order Summary so it shows the items and correct totals.

I thought there would be something like trigger('contentUpdated') for the block but can't seem to get that to do anything.

2 Answers 2

1

Does https://webkul.com/blog/update-cart-totals-by-js-on-checkout-page-magento2/ help? From what I understand the issue is that because the page isn't refreshed the totals are not updated and from what I know that is done via js in magento 2.

1

You can add below coding in your js. Once quote shipping address trigger, then order totals (summary) will reload in AJAX. Whole page won't refresh/reload.

require(
[
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/cart/totals-processor/default'
],
function(
    quote,
    totalsDefaultProvider
) {
    totalsDefaultProvider.estimateTotals(quote.shippingAddress());
}
);

Your Answer

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

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