Hi guys I hope you can help me!
We're using the warehouse theme by maestroo, and with this comes various tags depending on how many items are in stock of a product.
I'm repurposing this to show other messages (such as discontinued, coming soon, pre-order etc).
The one thing I'm struggling with, is that we have 2 items on pre-order (meaning there are 5 in stock, but not actually in stock).
Our system will then show the 'low stock' warning, which isn't the case.
I'd like it to show 'pre-order' but not 'low stock'.
To summarise, when an item contains tag 'PRE-ORDER', remove stock indication messages.
Code below to show what we're working with, on both collection AND product levels.
COLLECTION LEVEL CODE:
{% for tag in product.tags %}
{% unless tag contains 'PRE-ORDER' %}
{% else %}
<span class="product-item__inventory inventory inventory--high">PRE-ORDER</span>
{% endunless %}
{%- endfor -%}
{%- if all_inventory <= settings.low_inventory_threshold -%} (THIS LINE HERE DRIVES THE "IF STOCK LESS THAN 5, SHOW LOW STOCK MESSAGE)
<span class="product-item__inventory inventory inventory--low">LOW STOCK</span>
{%- else -%}
<span class="product-item__inventory inventory inventory--high">AVAILABLE TO ORDER</span> (THIS LINE HERE DRIVES THE "IF STOCK MORE THAN 5, SHOW IN STOCK MESSAGE)
{%- endif -%}
{%- else -%}
<span class="product-item__inventory inventory inventory--high">AVAILABLE TO ORDER</span>(THIS LINE HERE DRIVES THE "IF STOCK MORE THAN 5, SHOW IN STOCK MESSAGE)
{%- endif -%}
{% else %}
{% for tag in product.tags %}
{% if tag contains 'COMING SOON' %}
<span class="product-item__inventory inventory inventory--low">COMING SOON</span>
{% endif %}
{%- endfor -%}
{% for tag in product.tags %}
{% if tag contains 'NIS' %}
<span class="product-item__inventory inventory">OUT OF STOCK</span>
{% endif %}
{%- endfor -%}
{% else %}
{%- endif -%}
{%- endif -%}
PRODUCT LEVEL CODE:
{% for tag in product.tags %}
{% if tag contains 'PREORDER' %}
<span class="product-form__inventory inventory inventory--low">PRE ORDER NOW</span>
{% endif %}
{%- endfor -%}
<span class="product-form__inventory inventory inventory--low">LOW STOCK</span> (THIS LINE HERE DRIVES THE "IF STOCK LESS THAN 5, SHOW LOW STOCK MESSAGE)
{%- else -%}
<span class="product-form__inventory inventory inventory--high">AVAILABLE TO ORDER</span>(THIS LINE HERE DRIVES THE "IF STOCK MORE THAN 5, SHOW IN STOCK MESSAGE)
{%- endif -%}
{%- else -%}
<span class="product-form__inventory inventory inventory--high">AVAILABLE TO ORDER</span>(THIS LINE HERE DRIVES THE "IF STOCK MORE THAN 5, SHOW IN STOCK MESSAGE)
{%- endif -%}
{% else %}
{% for tag in product.tags %}
{% if tag contains 'COMING SOON' %}
<span class="product-item__inventory inventory">COMING SOON</span>
{% endif %}
{%- endfor -%}
{% for tag in product.tags %}
{% if tag contains 'PREORDER' %}
<span class="product-item__inventory inventory">PRE ORDER NOW</span>
{% endif %}
{%- endfor -%}
{% for tag in product.tags %}
{% if tag contains 'NIS' %}
<span class="product-item__inventory inventory">OUT OF STOCK</span>
{% endif %}
{%- endfor -%}
{% for tag in product.tags %}
{% if tag contains 'DISCONTINUED' %}
<span class="product-item__inventory inventory">DISCONTINUED</span>
{% endif %}
{%- endfor -%}
{% endif %}
{% if product.tags contains 'PRE-ORDER' %}
{%- if all_inventory <= settings.low_inventory_threshold -%}
<span class="product-item__inventory inventory inventory--low">PRE-ORDER NOW</span>
{% else %}
{%- if all_inventory <= settings.low_inventory_threshold -%}
<span class="product-item__inventory inventory inventory--low">LOW STOCK</span>
{% endif %}
I assume you mean the above? if they have the preorder tag show pre-order instead of low stock. If it doesn't have pre-order tag, then show low stock.
You probably have to change the if statement. The above is just a quick thought.
Just change the red tag to say whatever you want.
I had a feeling I hadn't worded it right to be honest, sorry.
I'd like the PRE ORDER message to replace the low stock warning message when apparent.
At the present moment, it will add as many messages as are tagged - for instance if the item was tagged with NIS, PRE-ORDER and Discontinued, all 3 messages will be shown.
Obviously that's not what we're doing, but I'm stating how the theme works.
Again, to summarise, I'd like a 'when pre-order tag is present, replace low stock message'
It's because you have them in 2 separate statements, reading your code
Your saying, in a for loop, if the preorder tag is applied to the product, then show pre-order, but then you are saying in the next code about inventory, show low stock.
#1 if you dont want that line at all then get rid of it
#2 if you do want ti but just not on preorders then add more values to your statements and combine statements
if tags contain preorder AND all_inventory <= settings.low_inventory_threshold
show preorder
elseif all_inventory <= settings.low_inventory_threshold
show low stock.
{% for tag in product.tags %}
{% unless tag contains 'PRE-ORDER' %}
{% else %}
<span class="product-item__inventory inventory inventory--high">PRE-ORDER</span>
{% endunless %}
{%- endfor -%}
{%- if all_inventory <= settings.low_inventory_threshold -%} (THIS LINE HERE DRIVES THE "IF STOCK LESS THAN 5, SHOW LOW STOCK MESSAGE)
<span class="product-item__inventory inventory inventory--low">LOW STOCK</span>
User | Count |
---|---|
784 | |
142 | |
93 | |
63 | |
59 |