Shopify markets - How to code only to the selected country in the market

Hi im a developer in the shopify plus account, so our company just use the market feature to expand its business to new zealand, and i want to try to code in the theme preview something like

if nz market
Welcome to the nz market

i already search in the google and it says to use

{%if localization.market.handle ==‘NZ’}
Welcome to the nz market
{% endif %}

but when i try to change the view as new zealand in the market selector , it’s open the our live domain not theme preview one, so i wonder how can i detect in the liquid that the website i open is from the NZ/AU market?

thanks

Victor17_0-1744792433474.png

You’re definitely on the right track with using localization.market.handle, but there’s a key limitation with how Shopify handles Markets in theme preview mode.

When you’re using the theme preview URL, Shopify doesn’t fully simulate Markets behavior (like geolocation or manually selected markets). If you switch to the New Zealand market in the market selector, it redirects to the live site, which breaks the preview and your ability to test your liquid condition:

{% if localization.market.handle == 'NZ' %}
  Welcome to the NZ market
{% endif %}

This works perfectly in production, but not inside theme preview.

Here are a couple of workarounds you can try:

1. Simulate market via URL parameter (for testing only)

You should be able to temporarily modify your theme to detect a fake market parameter in the URL:

{% assign debug_market = request.query_params.market %}
{% if debug_market == 'NZ' %}
  Welcome to the NZ market (debug mode)
{% endif %}

Then test it with a URL like:

https://your-store.myshopify.com/?preview_theme_id=123456789&market=NZ

This won’t use Shopify’s localization object, but it lets you simulate the output during development.

2. Use localization.country.iso_code as a fallback
If your markets are country-based (e.g., NZ market = New Zealand), you can use:

{% if localization.country.iso_code == 'NZ' %}
  Welcome to the NZ market
{% endif %}​

This tends to work better in preview mode since localization.country is often available even if market isn’t.