How to fix localization issue for non-available shopping in NZ in Shopify liquid?

Hi, my store won’t be selling products in New Zealand. So, if the user’s location is NZ, we want to display “Shopping not available” message on the collection page. I have written the following code to achieve this

{% if localization.country.iso_code == 'AU' %}
      You are in Australia. if Aus, products should appear here.

    {% elsif  localization.country.iso_code == 'NZ' %}
     Sorry, shopping is not available in your country.
{% endif %}

The issue is that it’s always returning true to AU even if I’m using VPN to connect from NZ.

Please help with how the code should be to be working.

Thank you.

Hi @apabaad

This is Victor from PageFly - Shopify Page Builder App

I think there are problems with the condition as elsif

For situations like this use a case statement instead

{% case localization.country_iso_code %}
 {% when "AU" %}
Product here
 {% when "NZ" %}
Product not available
{% endcase %}

Hope this can help you solve the issue

Best regards,

Victor | PageFly