Skip to content

Checkout cart totals.js throws an error when estimating shipping #5358

@ghost

Description

Steps to reproduce

  1. Add a product to the cart
  2. Make sure you have at least one Shipping Method active (e.g. Flat Rate)
  3. Navigate to Shopping Cart page
  4. Observe the result

Expected result

  1. Shipping should be estimated without errors

Actual result

  1. Loading indicator keeps spinning
  2. There is an exception thrown in IE console "Object doesn't support this action"

Observations

Reproduceable when using Internet Explorer 9+ browser.
It happens because in the file "magento/module-checkout/view/frontend/web/js/view/cart/totals.js" there are two calls to instantiate event by using new Event('resize') which is not supported by Internet Explorer.
One possible fix would be to refactor the event dispatch calls to something like below:

initialize: function () {
    this._super();
    var self = this;
    totalsService.totals.subscribe(function () {
        self._dispatchEvent();
    });
    shippingService.getShippingRates().subscribe(function () {
        self._dispatchEvent();
    });
},
_dispatchEvent: function () {
    // backward compatibility with IE
    var event = document.createEvent('Event');
    event.initEvent('resize', true, true);
    window.dispatchEvent(event);
}

Magento Versions

Magento 2.1 and develop branch.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions