Showing Inventory depending on State not Countries

Showing Inventory depending on State not Countries

A recent predicament we received involved a client whose main requirement was to not allow clients to purchase products across states. Even after they created specific shipping locations, Shopify would still show customers the product is in stock, whereas in reality the product was out of stock in the state the user was visiting from.

How to find the state?
Our solution involved using a geolocation service to pinpoint the state, making sure the Shopify locations were written exactly as the output from the geolocation service. The output was a JS variable from a JSON response.

Display front-end version of inventory quantity per location
Once we had this variable, we used a Shopify application in a hidden display that shows inventory per location on the front-end (something Shopify doesn't allow via Liquid natively weirdly).

Disable Add To Cart & Other Logic
Using Javascript, we would check if the State of the user was present in the list of location. If it wasn't, the add to cart would be greyed out. If it were present, we would then keep things as is, but make sure that the quantity selector is limited by the amount of that specific location's inventory.

Result is a site that checks user's state, sets inventory status according to stock in location and not globally while also allowing users to only purchase the limited stock in that location.

Do you have a requirement similar to this? Let us know and we'll be happy to help you get this done swiftly! 

Comments 0

Leave a comment

Please note, comments must be approved before they are published