Magento – Magento 2 : Cannot Read Property “quoteData” of undefined

cartjavascriptmagento2shopping-cart

I was seeing various errors on cart page of Magento 2.1.6.

Cannot read property "quoteData" of undefined (quote.js)
Cannot read property 'storeCode' of undefined (url-builder.js)
Cannot convert undefined or null to object (customer-addresses.js)

Incase someone else sees these errors, for me they were caused by removing certain blocks from checkout in XML.

<referenceBlock name="checkout.cart.shipping" remove="true"/>
<referenceBlock name="checkout.cart.coupon" remove="true"/>
<referenceBlock name="checkout.cart.crosssell" remove="true"/>
<referenceBlock name="checkout.cart.order.actions.gift_options" remove="true"/>

I fixed by re-inserting blocks and hiding relevant sections with css.

Best Answer

For my case it was this block

<referenceBlock name="checkout.cart.shipping" remove="true"/>

I removed that line and I overwrote shipping.phtml on my theme to remove the shipping address and to keep the checkoutConfig and the JavaScript. It's totally stupid to include the script in a part of the view and depend on it on other parts. Just like the rest of everything stupid with Magento

Related Topic