Re: Market handle gives long code

Market handle gives long code

JulianOri-
Shopify Partner
5 0 0

I have two different stores. One for NL (Netherlands) and one for DE (Germany). Both stores have only 1 market. First one Netherlands and the other Germany. Now I notice that if I check the market handle by doing:

<script>console.log({{ localization.market.handle | json }})</script>

(because it's the only way I found to check market handle)

the Dutch handle is 'nl', which stands for Netherlands. That is exactly what I want, but the German handle is not 'de', it is like 3e93e378-18c4-485f-b7be-9f58cc5b7522.

What is the reason for the Germany market to have such a handle? Is there a way to change/avoid it? It is quite important for using context templates (Even though I could use the long handle, I still would like to change this, because I work in a company with multiple developers).

Replies 5 (5)

tim
Shopify Partner
3917 397 1443

Have you tried localization.country.iso_code?

Or localization.language.iso_code?

Or shop.address.country_code?

Whichever better reflects the data you need...

 

Because market is not always a single country.

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
JulianOri-
Shopify Partner
5 0 0

Thank you for replying!

It isn't really about the way of getting the right code, it is specifically about the market handle, because to use different templates in different markets you need to have a second json file with the market handle in it. So for index.json, you need a index.context.*handle*.json. And I only use one market in the store. With the dutch store it does show 'nl', but the german doesn't show 'de' and the settings are the exact same.

tim
Shopify Partner
3917 397 1443

Aah, I see.

The reason could be if you've modified and re-created your market.

Technically, you should be able to change the handle with GraphQL at least -- https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/marketUpdate 

Not sure if you'd need to update your theme templates then.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
JulianOri-
Shopify Partner
5 0 0

Thank you for your answer! So I've seen people say that you can change the market handle, but I don't see the feature you are describing to edit market.

 

Screen Shot 2024-07-02 om 09.13.43.png

Screen Shot 2024-07-02 om 09.13.25.png

tim
Shopify Partner
3917 397 1443

It's like your second screenshot, but market must not be primary:

Screenshot 2024-07-02 at 8.15.04 PM.png

 

So, create new market, swap them, modify Germany and swap back?

Or, use GraphQL -- just tried and was able to modify primary market. Note that existing filenames in theme would not change automatically.

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com