New Shopify Certification now available: Liquid Storefronts for Theme Developers

Stock count on Dawn theme

Solved
ariathelabel
Tourist
12 0 2

Hi, I am using the Dawn Theme and I would like to be able to add "SELLING FAST" or "LOW IN STOCK" to some of my products. Does anyone know how I can do this please - tried lots of different ways already!

 

Thank you!!!

Accepted Solution (1)
shadowsfall118
Shopify Partner
125 13 28

This is an accepted solution.

@ariathelabel If you want to choose where exactly its shown you will need to go into code editor. Click online store > Actions (to the right of page) > edit code. Then search for main-product.liquid.

 

Look for this code:

Screen Shot 2022-09-08 at 2.05.14 PM.png

Then add the following code before (when) or after (endif).

{%- if product.selected_or_first_available_variant.inventory_quantity == 0 -%}
    <p>COMMING SOON</p>
    {%- elsif product.selected_or_first_available_variant.inventory_quantity < 25 -%}
    <p>LOW IN STOCK</p>
     {%- elsif product.selected_or_first_available_variant.inventory_quantity > 90 -%}
    <p>SELLING FAST</p>
{%- endif -%}

 

View solution in original post

Replies 15 (15)
shadowsfall118
Shopify Partner
125 13 28

@ariathelabel If on the product page, use below. Please note this will not update on variant chnage.

 

{%- if product.selected_or_first_available_variant.inventory_quantity > 90 -%}
    <p>SELLING FAST</p>
    {%- elsif product.selected_or_first_available_variant.inventory_quantity < 25 -%}
    <p>LOW IN STOCK</p>
{%- endif -%}

 

To show or see the stock level, use:

{{  product.selected_or_first_available_variant.inventory_quantity }}
ariathelabel
Tourist
12 0 2

Thank you!!

But nothing is showing when I add that into a custom liquid box?

shadowsfall118
Shopify Partner
125 13 28

@ariathelabel I just tried on my dawn theme in a custom block and it works. Make sure your stock level for that product is either below 25 or above 90 or it won't show. Otherwise change the values in the code to match your desired needs.

ariathelabel
Tourist
12 0 2

Got it, thank you!!

ariathelabel
Tourist
12 0 2

I have one product that is currently out of stock completely - is there a way to add a third clause to say if the stock count is 0 then show "COMING SOON" ? Thank you so much for your help!

shadowsfall118
Shopify Partner
125 13 28

This is an accepted solution.

@ariathelabel If you want to choose where exactly its shown you will need to go into code editor. Click online store > Actions (to the right of page) > edit code. Then search for main-product.liquid.

 

Look for this code:

Screen Shot 2022-09-08 at 2.05.14 PM.png

Then add the following code before (when) or after (endif).

{%- if product.selected_or_first_available_variant.inventory_quantity == 0 -%}
    <p>COMMING SOON</p>
    {%- elsif product.selected_or_first_available_variant.inventory_quantity < 25 -%}
    <p>LOW IN STOCK</p>
     {%- elsif product.selected_or_first_available_variant.inventory_quantity > 90 -%}
    <p>SELLING FAST</p>
{%- endif -%}

 

ariathelabel
Tourist
12 0 2

Amazing, got it!! Thanks so much!!

shadowsfall118
Shopify Partner
125 13 28

@ariathelabel no problem! Please like and mark as solution!

rm014
Shopify Partner
34 0 1

Hi @shadowsfall118, how about if you also want to show the stock count on variant change? 

shadowsfall118
Shopify Partner
125 13 28
shadowsfall118
Shopify Partner
125 13 28
rm014
Shopify Partner
34 0 1

@shadowsfall118, tried to follow those but still not working, not sure why. Thanks though for helping. 

shadowsfall118
Shopify Partner
125 13 28

@rm014 I followed this guide (https://parasoul.ltd.uk/shopify/dawn-theme-display-inventory-quantity) on a raw dawn theme and it does work. If you follow this guide do you get it to say "We have more than 10 in stock" if the stock is above 10?

 

If not you have some modifications that are not allowing the code to execute properly or you missed something in the guide.

 

If you do see "We have more than 10 in stock" and you would like it to say something different ex. total amount in stock or "Selling Fast" like the original request, let me know.

rm014
Shopify Partner
34 0 1

all good now @shadowsfall118, works like a charm. found the issue and it's working well now. Thank you so much for your help

Zel_
Shopify Partner
21 0 1

Hey 👋

 

Custom low stock message (with or without stock value) can be added  to product page via HeyMerch low stock app. No code is requried. It works based on variant, can be selected to display for custom product or custom collection.