Skip to content

Instantly share code, notes, and snippets.

@carbone
Last active Mar 15, 2019
Embed
What would you like to do?
Use in combination with Mr. Arigato https://apps.shopify.com/mr-arigato-task-automator to show stock by location in a Shopify theme. See also: https://apps.bonify.io/mr-arigato-task-automator-for-shopify "Set Variant Inventory Level Metafield by Location ID (SKU required)"
{% assign loc = shop.metafields.custom_fields["locations"] | split: "|" %}
{% if loc != blank %}
<h3>Available at the following locations</h3>
<table>
{% for info in loc %}
{% assign table_item = info | split: '='%}
{% assign location_id = table_item[0] %}
{% assign location_name = table_item[1] %}
<td colspan="2"><strong>{{ location_name }}</strong></td>
{% for variant in product.variants %}
{% if variant.metafields.inventory_levels[location_id] != blank %}
<tr>
<td>{{variant.title}}</td>
<td>{{ variant.metafields.inventory_levels[location_id] }} in stock</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</table>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment