Last active
November 13, 2017 15:17
Star
You must be signed in to star a gist
Replacement for {{ product | json }} with accurate inventory information removed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %}## Add this snippet, then replace {{ product | json }} with {% include 'product-json' %} ##{% endcomment %} | |
{% capture product_json %}{{ product | json }}{% endcapture %} | |
{% assign product_json_split = product_json | split: '"inventory_quantity":' %} | |
{%- for str in product_json_split -%} | |
{%- if forloop.first -%}{{ str }} | |
{%- else -%} | |
"inventory_quantity": | |
{%- assign str_split = str | split: ',' -%} | |
{%- for str2 in str_split -%} | |
{%- unless forloop.first -%},{%- endunless -%} | |
{%- if forloop.first -%} | |
{%- assign str2_int = str2 | plus: 0 -%} | |
{%- if str2_int > 0 -%}999999{% elsif str2_int < 0 %}-1{% else %}{{ str2 }}{%- endif -%} | |
{%- else -%} | |
{{- str2 -}} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endif -%} | |
{%- endfor -%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment