I have products setup with a low_stock tag, made visible as ‘Low stock’ on website pages, similar style to how it says ‘Sold out’ when inventory tracker is set to 0. See here https://pullmaneditions.com/collections/all-posters
I want an option to also have ‘Very low stock’ appear, but when I do a very_low_stock_tag it just appears as ‘Low stock’. I’ve realised this is because in my Snippets/product-price.liquid file I have the below code:
{% for tag in product.tags %}{% if tag contains ‘low_stock’ %} price–low-stock {% endif %}{% endfor %}"
I know that “contains” needs to be swapped to "==" so it gives “Low stock” and then a new statement is needed specific for very_low_stock so that each line is specific to each tag. When I have tried doing this it doesn’t seem to change.
Please can someone help - have been stuck for ages!
Hi @pullmaneditions ,
I have modified your code to work for “very_low_stock”. This code will trigger correctly for both “very_low_stock” and “low_stock”.
{% for tag in product.tags %}
{% if tag contains 'very_low_stock' %}
price-very-low-stock
{% elsif tag contains 'low_stock'%}
price--low-stock
{% endif %}
{% endfor %}
If you require further help to implement this code on your site, feel free to contact me.
Thank you
Thank you for this! It still doesn’t seem to be working. I have pasted the code you altered. I will paste below the code I have now got on this Snippet…
{% comment %}
Renders a list of product’s price (regular, sale, unit)
Accompanies product forms and meant to be updated dynamically
Accepts:
- variant: {Object} Variant Liquid object (optional)
- product: {Object} Product Liquid object (optional)
Usage:
{% include ‘product-price’, variant: current_variant, product: product %}
{% endcomment %}
{%- liquid
if variant.title
assign compare_at_price = variant.compare_at_price
assign price = variant.price
assign available = variant.available
else
assign compare_at_price = 1999
assign price = 1999
assign available = true
endif
assign money_price = price | money
-%}
{%- comment -%}
Explanation of description list:
- div.price__regular: Displayed when there are no variants on sale
- div.price__sale: Displayed when a variant is a sale
- div.price__unit: Displayed when the first variant has a unit price
- div.price__availability: Displayed when the product is sold out
- div.price__low: Displayed when the product is low availability
{%- endcomment -%}
-
{{ 'products.general.regular_price' | t }}
-
{{ money_price }}
-
{{ 'products.general.sale_price' | t }}
-
{{ money_price }}
-
{{ 'products.general.regular_price' | t }}
-
{{ compare_at_price | money }}
{{ 'products.general.sale' | t }}
{{ 'products.product.sold_out' | t }}
{{ 'products.general.low_stock' | t }}
{%- if cart.taxes_included or shop.shipping_policy.body != blank -%}
{%- if cart.taxes_included -%}
{{ 'products.product.include_taxes' | t }}
{%- endif -%}
{%- endif -%}
-
{{ 'products.product.unit_price_label' | t }}
-
{%- capture unit_price_separator -%}
/{{ 'general.accessibility.unit_price_separator' | t }}
{%- endcapture -%}
{%- capture unit_price_base_unit -%}
{%- if variant.unit_price_measurement -%}
{%- if variant.unit_price_measurement.reference_value != 1 -%}
{{- variant.unit_price_measurement.reference_value -}}
{%- endif -%}
{{ variant.unit_price_measurement.reference_unit }}
{%- endif -%}
{%- endcapture -%}
{{ variant.unit_price | money }}{{- unit_price_separator -}}{{- unit_price_base_unit -}}
Hi @pullmaneditions ,
I reviewd the code snippet you provided but i cannot help and provide information based on this single file. In this code snippet, you are just adding a class. I do not see a code for Low Stock Tag.
To add this feature, I will have to look into the theme and other files that render the tag.