Theme addresses doesn't show default country
See original GitHub issueThe default country of the logged in user isn’t selected on page load.
Issue seems to be here:
if (countrySelect.dataset.default) { countrySelect.value = countrySelect.dataset.default; }
The value should be a country code for it to work, but countrySelect.dataset.default is a full country name.
For example. If one uses data-default=“BE” (Belgium) in templates/customer/addresses in stead of data-default=“{{ form.country }}” it does work.
Note: I’m using a Dutch theme locale on the slate starter theme.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:5
Top Results From Across the Web
Default country set in the form display settings is not applied
Problem/Motivation If I add a address field to a content type and set a default country, the setting is not applied when viewing...
Read more >Country not shown | WordPress.org
I have tried this but still no country is shown.. Is this because the country is the same as the shop country location?...
Read more >Setting a Default Country at Checkout - Cratejoy Support
This article will describe how to set this equal to a new country. If your theme does not have a `components` folder, this...
Read more >Help: Set default country in Address field | 123FormBuilder
You can establish what default country appears on your form in the Address field. Add/Click on your Address field and in the left...
Read more >How to Change the Default Address Format — AudioTheme
If you're not using the a country code, the plugin attempts to match the country ... doesn't work for you and you want...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found another possible bug. If the country is set to “Russia”, the default value of province is not working. My workaround: in
populateZones()
replacereturn zone.name === zoneSelect.dataset.default;
with
return zone.code === zoneSelect.dataset.default;
It requires to make a change in addresses.liquid file. Replace
with
To add to the previous comment here, data-default is expecting the country code and province code but with the example in the read me they use {{ form.country }} and {{ form.province }} which return the country name and province name which leaves the fields blank. Also had to change them to {{ address.country_code }} and {{ address.province_code }} for the field to show the correct values.