magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Checkout 'hanging' for 2 out of 3 websites running the SAME Magento code #2933

Closed martijnhovinga closed 8 years ago

martijnhovinga commented 8 years ago

I installed Magento 2 with Softaculous successfully. I only added code to .local host in Magento root for running 3 stores based on the same Magento installation (taking the added code out did not make any difference to the issue below).

On 2 of my stores, after adding to cart and clicking "Go to Checkout' the screen only displays the 'logo and the 'order summary' without the 'shipping' step, see https://babyplus.com.my/checkout Same for https://contoursbaby.com.my/checkout

On the third store however it consistently works fine, running the SAME Magento installation: https://babyfair.com.my/checkout

'Checkout with PayPal' works fine on all websites.

I compared the settings in Store/Config and cannot find any significant differences. Even after a new installation, the problem persists.

I had a well-known Magento extension developer have a look at this, however they could not find the solution. According to their professional opinion, this could be a 'bug'.

ishakhsuvarov commented 8 years ago

@martijnhovinga Thank you for reporting the issue. Currently we can not reproduce described issue with clean magento installation. Please try to install Magento in one of the recommended ways and test the same case without third-party modules to see if the issue persists.

martijnhovinga commented 8 years ago

@ishakhsuvarov Thanks for your feedback. My assumption is that is a bug indeed in the STATE OPTIONS settings under default configuration. Initially I ticked Malaysia in 'State is Required for'. This is similar to https://github.com/magento/magento2/issues/1508

I found this Javascript error on the checkout pages of babyplus.com.my and contoursbaby.com.my:

/pub/static/frontend/Magento/luma/en_US/Magento_Ui/js/form/element/region.js:34 Uncaught TypeError: Cannot read property 'is_region_required' of undefined does NOT occur on babyfair.com.my

After changing State Options Settings, the problem still persists in the 2 sites.

srynot4sale commented 8 years ago

Solved for me - fix was to enable the country specified in the "Default Tax Destination -> Default Country" in "Country Options -> Allowed Countries"

martijnhovinga commented 8 years ago

Thank you very much! This worked for me as well! PROBLEM SOLVED!

astorm commented 8 years ago

@daim2k5 -- Why'd the ticket get closed? It's great these users solved their problem, but it sounds like they had a valid configuration of Magento that ended up creating javascript errors that blocked other page functionality, and was hard to diagnose. Shouldn't the platform fix that?

srynot4sale commented 8 years ago

Agreed - this is a horrible bug. Needs to be prevented from occuring

davidalger commented 8 years ago

@martijnhovinga Since you seem to have figured out a way to resolve your issue, would you be able to try providing steps to re-create the issue for the Magento team to be able to reproduce and solve the underlying bug? This definitely sounds like a bug; an obscure misconfiguration such as this should not be able to cause JS errors on the front-end like this.

