Hello,
My name is Kenan
I am a Shopify Developer
and Award-winning UI Designer from London / The UK.
40.758896° N
-73.985130° W
My name is Kenan
I am a Shopify Developer
and Award-winning UI Designer from London / The UK.
40.758896° N
-73.985130° W
+44 7 393 597 802
- Date
- Jan 15, 2024
- Platform
- Shopify Development
Developing a Shopify Theme with Built-in Country Detection
Setting Up Your Shopify Theme
- Add Country Detection to your store:
- Open your Shopify store's admin.
- Navigate to Online Store > Themes.
- Click "Edit Code" on the theme you want to modify.
- Find a theme.liquid
- Add tihs code after </body> tag
- If needed, create a duplicate theme to avoid affecting your live site during development.
Implementing Country Detection
- Use jQuery for Geolocation:
<script>
$(document).ready(function() {
var detectCountry;
jQuery.get('/browsing_context_suggestions.json', (d) => {
detectCountry = d.detected_values.country.handle;
console.log(detectCountry);
});
});
</script> - You can get Country Code & Full Country Name :
{handle: 'GB', name: 'United Kingdom'}