BLOG

Collection Page redirect base on country code

{%- for collection in collections -%}
{%- if request.path == "/collections/accessories" and localization.country.iso_code == 'IN' -%}
<script>window.location.href = "http://stackoverflow.com";</script>
{%- endif -%}
{%- endfor -%}

<script>
$(document).ready(function(){
$.getJSON("https://ipinfo.io", function(data) {
console.log(data.country);
if(data.country == "IN"){
window.location.href = "http://stackoverflow.com";
}else if(data.country == "RO"){
window.location.href = "https://www.google.com";
}
});
});
</script>


Share:

Post a Comment!