Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimate Shipping and Tax Form not works due to js error in collapsible.js [proposed fix] #8222

Closed
Dart18 opened this issue Jan 21, 2017 · 12 comments
Assignees
Labels
bug report Component: Checkout Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update

Comments

@Dart18
Copy link

Dart18 commented Jan 21, 2017

The shipping and estimate tax form don't display the form with country, city, postcode fields.
The form is in the dom, but hidden.
The Cannot read property 'it/checkout/cart/block-shipping' of null javascript error appears in the console.

Preconditions

  1. Magento 2.1.3
  2. Mysql 5.7.17
  3. PHP 5.6.29-1+deb.sury.org~xenial+1 (cli)
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
  4. Data imported from Magento 1.9.0.1 to 2.1.1, upgraded to 2.1.2 and after to 2.1.3
  5. Shipping method: Table Rates
  6. The site does not seems to be affected from Website Specific Shipping Methods are not working after upgrade 2.1.2=>2.1.3 #7840 in the checkout step 1 and 2, but I can not exclude a side effect on the estimation block.

Steps to reproduce

  1. Set a base unsecure url in the format www.domain.tld
  2. Cart with one item, simple product
  3. No shipping promotions
  4. Click on Estimate Shipping and Tax and nothing happens.

Expected result

  1. Click on Estimate Shipping and Tax should display the form.

Actual result

  1. The estimation form in the sidebar is hidden and appears the following error in console:
