Shopify themes, liquid, logos, and UX
I currently have this code on my products -
{% if product.selected_or_first_available_variant.inventory_quantity < 3 %}
<p style="color: black"> {{ product.selected_or_first_available_variant.inventory_quantity }} left in stock</p>
{% endif %}
But it only shows the correct variant quantity when you refresh the page. Is it possible to show the correct product quantity when selected? See the image where it shows the 'ruled' variant is out of stock, but the Graph has 2 left, and when you click back on ruled, it still shows '2 left in stock'. I have noticed a few customers clicking through the variants and leaving the site.
I tried tweaking it myself but out of my depth. I am using the Dawn theme.
thanks!
Please try this code
{% if product.selected_variant.inventory_quantity < 3 %}
<p style="color: black">
{{ product.selected_variant.inventory_quantity }} left in stock
</p>
{% endif %}
Thanks!
Hi.
Thank you so much for your help.
Unfortunately, this didn't work. It doesn't show the quantity.
Hey @izzy365
Try to replace your code with the code mentioned below and check if this works for you
{% if product.selected_variant.inventory_quantity < 3 %}
<p style="color: black">
{{ product.selected_variant.inventory_quantity }} left in stock
</p>
{% endif %}
If I managed to help you then, don't forget to Like it and Mark it as Solution!
Best Regards,
Moeed
Hi.
Thank you so much for your help.
Unfortunately, this didn't work. It doesn't show any text on the product now.
It doesn't seem to recognise "product.selected_variant.inventory_quantity"
Update, I edited the code so that it only shows up with stock quantities on products that do not have variants. If anyone ever solves this please let me know.
Hello, if you are okay with using 3rd party app for this use case, you can check this application. It directly shows the left in stock in variant level.
We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024