magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

JS Error : Getting 'storeCode' of undefined while single store mode enabled

Open cizgidekiadam opened this issue 10 years ago • 8 comments

Preconditions

  1. Magento 2.1.2

Steps to reproduce

  1. Enable Single Store Mode
  2. Add product to cart, go to cart

Expected result

  1. No js errors

Actual result

  1. 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
            }
        );
    }
    );
    

cizgidekiadam avatar Oct 13 '16 08:10 cizgidekiadam

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.

olysenko avatar Oct 17 '16 10:10 olysenko

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

askarbin avatar Oct 28 '16 15:10 askarbin

@rbostan, please have a look at @askarbin above comment. Does it help you?

olysenko avatar Oct 31 '16 09:10 olysenko

@olysenko Yes, it does. Thanks @askarbin

cizgidekiadam avatar Nov 01 '16 08:11 cizgidekiadam

Ok how can we remove that block and remove the reference to the gift URL? I don't need it

ahmadalfy avatar Jul 16 '17 20:07 ahmadalfy

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!

timbaker1991 avatar Jul 17 '17 18:07 timbaker1991

i solved this problem, i remove block checkout.cart.order.actions in file Magento_Checkout/layout/checkout_cart_index.xml your template custom.

phuongleduy avatar Oct 17 '17 03:10 phuongleduy

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

harshadgoswami avatar Jan 30 '18 15:01 harshadgoswami