Magento2: KnockoutJS doesn't catch customer country in checkout (2.0.6)

Created on 4 Aug 2016  路  12Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2.0.6

    Steps to reproduce

  2. proceed to checkout

  3. fill out all forms (proceed as guest)
  4. check billing details on payment selection page (Step 2)

    Expected result

  1. Country is shown, according to configured layout in Shop -> Settings -> Customer -> Customer Configuration. See my case config:
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}{{depend firstname}}<br/>{{/depend}}
{{depend company}}{{var company}}<br />{{/depend}}
{{if street1}}{{var street1}}<br />{{/if}}
{{depend street2}}{{var street2}}<br />{{/depend}}
{{depend street3}}{{var street3}}<br />{{/depend}}
{{depend street4}}{{var street4}}<br />{{/depend}}
{{if postcode}}{{var postcode}}, {{/if}}{{if city}}{{var city}}{{/if}}<br/>
{{if country}}{{var country}}{{/if}}<br/>
{{depend telephone}}T: {{var telephone}}{{/depend}}
{{depend fax}}<br/>F: {{var fax}}{{/depend}}
{{depend vat_id}}<br/>VAT: {{var vat_id}}{{/depend}}

Actual result

  1. Country is not shown in Checkout. INstead, a <br /> element get created (which would be fine, if theres a country echo)

bildschirmfoto 2016-08-04 um 12 22 58

DOM:

<div class="billing-address-details" data-bind="if: isAddressDetailsVisible() &amp;&amp; currentBillingAddress()">
    <!-- ko text: currentBillingAddress().firstname -->Max<!-- /ko --> <!-- ko text: currentBillingAddress().lastname -->Schimmelmann<!-- /ko --><br>
    <!-- ko text: currentBillingAddress().street -->Musterstra脽e 1<!-- /ko --><br>
    <!-- ko text: currentBillingAddress().city -->Musterhausen<!-- /ko -->, <!-- ko text: currentBillingAddress().region --><!-- /ko --> <!-- ko text: currentBillingAddress().postcode -->12345<!-- /ko --><br>
    <!-- ko text: getCountryName(currentBillingAddress().countryId) --><!-- /ko --><br>
    <!-- ko text: currentBillingAddress().telephone -->1234512345<!-- /ko --><br>
    <button type="button" class="action action-edit-address" data-bind="visible: !isAddressSameAsShipping(), click: editAddress" style="display: none;">
        <span data-bind="i18n: 'Edit'">Bearbeiten</span>
    </button>
</div>

What is this bug, and how can we hotfix it?

ADDITIONAL:
it also doesn't update itself automatically.

If you go back one step to change your billing and shipping details, the Payment Outputs are still on the "old" values. You need to uncheck and recheck the "Same Shipping as Billing Adress"-Field in order to get updated customer details. This might be another bug, probably.

Frontend Cannot Reproduce Clear Description Format is valid bug report

Most helpful comment

@miakusha thank lots.
pub/static/frontend/magento/theme/en_US/Magento_Checkout/js/view/billing-address.js

addressOptions.push(newAddressOption);

       // start adding fix
       if (_.isEmpty(countryData())) {
    countryData(customerData.reload(['directory-data'], false));
       }
       // end adding fix

return Component.extend({

All 12 comments

Same problem still in 2.1.1. currentBillingAddress().countryId does return the country code, but the getCountryName() doesn't return the full country name

Is there any update on this? The bugs there for a while. Internal Ticket #?

I have the same problem in magento 2, the billing address is not showing on checkout page in magento 2

Currently not experiencing this issue anymore in 2.1.7

@grasdaggel I cannot reproduce this issue. Please, provide more information or confirm that it's not relevant for now.

I have the issue now on a clean 2.1.7 install. The issue gets triggered for me when some "Top destinations" (countries) are selected in Stores->configuration->General->General->Country Options->Top destinations

The issue can not be reverted by deselecting the Top destinations. Also, at least one Top destination remains active at all times, even after + click country (to deselect) and save config. Use system value is not present as an option.

Hi, @michel334. Can you please specify some more settings of your store? I observed the faulty behavior of Top Destination, but still can't reproduce the main issue with missing country information on checkout page.

Hello @IlnitskiyArtem. i upgraded to PHP Version 7.0.21 and i cannot reproduce the missing country issue anymore on a clean install using top destinations.

I now have the issue again (missing country information on checkout page)
On a clean install of Magento 2.1.7 on apache with PHP Version 7.0.21
I have the issue both in developer and in production mode
No modules, just default Luma theme
i mostly use the Chrome browser Versie 59.0.3071.115

here is a link to a testshop with the issue, and a javascript popup when the issue occurs

http://magentotest.michelwebdesign.nl
http://magentotest.michelwebdesign.nl/phpinfo.php

i no longer use the top destination function, but somehow this issue gets triggered

i did some searching

In this file
vendor/magento/module-checkout/view/frontend/web/js/view/billing-address.js

        getCountryName: function (countryId) {
            return countryData()[countryId] != undefined ? countryData()[countryId].name : '';
        }

this function returns empty string because countryData is empty

In the same file i see
countryData = customerData.get('directory-data')
but after that call countryData is empty when i observe the issue

This seems to fix the problem for me

    addressOptions.push(newAddressOption);

           // start adding fix
    if (_.isEmpty(countryData())) {
        countryData(customerData.reload(['directory-data'], false));
    }
           // end adding fix

    return Component.extend({

I found the fix bij googling around and found this site:

https://code.aliyun.com/runphp/magento2/commit/7310e134a0472b9461f047b18f28101d606cfd13?view=parallel

this also seems related (maybe introduced the bug?) This seems to be the current state of the files in Magento 2.1.7

https://github.com/magento/magento2/commit/398ecd54ae54356726d1713b7c0ef9e388391a50

some more related files
vendor/magento/module-checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js
vendor/magento/module-checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js

The issue seems strongly related to (browser) caching. Sometimes everyting works fine (country is shown ), unitl i test with a cleared browser cache, then country is empty again in shipping and billing details.

@grasdaggel, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.1.9

@miakusha thank lots.
pub/static/frontend/magento/theme/en_US/Magento_Checkout/js/view/billing-address.js

addressOptions.push(newAddressOption);

       // start adding fix
       if (_.isEmpty(countryData())) {
    countryData(customerData.reload(['directory-data'], false));
       }
       // end adding fix

return Component.extend({

Greats its working good @lxgiang90

Was this page helpful?
0 / 5 - 0 ratings