If I read you right, steps may be something like a) setup store; b) set "State is Required for" to something; c) bug (with workaround being to also configure other setting.

martijnhovinga commented 8 years ago

@davidalger Without doubt, this is a bug. Even worse, it affects the most vital part of the system, i.e. the checkout process and most customers who wish to buy and face this problem get frustrated and decide to leave the website.So I am very thankful that you will look into this for the sake of others using the system. The problem was caused by a discrepancy between Default Country and Default Tax Destination Calculation.

The settings in default configuration when the problem occurs are as follows: "Stores > General > Default Country: Malaysia and >Allowed Countries: Malaysia & Singapore" and "Stores > Sales > Tax > Default Tax Destination Calculation: United States" This resulted in a Javascript error: /pub/static/frontend/Magento/luma/en_US/Magento_Ui/js/form/element/region.js:34 Uncaught TypeError: Cannot read property 'is_region_required' of undefined

By changing only "Default Tax Destination Calculation to my default Country, i.e. Malaysia, the problem was solved.

I also configured 2 additional websites, however I don't believe that is relevant. The only surprise was that it worked like a charm in one of the 2 additional stores.

If you want to have access to my production system to check and reproduce, I am willing to grant that depending on the timing (I am in Malaysia/Singapore time zone).

My recommendation is that the value of Default Tax Destination Calculation would be synchronized automatically with the value of the Default Country.

Thank you all.

ishakhsuvarov commented 8 years ago

@martijnhovinga @srynot4sale Thank you for finding the correct steps to reproduce the bug. We have created an internal ticket MAGETWO-47868 to fix the issue.

ishakhsuvarov commented 8 years ago

Closing the ticket, as the fix for this issue had been delivered to the develop branch. Please feel free to reopen if there are any additional questions.

martijnhovinga commented 8 years ago

Thank you.

On 2016-01-28 18:36, Ievgen Shakhsuvarov wrote:

Closing the ticket, as the fix for this issue had been delivered to the develop branch. Please feel free to reopen if there are any additional questions.

Reply to this email directly or view it on GitHub [1].

Links:

[1] https://github.com/magento/magento2/issues/2933#issuecomment-176239047

dimasdwika commented 8 years ago

I can still replicate this issue with these configuration (on 2.0.5)

"Stores > General > Default Country: Australia" "Stores > General > Allow Country: Australia" "Stores > Sales > Tax > Default Tax Destination Calculation: Australia"

When going to checkout, the issue still persist with Cannot read property 'is_region_required' of undefined as per #3142

And by changing "Stores > General > Allow Country: Australia, United States", it will fix the problem. However, this will prevent using Magento to only sell outside United States.

ignaciomella commented 8 years ago

I have the same problem on 2.0.5.

Country is Chile but steps too recreate problem are the same as detailed by dimasdwika.

maksek commented 8 years ago

@dimasdwika, @ignaciomella - the fix was delivered to the develop branch, as @ishakhsuvarov mentioned in his comment. develop != 2.0.x, I will contact product team to validate if it will be delivered into 2.0.x, otherwise fix will be available in 2.1.0

komsitr commented 8 years ago

@maksek I apply this fix to the version 2.0.7 but the issue still persists https://github.com/magento/magento2/commit/7b1ac83b92228803884f04cb74505b776bef59cd

loadByStore() function still returns all countries in the list instead of Singapore which is the only country in default country / allowed country / and default tax destination country.

komsitr commented 8 years ago

OK I find the problem. Please consider the fix below.

Cause: is_region_required key is missing from the country object being retrieved from country.indexedOptions. Referring to "app\directory\Model\ResourceModel\Country\Collection.php" line: 231

if ($this->helperData->isRegionRequired($value)) {
    $option['is_region_required'] = true;
}

This key will be set only this country requires its region. But the script "app\ui\view\base\web\js\form\element\region.js" doesn't check the existence of this key before referring it.

Solution: Method 1: Add an else condition / cons is page size will increase because the key is added to all country objects

if ($this->helperData->isRegionRequired($value)) {
    $option['is_region_required'] = true;
}
else {
    $option['is_region_required'] = false;
}

Method 2: Check if the key exists in region.js. I am more on this method due to the cons above mentioned.

if (!('is_region_required' in option) || !option['is_region_required']) {
    this.error(false);
    this.validation = _.omit(this.validation, 'required-entry');
}

I believe that this issue occurs in post-code.js too because the key is_zipcode_optional is using the same implementation method.

webspeaks commented 8 years ago

Exists in 2.0.7. Doesn't get resolved when I set Tax destination country to same as Only allowed country.

hpatelgit commented 7 years ago

Hello,

Yes @webspeaks i am also facing this issue into Magento latest ver. 2.1.2. It will work for first order but if you try same country and state with reorder it will gives error 'You can't use the payment type you selected to make payments to the billing country.' and in console it will show 'jquery.js:9666 PUT http://test.com/rest/default/V1/carts/mine/selected-payment-method 400 (Bad Request)'

Please help me to resolve this issue.

Thanks

hpatelgit commented 7 years ago

Still this issue present into magento 2.1.3.

PrajapatiChirag commented 6 years ago

I can still replicate this issue with these configuration (on 2.0.7)

"Stores > General > Default Country: Australia"
"Stores > General > Allow Country: Australia"
"Stores > Sales > Tax > Default Tax Destination Calculation: Australia"

Solution: Method 1: Add an else condition / cons is page size will increase because the key is added to all country objects

if ($this->helperData->isRegionRequired($value)) {
    $option['is_region_required'] = true;
}
else {
    $option['is_region_required'] = false;
}

Method 2: Check if the key exists in region.js. I am more on this method due to the cons above mentioned.

if (!('is_region_required' in option) || !option['is_region_required']) {
    this.error(false);
    this.validation = _.omit(this.validation, 'required-entry');
}
rvinothraj commented 6 years ago

Hi Guys, Just now(21-02-2018) i faced this issue, i planed to follow @PrajapatiChirag , but after the the simple way is there on Magento configuration.

Steps:

*   Select Singapore in optional country list.
*   Go to -> Admin Panel -> Stores -> Configuration -> General -> General -> Zip/Postal Code is Optional for 
* Uncheck "Use system value"
* Then select your country (My country: Singapore) -> save.
* Finish -> issue solved.

Thanks, MaaRaa

0franco commented 6 years ago

Same issue v. 2.2.2 , solved with the config change provided by @srynot4sale, thank you

peterjaap commented 6 years ago

Backward patch for 2.2.6;

diff --git a/view/base/web/js/form/element/region.js b/view/base/web/js/form/element/region.js
index fec69bf..9b7b9a9 100644
--- a/view/base/web/js/form/element/region.js
+++ b/view/base/web/js/form/element/region.js
@@ -40,7 +40,10 @@ define([
                 return;
             }

-            defaultPostCodeResolver.setUseDefaultPostCode(!option['is_zipcode_optional']);
+            defaultPostCodeResolver.setUseDefaultPostCode(true);
+            if (option && (!('is_zipcode_optional' in option) || !option['is_zipcode_optional'])) {
+                defaultPostCodeResolver.setUseDefaultPostCode(false);
+            }

             if (this.skipValidation) {
                 this.validation['required-entry'] = false;
-- 
2.17.1
rstylenl commented 5 years ago

I had the same issue when trying to edit a customer. All was fine after editing the files but when i installed a Vanilla version of Magento 2.2.3 and imported the customer to that one, i could just edit the customer without needing to change the code. So that made me look at the database.

The customer grid was not showing Customer group and Website, so i deced to look at the difference in database fields. Came accross some things that where not right in the Live website, so i changed those fields, and when i edited a customer the Customer group and Website showed up again. But it was still not showing up in the grid view, even after running a php bin/magento index:reindex.

Then I came across an one single entry in eav_entity table which didn't look right. it looked like this: eav_entity

i looked at the vanilla install and there that table was emtpy, so i decided to backup this table and delete this row. After that i changed back the post-code.js and region.js script to it's original state, and now i can edit customers without isues.

If you have any questions please let me know.