jquery-migrate.js:21 JQMIGRATE: Logging is active
jquery.storageapi.min.js:2 Uncaught TypeError: Cannot read property 'it%2Fcheckout%2Fcart%2Fblock-shipping' of null
    at Object.t (http://plutone.local.host/develflowershop/www.develflowershop…84959354/frontend/Magento/luma/it_IT/jquery/jquery.storageapi.min.js:2:721)
    at Object._callMethod (http://plutone.local.host/develflowershop/www.develflowershop…4959354/frontend/Magento/luma/it_IT/jquery/jquery.storageapi.min.js:2:4103)
    at Object.get (http://plutone.local.host/develflowershop/www.develflowershop…4959354/frontend/Magento/luma/it_IT/jquery/jquery.storageapi.min.js:2:4145)
    at $.(anonymous function).(anonymous function)._processState (http://plutone.local.host/develflowershop/www.develflowershop…c/version1484959354/frontend/Magento/luma/it_IT/mage/collapsible.js:116:42)
    at $.(anonymous function).(anonymous function)._processState (http://plutone.local.host/develflowershop/www.develflowershop…c/version1484959354/frontend/Magento/luma/it_IT/jquery/jquery-ui.js:402:25)
    at $.(anonymous function).(anonymous function)._create (http://plutone.local.host/develflowershop/www.develflowershop…ic/version1484959354/frontend/Magento/luma/it_IT/mage/collapsible.js:53:18)
    at $.(anonymous function).(anonymous function)._create (http://plutone.local.host/develflowershop/www.develflowershop…c/version1484959354/frontend/Magento/luma/it_IT/jquery/jquery-ui.js:402:25)
    at $.(anonymous function).(anonymous function)._createWidget (http://plutone.local.host/develflowershop/www.develflowershop…ic/version1484959354/frontend/Magento/luma/it_IT/jquery/jquery-ui.js:561:8)
    at new $.(anonymous function).(anonymous function) (http://plutone.local.host/develflowershop/www.develflowershop…ic/version1484959354/frontend/Magento/luma/it_IT/jquery/jquery-ui.js:363:9)
    at $.(anonymous function).(anonymous function) (http://plutone.local.host/develflowershop/www.develflowershop…c/version1484959354/frontend/Magento/luma/it_IT/jquery/jquery-ui.js:357:11)
t @ jquery.storageapi.min.js:2
_callMethod @ jquery.storageapi.min.js:2
get @ jquery.storageapi.min.js:2
_processState @ collapsible.js:116
(anonymous) @ jquery-ui.js:402
_create @ collapsible.js:53
(anonymous) @ jquery-ui.js:402
_createWidget @ jquery-ui.js:561
$.(anonymous function).(anonymous function) @ jquery-ui.js:363
$.(anonymous function).(anonymous function) @ jquery-ui.js:357
(anonymous) @ main.js:30
execCb @ require.js:1650
check @ require.js:866
enable @ require.js:1143
init @ require.js:774
(anonymous) @ require.js:1416
setTimeout (async)
(anonymous) @ require.js:1755
localRequire @ require.js:1405
window.require @ mixins.js:239
init @ main.js:23
(anonymous) @ main.js:83
_.each._.forEach @ underscore.js:150
(anonymous) @ main.js:72
apply @ main.js:69
fire @ jquery.js:3099
add @ jquery.js:3145
jQuery.fn.ready @ jquery.js:3379
jQuery.fn.init @ jquery.js:2819
jQuery.fn.init @ jquery-migrate.js:225
jQuery @ jquery.js:75
(anonymous) @ bootstrap.js:19
execCb @ require.js:1650
check @ require.js:866
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
enable @ require.js:1143
init @ require.js:774
(anonymous) @ require.js:991
(anonymous) @ require.js:132
(anonymous) @ mixins.js:106
execCb @ require.js:1650
check @ require.js:866
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
enable @ require.js:1143
init @ require.js:774
(anonymous) @ require.js:991
(anonymous) @ require.js:132
(anonymous) @ mixins.js:106
execCb @ require.js:1650
check @ require.js:866
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
enable @ require.js:1143
init @ require.js:774
(anonymous) @ require.js:991
(anonymous) @ require.js:132
(anonymous) @ mixins.js:106
execCb @ require.js:1650
check @ require.js:866
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
(anonymous) @ require.js:1113
(anonymous) @ require.js:132
(anonymous) @ require.js:1156
each @ require.js:57
emit @ require.js:1155
check @ require.js:917
enable @ require.js:1143
init @ require.js:774
(anonymous) @ require.js:991
(anonymous) @ require.js:132
runCallbacks @ domReady.js:24
callReady @ domReady.js:35
pageLoaded @ domReady.js:50

I'm working on a site ready to go live. So any suggestion is very appreciate.
Thanks in advance.

@Dart18
Copy link
Author

Dart18 commented Jan 23, 2017

Some additional informations.
I'm in developer mode.
The current theme is Luma.
All cache types are enabled.
All custom modules are disabled.
I tried cleaning browser cache and local storage data without any effect;
I tried also

php bin/magento setup:static-content:deploy -d;
php bin/magento setup:static-content:deploy -d it_IT;

, I emptied the cache from the backend, without success.
My website has two stores, the default uses en_US locale, the second uses it_IT locale provided by Magento2 Italian Language Pack (It_IT) and installed via composer.

Switch between languages does not change the resut: the error is the same.
Any suggestion? There is something else that I forget to try?
Thanks

@Dart18
Copy link
Author

Dart18 commented Jan 23, 2017

Switching on YES the option:
Stores -> Configuration -> General -> Web -> Url Options -> Add Store Code to Urls, the error changes in:

jquery.storageapi.min.js:2 Uncaught TypeError: Cannot read property 'it%2Fita%2Fcheckout%2Fcart%2Fblock-shipping' of null
....

The string 'it/ita/checkout/cart/block-shipping now includes the store code.
I'm not sure, but the "it" at the beginning seems to be the TLD of my website (.it)

@Dart18
Copy link
Author

Dart18 commented Jan 24, 2017

Proposed FIX:

In

<document root>/lib/web/mage/collapsible.js

at line 103 change the research value '.' with /\./g to perform the replace globally.

The result should be the following:

Original collapsible.js:

...
_processState: function () {
            var anchor = window.location.hash,
                isValid = $.mage.isValidSelector(anchor),
                urlPath = window.location.pathname.replace('.', '');
...

Modified collapsible.js:

...
_processState: function () {
            var anchor = window.location.hash,
                isValid = $.mage.isValidSelector(anchor),
                urlPath = window.location.pathname.replace(/\./g,'');
...

There is a single occurrence of 'window.location.pathname.replace' in all Magento 2.1.3 CE.
After this single change the estimation shipping and tax form appears and works.
Please check my work and, if approved, merge it as soon as possible.
Thanks

P.S.:
People who want to try this fix manually, have to clear static files cache after editing the file.

@Dart18 Dart18 changed the title Estimate Shipping and Tax Form not works due to js error Cannot read property 'it/checkout/cart/block-shipping' of null Estimate Shipping and Tax Form not works due to js error in collapsible.js Jan 24, 2017
@Dart18 Dart18 changed the title Estimate Shipping and Tax Form not works due to js error in collapsible.js Estimate Shipping and Tax Form not works due to js error in collapsible.js [proposed fix] Jan 24, 2017
@Dart18
Copy link
Author

Dart18 commented Mar 31, 2017

This issue affects also CE 2.1.5, CE 2.1.6 and CE 2.1.7

@katmoon
Copy link
Contributor

katmoon commented Sep 7, 2017

The error also reproduces on 2.0.9

@magento-engcom-team magento-engcom-team added 2.1.x bug report Component: Checkout Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 11, 2017
@Dart18
Copy link
Author

Dart18 commented Nov 2, 2017

After the update to 2.2.0 the error seems to have disappeared and I'm no longer able to reproduce it.

@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Nov 7, 2017
@magento-engcom-team magento-engcom-team self-assigned this Nov 7, 2017
@magento-engcom-team
Copy link
Contributor

Hi @Dart18
Thanks for reporting this issue.
Could you please let us know if the issue is still actual? Thank you

@magento-engcom-team
Copy link
Contributor

@Dart18, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@0m3r
Copy link
Contributor

0m3r commented Jun 18, 2018

The error also reproduces on 2.2.4

jquery.storageapi.min.js:2 Uncaught TypeError: Cannot read property 'htmlblock-shipping' of null

2018-06-18 15-40-10

the error was reproduced if window.location.pathname has two or more dots (for example /index.php/push-it-messenger-bag.html)

>window.location.pathname
"/index.php/push-it-messenger-bag.html"
>window.location.pathname.replace('.', '')
"/indexphp/push-it-messenger-bag.html"
>window.location.pathname.replace(/\./g,'')
"/indexphp/push-it-messenger-baghtml"

urlPath = window.location.pathname.replace('.', ''),

original code replace only one dot

@0m3r 0m3r mentioned this issue Jun 18, 2018
4 tasks
@VladimirZaets VladimirZaets added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jun 21, 2018
@VladimirZaets
Copy link
Contributor

Hi @Dart18. Thank you for your report.
The issue has been fixed in #16213 by @0m3r in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.6 release.

magento-engcom-team added a commit that referenced this issue Jun 21, 2018
 - Merge Pull Request #16213 from 0m3r/magento2:patch-1
 - Merged commits:
   1. 4952d50
magento-engcom-team pushed a commit that referenced this issue Jun 21, 2018
@0m3r 0m3r mentioned this issue Jun 27, 2018
4 tasks
@magento-engcom-team
Copy link
Contributor

Hi @Dart18. Thank you for your report.
The issue has been fixed in #16429 by @0m3r in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jul 2, 2018
magento-engcom-team added a commit that referenced this issue Jul 2, 2018
 - Merge Pull Request #16429 from 0m3r/magento2:2.3-develop-PR-port-16213
 - Merged commits:
   1. 59a80fd
gelanivishal pushed a commit to gelanivishal/magento2 that referenced this issue Jul 3, 2018
@gelanivishal gelanivishal mentioned this issue Jul 3, 2018
4 tasks
@sidolov
Copy link
Contributor

sidolov commented Jul 4, 2018

Hi @Dart18. Thank you for your report.
The issue has been fixed in #16491 by @gelanivishal in 2.1-develop branch
Related commit(s):

The fix will be available with the upcoming 2.1.15 release.

@sidolov sidolov added the Fixed in 2.1.x The issue has been fixed in 2.1 release line label Jul 4, 2018
magento-engcom-team added a commit that referenced this issue Jul 4, 2018
 - Merge Pull Request #16491 from gelanivishal/magento2:2.1-develop-PR-port-16213
 - Merged commits:
   1. f0a8ba8
   2. f388069
magento-engcom-team pushed a commit that referenced this issue Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Checkout Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update
Projects
None yet
Development

No branches or pull requests

7 participants