I am looking to display if the current product is in stock or not. I have seen some for have had it so it displays the number of products, I am however just trying to display whether it is in stock or not.
I am using the Dawn theme.
Thank you
I am looking to display if the current product is in stock or not. I have seen some for have had it so it displays the number of products, I am however just trying to display whether it is in stock or not.
I am using the Dawn theme.
Thank you
Hi @darkthrone ,
You can use the code below to show when In stock or Out of Stock. However, if you have multiple variants, this doesnāt update until your refresh the page. You have to have a custom script to update this.
If you have no variant, you can use the custom block to edit the theme. Please follow the instructions below.
From you Admin page, go to Online store > Themes > Customize
Go to your product page, and click āAdd blockā, click āCustom blockā
Please the code below in the textbox.
{% if product.selected_or_first_available_variant.available %} In Stock {% else %} Out of stock {% endif %}
Great, it works! Now, Iāve seen some websites that have this feature and the āIn Stockā sign is green and has a green circle next to it - sometimes flashing, to show Live Stock. Do you know how I can add this feature or change the colour? Say Green for In Stock and Red for out?
Thank you
Hi, following my previous message, after some trial and error I managed to make this work with the help of Chat GPT.
By adding a Custom Liquid box onto the Product Page Default Template, I can now see the In Stock indicator flashing green to kind of show Live Stock status with following code;
.stock-indicator .live-indicator { color: #9DA9A0; /* Green shade for the text */ font-weight: bold; } .stock-indicator .out-of-stock-indicator { color: red; font-weight: bold; } .stock-indicator .live-indicator::before { content: 'ā'; /* Solid circle */ color: #9DA9A0; /* Same green shade for the circle */ font-size: 18px; /* Adjust size as needed */ margin-right: 5px; /* Space between the circle and text */ animation: blink-animation 1s steps(5, start) infinite; } @keyframes blink-animation { 50% { opacity: 0; } }Hope this helps someone else!
Thanks
Jordan
Hi Jordan - did you add this code at the bottom of main-product.liquid?