JS Error : Getting 'storeCode' of undefined while single store mode enabled
Preconditions
- Magento 2.1.2
Steps to reproduce
- Enable Single Store Mode
- Add product to cart, go to cart
Expected result
- No js errors
Actual result
-
There are an error in console
Uncaught TypeError: Cannot read property 'storeCode' of undefined(anonymous function) @ url-builder.js:17
url-builder.js;
define( [ 'jquery', 'Magento_Checkout/js/model/url-builder' ], function ($, urlBuilder) { 'use strict'; return $.extend( urlBuilder, { line 17: ----> storeCode: window.giftOptionsConfig.storeCode } ); } );
Hi, thank you for report. I cannot reproduce this issue on clean installation 2.1.2. If you have 3-rd party extensions please disable it and try again, also try to clear all caches, including browser cache. If not help please provide more info about your browser, environment, specific settings etc.
I have experienced the same issue after removing checkout.cart.order.actions.gift_options block in my custom theme layout. Putting it back just resolved the problem
@rbostan, please have a look at @askarbin above comment. Does it help you?
@olysenko Yes, it does. Thanks @askarbin
Ok how can we remove that block and remove the reference to the gift URL? I don't need it
For what it is worth I have just been struggling with this, whilst I never removed it from my custom theme, I had never added the Magento_GiftMessage/layout/checkout_cart_index.xml to the theme, adding this solved it for me.
I can only assume that is is because I had declared Magento_Checkout/layout/checkout_cart_index.xml and so it was looking in the same place for this, and failing as it couldn't find it? Doesn't sound right, I am sure someone who writes the core files will correct me on that!
i solved this problem, i remove block checkout.cart.order.actions in file Magento_Checkout/layout/checkout_cart_index.xml your template custom.
I have single store site following solution works for me
/vendor/magento/module-gift-message/view/frontend/web/js/model/url-builder.js
replaced { storeCode: window.giftOptionsConfig.storeCode }
by { storeCode: 'default' }
where "default" is my store code for site , you can find your store code in stores > all store section in admin