App That Updates Metafields With Inventory By Location - Display Inventory By Location Product Page

Highlighted
Excursionist
17 0 7

Hello All,

 

I've spent days trying to find a solution to the following problem and I'm hoping there is an existing app that can get me closer to a solution.

 

Problem: We need to display inventory by location on the front-end to the user (we have 4 B&M stores, and want to help the customer know if it's in stock before they visit). The Shopify locations feature seems to only be half baked, they store the inventory by location in the back-end but only pass the aggregate amount of all stores to the front-end. I've pointed this out to Shopify support but I doubt a fix is on its way any time soon.

 

What I'm looking for: An app that can update the product metafield with the inventory on hand, after which I can then easily display it on the front end. I'm not an app developer but from what I can tell it has to just poll the current inventory through the API and then save it in the correct product metafield. I'm hoping that there is another app that already does this or one that is close that I can repurpose.

 

If anyone has any suggestions or clues as to where I can look I would appreciate it, I've done every type of search I can think of to find this. We may be pursue the custom app route if nothing exists, but I hope we can find a preexisting app.

 

 

1 Like
Highlighted
New Member
1 0 1

+1 need this app!


@mfsyyc wrote:

Hello All,

 

I've spent days trying to find a solution to the following problem and I'm hoping there is an existing app that can get me closer to a solution.

 

Problem: We need to display inventory by location on the front-end to the user (we have 4 B&M stores, and want to help the customer know if it's in stock before they visit). The Shopify locations feature seems to only be half baked, they store the inventory by location in the back-end but only pass the aggregate amount of all stores to the front-end. I've pointed this out to Shopify support but I doubt a fix is on its way any time soon.

 

What I'm looking for: An app that can update the product metafield with the inventory on hand, after which I can then easily display it on the front end. I'm not an app developer but from what I can tell it has to just poll the current inventory through the API and then save it in the correct product metafield. I'm hoping that there is another app that already does this or one that is close that I can repurpose.

 

If anyone has any suggestions or clues as to where I can look I would appreciate it, I've done every type of search I can think of to find this. We may be pursue the custom app route if nothing exists, but I hope we can find a preexisting app.

 

 


 

1 Like
Highlighted
Excursionist
17 0 7

Does anyone have any insight? I'd be open to a custom app if someone knew who would be best to talk to.

0 Likes
Highlighted
Shopify Partner
1840 176 690

Hello,

 

I am not aware of any app that does what you're looking for using Shopify's multi-location inventory management for store display purposes specifically.

 

And yes, you are quite right that a bespoke app would be a good fit for this requirement. A private app should be enough. One thing to beware of is that the closer you need the customer facing inventory levels to be real-time to actual inventory levels, the more complicated and resource intensive it becomes. If you're okay with customer facing inventory levels being slightly out of date (due to scheduled syncs, caching, or otherwise) then it's less of an issue.

 

Another issue to be aware of is the amount of roundtrip requests you'd ideally want to avoid when syncing inventory levels per product variant / inventory item / location / inventory level. That chain can be quite a nuisance to work with in practice and I have found it's easier to have a local copy of variant ID to inventory item ID and location ID, inventory level. Getting latest inventory levels is also quite ineffective using the REST API but the GraphQL API has the inventorybulkadjustquantityatlocation mutation which is constant cost and very cheap (good so you don't hit your API limits) plus it has this neat side effect that if you adjust with 0, it returns the current level. You'd sync your local copy in batches of 500 inventory items per location at a time based on a scheduled job. New / Removed variants (hence also inventory items) would be better detected using webhook events rather than constantly syncing the entire product / inventory catalog.

 

Your storefront would load the product detail page as usual and once loaded, you'd use JS to fetch the inventory levels from your very own API endpoint. I don't see the need to have this part done as an app proxy as it would just add latency to the page and the inventory level per location is not a primary concern and requirement of the product page so it can be loaded asynchronously.

 

All that could run on any off the mill cloud service - all of them offer serverless functions, schedulers, KV storage (or similar) etc. and depending on your stores' load, you might even fall within the free tier (Google is quite generous here though ultimately the big 3 all have their perks).

 

Hope this helps and good luck!

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Highlighted
Shopify Partner
129 7 30

You should be able to do that with our new automation app, Mr. Arigato (barring any Shopify API limitations). If you install the app, use the request help feature in the app and I can help you set this up at no charge. :) 

 

I started a prototype of the workflow you'd need, but I need to investigate something with it before it's ready to go. I'll do that tomorrow. Once we have it worked out, we'll add it to our public workflow library so that other merchants can grab the workflow as needed.

0 Likes
Highlighted
Excursionist
17 0 7

Hi John,

 

If your app can actually do this you'll get a lot of new subscribers as I've talked to so many shop owners with the same issue. We will be buying your app for sure, I'll give it a test tonight or tomorrow. I appreciate you taking the time to reply!

0 Likes
Highlighted
Shopify Partner
19 1 8

Hello,

 

We have added the workflow to Mr. Arigato. Look for the workflow titled "Set Variant Inventory Level Metafield by Location ID".

 

As inventory levels are updated across your variants a metafield value will be set on the variant that includes the inventory level by location.

The format would be {{ variant.metafields.inventory_levels["location_id_here"] }}.

 

Feel free to reach out to our support team, they are awesome at helping people accomplish specific tasks!

0 Likes
Highlighted
Shopify Partner
129 7 30

It's worth noting that we did bump into a Shopify limitation with this. There's no way to take an inventory item's ID and get the variant or product that it's attached to. Since everything hinges on reacting to the inventory updated webhook this was a challenge. To get past it, we had to add a workaround that connects the dots with SKUs instead. This means that in order for this workflow to work, your product variants must use SKUs

 

You can find the workflow in our library now at https://apps.bonify.io/mr-arigato-task-automator-for-shopify

 

0 Likes
Highlighted
Excursionist
17 0 7

Hi John,

 

I don't fully understand the issue. I have the app up and running now and I see that it's updated a few metafields but I'm having trouble finding them using my metafields app (metafields2). I will do some more digging, hopefully I can make this work!

0 Likes
Shopify Partner
129 7 30

I've spent a good bit of time setting up a complete working example. I'll provide all the setup instructions and code. This builds a system that listens for changes to inventory quantities and syncs a metafield on each variant, for each location's inventory. The inventory quantities get stored dynamically for each of your locations, in a metafield with a namespace of "inventory_levels" and a key of the location's Shopify ID. More on that later, but that's where we're going.

 

You can customize the liquid code to suit your situation, including showing and hiding this info based on the active variant.

 

Here's a screenshot of what my setup will get you out of the box. 

 

Screenshot 2019-03-15 11.27.39.pngRequirements for this setup

  1. Metafield app that can handle product variants and shop variables. Since we built Custom Fields, I'll use that. A metafield app isn't strictly required, but it helps in setup and testing.
  2. Automation app that can update product variants when inventory quantities are updated. Since we built Mr. Arigato, we'll use that.
  3. SKUs on all product variants you want to use this with.
  4. Theme access to update your product template.
  5. Patience. ;)

Setting Up the Automation

In Mr. Arigato, start with the "Set Variant Inventory Level Metafield by Location ID (SKU required)" workflow library item.

 

Screenshot 2019-03-15 11.33.58.png

 

Once imported into your workflows, it will look like this.

 

Screenshot 2019-03-15 00.20.20.png

 

You can change the metafield setup if you want, but it will work without any changes. Don't forget to enable the workflow so it starts listening for events!

 

Screenshot 2019-03-15 00.20.36.png

 

That's it for Mr. Arigato setup. Jump into the "View Stats" section to watch for your events. These will trigger shortly after you change quantities in Shopify. Keep this window open for debugging.

 

Screenshot 2019-03-15 15.24.16.png

 

Change some data in Shopify to fire the automation

On to testing! On your product variant in Shopify, make some changes to your available quantities. Within a minute you should see Mr. Arigato update with your changes. At this point, you now have data set on that product variant's metafields. On to the liquid code!

 

Screenshot 2019-03-15 00.26.02.png

 

The Code

Copy this gist as a snippet with the name of locations.liquid. Save it in your theme.

 

Screenshot 2019-03-15 15.27.25.png

 

Now call the snippet from your product template of choice, I'd insert it under product.description as a good starting place. No customizations needed, that's it for the code. Now all we need to do is set up a shop variable to track your location information since it's not globally available in liquid for some reason. We'll also want to check that data is being set on our variants. On to the metafield app.

 

Screenshot 2019-03-15 15.30.37.png

 

The Metafield App

In Custom Fields, you'll need "Other Metafields" enabled, since these fields aren't managed by Custom Fields. These settings are under "Settings" in the app. They are off by default.

Screenshot 2019-03-15 00.17.16.png

 

Now go to your product in Custom Fields, navigate to the variants section for that product and notice the variant has data for each of the inventory locations, keyed off of the inventory location. No changes needed, we're just checking that we have values. Time to connect the dots with a shop variable for the location information.

 

Screenshot 2019-03-15 00.08.52.png

 

In Custom Fields, set up a Global text field called "Locations".

 

Screenshot 2019-03-15 15.38.52.png

 

Now set the value of the field. The format is location_id=human name with a pipe separating each location. No spaces. To get the IDs of your locations, refer to the keys in the screenshot above when we checked the variant for data. The order you enter the locations in this box is the order they'll be printed. If you have locations you don't want shown on the site, just omit them here. 

Screenshot 2019-03-15 15.40.23.png

That's it!

Go check out your test product and bask in your glory!

 

If it didn't work, remember... you must have SKUs set for this to work. Also, updates with Mr. Arigato are not instant. Check the stats in Mr. Arigato for errors and check your variant in Custom Fields for data. Keep in mind, no data will be set on the product itself, only on the variant. Finally, each product variant needs to be triggered with an inventory update in order for the data to populate. At first, only your test product will have data displayed. As you sell and restock items or change quantities, the data will be set for more and more products.

Screenshot 2019-03-15 11.27.39.png

 

 

1 Like