Hi
I my site sells bathroom/kitchen tiles so we like to display quantity on the site as m2 (square metres) as oppose to total quantity of tiles so is more meaning full.
we have been using the empire theme for a while and now the recent update includes its own stock level snippet which displays total quantity not just on the product page but also on home page featured collections and products as well as collection pages so customers can see before clicking on a product what the current quantity is.
I have tried to update the code for the updated theme based on my current site so that it too displays m2 amount instead of quantity but the code isn’t working.
my current code is
{{ product.variants.first.inventory_quantity | divided_by:product.metafields.cal.sqm.value | round }} m2
this only displays on a product page
looking at the new snippet they have a list of liquid rules which starts with
{% liquid
assign stock_level = ‘’
assign inventory_quantity = variant.inventory_quantity
I was hoping it would just be a matter of updating the variant.inventory_quantity to my original code of {{ product.variants.first.inventory_quantity | divided_by:product.metafields.cal.sqm.value | round }} m2 but this is not working for myself.
does anyone know what the correct code would be to update variant.inventory_quantity to my m2 quantity.
thanks
below is the rest of the code as I maybe looking in the wrong places
{% comment %}
@Anonymous attr {String}
Stock level attributes
@Anonymous inventory_display {String}
How the inventory quantity is displayed
@Anonymous inventory_transfer {Boolean}
If true, show the inventory transfer notice
@Anonymous variant {Object}
The product variant
@Anonymous verbose {Boolean}
If true, show additional text/elements
{% endcomment %}
{% liquid
assign stock_level = ‘’
assign inventory_quantity = variant.inventory_quantity
if variant.inventory_policy == ‘continue’
if inventory_quantity <= 0 and variant.product.template_suffix contains ‘pre-order’
assign stock_level = ‘pre-order’
else
assign stock_level = ‘continue-selling’
endif
elsif inventory_quantity > settings.low_stock_threshold
assign stock_level = ‘high’
elsif inventory_quantity > 0 and inventory_quantity <= settings.low_stock_threshold
assign stock_level = ‘low’
elsif inventory_quantity <= 0
assign stock_level = ‘none’
endif
if inventory_display == ‘hidden’
assign inventory_quantity = ‘’
elsif inventory_display == ‘low_stock_only’ and stock_level == ‘high’
assign inventory_quantity = ‘’
elsif inventory_display == ‘low_stock_threshold’ and stock_level == ‘high’
assign inventory_quantity = settings.low_stock_threshold
else
assign inventory_quantity = inventory_quantity
endif
%}
{% capture stock_badge_classes %}
product-stock-level
product-stock-level–{{ stock_level }}
{% if variant.incoming and inventory_transfer %}
product-stock-level–incoming
{% endif %}
{% endcapture %}
{% capture stock_badge_text %}
{% if stock_level == ‘pre-order’ %}
{{ ‘product.status.pre_order’ | t }}
{% elsif stock_level == ‘continue-selling’ %}
{{ ‘product.status.continue_selling’ | t }}
{% elsif stock_level == ‘high’ %}
{% if inventory_display == ‘low_stock_threshold’ %}
{% if verbose %}
{{ ‘product.status.in_stock_threshold_verbose’ | t: inventory_quantity: inventory_quantity }}
{% else %}
{{ ‘product.status.in_stock_threshold’ | t: inventory_quantity: inventory_quantity }}
{% endif %}
{% elsif verbose %}
{{ ‘product.status.in_stock_verbose’ | t: inventory_quantity: inventory_quantity }}
{% else %}
{% if inventory_display == ‘hidden’ %}
{{ ‘product.status.in_stock_hidden’ | t }}
{% else %}
{{ ‘product.status.in_stock’ | t: inventory_quantity: inventory_quantity }}
{% endif %}
{% endif %}
{% elsif stock_level == ‘low’ %}
{% if inventory_display == ‘hidden’ %}
{{ ‘product.status.low_stock_hidden’ | t }}
{% else %}
{{ ‘product.status.low_stock’ | t: inventory_quantity: inventory_quantity }}
{% endif %}
{% elsif stock_level == ‘none’ %}
{% if variant.incoming and inventory_transfer %}
{{ ‘product.status.incoming_stock’ | t: inventory_quantity: inventory_quantity }}
{% else %}
{{ ‘product.status.no_stock’ | t: inventory_quantity: inventory_quantity }}
{% endif %}
{% endif %}
{% endcapture %}