How can I customize inventory status sales point?

Hi,

I want to customize “inventory status” sales point in my product page. I’m using “Expanse” Theme and it would be great if I can customize it as like below :

  1. Inventory status doesn’t show up if product quantity is over 3.

  2. If product quantity is less than 3, Inventory status show up with text “less stock” in Yellow.

  3. If product quantity only left one, Inventory status show up with text “Last One” in Red.

I’ve tried modify the code but I’m not sure which part has to be changed. Below is my theme’s product-inventory. liquid.

Could someone please help me with this?

{%- assign inventory_visible = false -%}
{%- if current_variant.inventory_management == ‘shopify’ -%}
{%- if current_variant.inventory_quantity <= block.settings.inventory_threshold and current_variant.inventory_quantity >= 0 -%}
{%- assign inventory_visible = true -%}
{%- endif -%}
{%- endif -%}

{%- liquid
if current_variant.inventory_quantity >= 3 or current_variant.inventory_policy == ‘continue’
assign inventory_visible = false
endif

assign show_incoming = false
if current_variant.incoming and inventory_visible == false and current_variant.inventory_quantity <= block.settings.inventory_threshold
assign show_incoming = true
endif
-%}

  • {%- if inventory_visible -%} {{ 'products.product.stock_label' | t: count: current_variant.inventory_quantity }} {%- else -%} {{ 'products.product.in_stock_label' | t }} {%- endif -%}
  • {%- if block.settings.inventory_transfers_enable -%}
  • {%- if current_variant.next_incoming_date -%} {%- assign date = current_variant.next_incoming_date | date: format: 'date' -%} {%- if current_variant.available -%} {{ 'products.product.will_not_ship_until' | t: date: date }} {%- else -%} {{ 'products.product.will_be_in_stock_after' | t: date: date }} {%- endif -%} {%- else -%} {{ 'products.product.waiting_for_stock' | t }} {%- endif -%}
  • {%- endif -%}

{%- assign variants_with_inventory_tracking = product.variants | where: ‘inventory_management’, ‘shopify’ -%}

{% comment %}
If loaded in quick view, it might be from a JS-loaded function
that loads recommended products. If that’s the case, the above
JS will not set the variant inventory. Add it to an accessible
data div to read later instead.
{% endcomment %}

{%- for variant in variants_with_inventory_tracking -%}
{%- endfor -%}
1 Like

Can you share the store URL?

You will need multiple code changes to make this happen, on variant change the quantity will also update so the code should update accordingly.

hi there, are you able to get an answer? Looking into this as well! Thanks!

1 Like