Skip to content

Instantly share code, notes, and snippets.

@carbone
Last active March 15, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbone/70167921a16fd6238832730c37e26816 to your computer and use it in GitHub Desktop.
Save carbone/70167921a16fd6238832730c37e26816 to your computer and use it in GitHub Desktop.
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