Location-Based Stock Availability on the Front End

DOB
Excursionist
13 0 6

Hello Shopify community -

We are currently selling internationally and we have two warehouses using Shopify's built-in location-based inventory feature. We are also using Shopify's geolocation app. Everything works well for our logistics (who are using the API to only pull orders they ship to), however one issue we keep running in to is stock availability on the front end.

Obviously the front end is displaying something in stock if the combined inventory between both locations is >0. What we would like to do is to set up rules to show a product as out-of-stock to customers visiting from certain countries, IF that product is out-of-stock in the warehouse location we would ship to them from.

The simplest form of this logic would be:

if [customer] is in [list of countries] then show "add to cart", else show "out of stock".

 

A more complex/automated version would pull inventory count on a per-location basis (rather than the total inventory) and show the appropriate button, but that would be a bonus not a necessity. I am already aware of an app (GeoIP Blocker) that will hide products based on geoIP rules, however this would hide the product entirely from these visitors including our "back in stock" notification button which we want to avoid.

Is there any way that we can integrate this using JS/Liquid rather than an app/private app? I don't mind having to modify the code regularly to include/exclude specific products in the logic as we don't often run out of stock but it does happen and it would be great if we could set a product as out of stock based on IP when the need arises.

 

Thanks in advance for your thoughts, and please let me know if you require further explanation!

greeney2k1
New Member
2 0 0

did you find a fix for this? 

the only way I could think of a fix is as follows.... 

1) Setup shipping rate for the UK postage
2) Setup shipping rate for EU postage
3) Duplicate your store inventory 
4) Assign original store inventory to UK postage rate
5) Assign duplicated inventory to EU postage rate
6) Set stock levels on all products manually for UK & EU to ensure accuracy
7) Use an IP blocker to hide products for certain countries - Recommended app - https://apps.shopify.com/geoip-based-product-blocker - $6.99 per month - this way if someone from the EU visits your store they will only see the EU products with accurate stock levels and someone from the UK will only see UK products with UK stock levels 
 
Not ideal if you have 000's of SKU's ... but it should work 
0 Likes
DOB
Excursionist
13 0 6

Hey there - I tried the IP blocker app but it loads the script from an external server and sometimes the products would show for up to 3-4 seconds before hiding. This was noticeable enough for customers that we got rid of it. Also my thought process was that if we're going to duplicate our entire inventory we might as well just go the official "clunky" route and have multiple stores...but that means a lot of extra monthly fees.

One solution I'm working on right now is using Product Inventory Information which is an app that will display multiple inventories divided across your warehouse locations on the front end. It inserts a div with unique classes for in stock, out of stock etc. and also has a geolocation feature so you can define who will see which location depending on their country. Out of the box it doesn't do what we need, BUT it does separate the inventory display on the front end and crucially injects the app's unique "outofstock" class into the page.

I'm hoping that with a bit of custom JS/jquery, I can have a script hosted locally search the page for the "outofstock" class the app inserts, and then manually set the add to cart button to inactive through JS. Not sure your level of coding is, but I have a JSFiddle with the general concept working on a simple HTML button, I just need to integrate it with Shopify: https://jsfiddle.net/gradivis/16Lnzqf5/2/

Again it's not ideal (if I can get it working), and would much prefer to do it through Shopify's geolocation app (that we're already using for currency and language). Would be relatively straight forward for them, rather than having multiple geolocation calls loading through separate apps.

 

0 Likes
DOB
Excursionist
13 0 6

For anyone coming in from Google, I just wanted to add the GENERAL code we're currently using in the hope that it might prove useful. I really wish this was included as standard in Shopify - it's still strange to me that handling inventory internationally was not included in their cross-border sales push, as it's pointless to serve a customer a website in their language and currency but not be able to serve them localised inventory levels.

 

As mentioned earlier, we are using TomIT's excellent inventory app to enable front-end display of geolocated inventory. This injects a DIV into the front-end that is geolocated and separated according to your Shopify locations. It's a great start, but it often means that you are showing for example "EU Inventory = 0" while still allowing EU customers to click "add to cart".

My addition is not exactly elegant (as it's not a language I've studied) but I made a little bit of JS that runs to check to see what inventory status Tom's app is injecting, and then changes the add-to-cart button based on that status (over-riding Shopify's use of total inventory for add to cart/out of stock buttons). It can sometime take a second or two to load since it's waiting for Tom's app to inject the inventory status, but it works as long as the visitor can be geolocated.

@Thomas_Lang1- do you think this sort of feature (being able to modify the add-to-cart button functionality when your geolocated inventory shows out of stock) could be added to your very useful app?

 

 

 

 

setInterval(function(){
  var t=document.getElementsByClassName("tomItInventoryLocationNoStock")[0].innerHTML;
  if(t="Currently Sold Out"){
  	var b=document.getElementsByClassName("add-to-cart")[0].setAttribute("disabled","disabled");
    var c=document.getElementsByClassName('add-to-cart')[0].innerText = 'SOLD OUT';
  }
  console.log(t);
},0);

 

 

 

 

rohitmishra
Shopify Staff
Shopify Staff
20 1 9

Hey all, 

I work on cross-border commerce at Shopify and I wanted to acknowledge that this is an issue that we are looking in to. 

I do not have an estimated timeline at the moment. If others in this thread have related use cases, feel free to add here. 

- Rohit 

Product Lead, Global Commerce and Sales Tax
DOB
Excursionist
13 0 6

Rohit,

Thanks so much for your response! I'm thrilled to know it has been acknowledged and that you're looking in to it. It truly is a huge part of cross-border commerce, and a significant portion of our cancelled transactions are due to stock being unavailable in a customer's shipping zone, despite them being able to purchase an item as total inventory across locations is >1.

Since a lot of your cross-border customers are using the Geolocation app for Shopify payments I think it would be a great line to follow in using the existing browser geolocation call to then deliver accurate inventory levels as well as currency. This would be the most streamlined approach in my opinion anyway, although I'm more UX/UI than back-end.

Really hope that this is something you and your team can find a solution for - it's really the only source of headaches we've had since switching to Shopify and I can only imagine the increase in market share you would see from International companies like ours who aren't jumping over to Shopify just yet. We had a working (custom) solution on Woocommerce and I know it's on BigCommerce's roadmap right now...first person with an out-of-the-box working solution is going to snap up a LOT of new business! Just my 2 cents

 

 

Harmony
Tourist
4 0 0

That's great, especially now with Brexit. We have EU and UK locations and it's a mess for customers importing from opposite location.

0 Likes
nicolewwj
New Member
1 0 0

Thank you so much for your thorough explanation of this multiple-warehouses issue and your work-through. I also found this problem to be quite a headache for me and my customers. I'm looking into using the Product Inventory app and hire a coder to do some customisation so that the warehousing info is not displayed on the product page but does trigger the "out-of-stock" label and toggle off the "add to cart" button.

I would appreciate to hear about any update if you happen to find even a better solution?

 

Thanks!

0 Likes
TritonNoirFab
New Member
1 0 0

Hi,

We are using Shopify since 2014 but as soon as we needed to have advanced control on how we deal with location based restrictions in conjunction with inventory management we had to move to WooCommerce.

It's quite sad that as of today, 7 years later, Shopify does not provide a satisfying solution for cross border multi warehouse stores.

Our needs:

  • One store
  • Selling the same products worldwide
  • Product variations (languages)
  • 5 Warehouses serving different countries or US states
  • Inventory managed per Warehouse
  • Multi currency
  • Multi Language
  • Availability of a product to a given customer is based on shipping address country/state (linked to a specific warehouse).

As of today, we are using custom made (badly developed) plugin on WooCommerce for the products and Shopify for a small portion of our catalog. 

I can(t find an app that does all that correctly.

We would definitely strongly consider jumping back to Shopify if we had a robust solution (that does not require advanced coding).

Fabrice

0 Likes
Dadan1
New Member
1 0 0

Any update here Rohit? 

0 Likes