How can I get the inventory qty only for one location?

How can I get the inventory qty only for one location?

yoonlaser
Shopify Partner
30 0 4

Hello,

I'm showing an available qty on my product page. We have 'buy with prime' items connected to our store. So when I use this variable 'variant.inventory_quantity', it shows the total inventory qty of both our warehouse and FBA items. Is there any way that I can only show the inventory level of our location?

F.Y.I. the code I put into my theme's custom liquid section is,

{% assign totalProductsQuantity = 0 %}

{% for variant in product.variants %}
{% assign totalProductsQuantity = totalProductsQuantity | plus: variant.inventory_quantity %}
{% endfor %}

{% unless product.tags contains 'bwp' %}
{% if product.has_only_default_variant %}
{% if totalProductsQuantity > 0 %}
<p class="pion-qty">{{ totalProductsQuantity }} In Stock</p>
{% endif %}
{% endif %}
{% endunless %}

Thank you!



Reply 1 (1)

PaulNewton
Shopify Partner
7032 629 1481

No , currently liquid only gives an aggregate.

You would need an app to populate metafields with that data  mechanic has a starting point task

https://tasks.mechanic.dev/sync-inventory-levels-to-variant-metafields  , though this may also be possible with shopify flow.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org