Best way to hide prices based on my website visitor's country?

We mainly sell products on Shopify in the USA, but we have two product distributor’s located in Australia and New Zealand.

These distributors want us to not display prices on our website when visitors from Australia and New Zealand view our website. (Ideally where a product price is displayed it might instead have a word or two of explanation, such as “Contact Local Distributor”.

What is a reliable or recommended way to do this? Are there certain Shopify apps that can do this?

**What I have tried —**I first learned that by default Shopify detects a visitor’s country when they visit a Shopify website. And that country name gets stored in the variable: localization.country (is this incorrect information?)

Then with code you can check the value of this variable, and based on that test hide or display the price for example. This sounded promising.

I got a VPN for my computer, and wanted to do a test to see if in fact this variable gets set to different countries.

I tried this, but had some problems. I added a VPN to my computer to test and check the variable, and set the VPN for a non-USA country. Then checked the value of this localization.country variable. The value was always USA in chrome browser, and United Arab Emirates in Firefox. It never matched country my VPN was set on.

I don’t not know what is going on. Did Shopify not actually detect the country and store it in this variable?

I asked Shopify support, and they said the reason it did not work was because my site was not using a custom domain. (Currently, it is being set up and using the default Shopify URL). This does not sound right to me?

Problem is, I cannot switch to my custom domain until this hiding prices thing is working.

The approach I took may not be the best way to do this, and I look forward to any better ways to accomplish this.

Hello @Anthony_ny27
Greetings and Happy Holidays.

You can do that easily with just a liquid customisation. I have created a code snippet for you, wherever your prices are rendered, you can use this.

With the help of localization.market.id you can find if the customer is from US or other markets. From here you can find your market id.

Here is example Snippet


                {% if localization.market.id == 45450494112  %}
                  {%- render 'price',
                    product: product,
                    use_variant: true,
                    show_badges: true,
                    price_class: 'price--large'
                  -%}
                {% else %}
                 
                  {% if localization.market.id == 45450461344  %}
                     Contact Local Distributor
                    

Country = **New Zealand**

                    

Market ID = **{{ localization.market.id }}** 

                  {% elsif localization.market.id == 45450526880  %}
                     Contact Local Distributor
                    

Country = **Australia**

                    

Market ID = **{{ localization.market.id }}** 

                    {% else %}
                     Contact Local Distributor
                  {% endif %}
                {% endif %}

In above customisation I checked with the help of Market ID, if the visitors Country is USA then it will show Price of the Product to Visitors within US.
If Customer is from Anywhere around the world other than US, then they will see the Contact Local Distributor hyperlink which will redirect them to Local Vendor and in New Zealand and Australia can be redirected to dedicated pages for those two Region. Let me know if this helps or you need help setting this up for your store. Thanks

Here are some screenshorts

Note:
Country and Market ID text shown in screenShots are just for demo purposes

You can test these different Markets here on this link using any VPN (I am using Urban VPN in Incognito Mode, so Shopify Don’t cache the location)
https://for-wishlist-app.myshopify.com/products/the-multi-location-snowboard?_ab=0&_bt=eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaU5tYjNJdGQybHphR3hwYzNRdFlYQndMbTE1YzJodmNHbG1lUzVqYjIwR09nWkZWQT09IiwiZXhwIjoiMjAyNC0xMi0yMFQxMjoxOTo1MC43NzRaIiwicHVyIjoicGVybWFuZW50X3Bhc3N3b3JkX2J5cGFzcyJ9fQ%3D%3D–85dc541f05a8ac16362fe67ac858cae3a587bf08&_fd=0&_sc=1&key=b0924d4caa21d1d1d5cb3c538d2571e01dbd9f066db9f252e42636f8ba7e50dd&preview_theme_id=138649764000

Thank you for the detailed explanation and the screenshots, and the code snippet.

Just as a test, I added short bit of code to product page to check the value of the localization.market.id variable.

I tried to preview it by suing Settings > Markets, and Preview of markets i have: United States, International, and Australia.

At moment, I am trying to preview united states, and my firefox browser is showing market id for international and my chrome browser is showing market id for australia. I’m so frustrated. What could be going on?

It seems check the value of this market id is not reliable?

I think most probably this is because of Browser Caching issue,
Could you please share your store URL so I can test this on my end?
You can also clear your browser cache and in incognito mode try with Urban VPN and see if it returns you the correct values? Thanks