Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
I was wondering if it is possible to show/hide product variants depending on the location of the customer?
For example we stock some variants in Europe but not in the US, would it be possible for me to hide those variants when a US customer is viewing them rather than just charging extra to ship them from Europe.
I look forward to reading any responses!
Kind regards,
Mike
Hi @ExactArt
This is indeed doable through a combination of Geolocalization APIs that communicate the user's location and the implementation in the liquid code that fetches the appropriate variants through the value shared by the API.
Sharing a solution isn't very straightforward here, should you want to tackle this from your end I suggest you use ipstack.com as a starting point and merging this with the product-template liquid file that controls the variants displayed to the user. Variants would need metafields for country detection and selection.
Should you need assistance please don't hesitate to reach out privately so our team can get this done for you if needed.
Cheers!
That app slows down the site. Not great for the UX.
Even though the hiding does work well.
But this (and hiding when stock is zero) should have been integrated in Shopify from when you started with Markets etc.
Hi Mike did you find a solution to this issue? I have a similar problem. I want to hide certain variants from USA customers and hide other variants from UK customers.
We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024