1

I have created a custom page with free text ordering functionality and called custom add to cart API to add items to the cart.

Once the item is added I need to update the cart item count with updated quantity. I tried to use

require([
    'jquery',
    'Magento_Checkout/js/action/get-totals'
], function ($, getTotalsAction) {
    'use strict';

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

But It is throwing error: Uncaught TypeError: Cannot read property 'quoteData' of undefined at quote.js:34

And

url-builder.js:12 Uncaught TypeError: Cannot read property 'storeCode' of undefined at url-builder.js:12

Anything missing here?

I referred Error javascript define magento2 : window.checkout.quoteData or store code are undefined which doesn't have any working solutions.

1 Answer 1

0

I was able to achieve this my the below code. It might help someone

require([
       'Magento_Customer/js/customer-data'
    ], function (customerData) {
        var sections = ['cart'];
        customerData.invalidate(sections);
        customerData.reload(sections, true);
    });

Your Answer

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

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