Stock shown on product page for different variants

Hello, I have the dawn theme.

I want stock to be shown on product page, but when i have product with different variants it shows stock only for the first variant, no matter which variant I choose. I went to online store edit, products, default products and I put custom liquid with this code ( I also want the text for under 10 products in stock to be red, and for more than 10 to be green). Can anybody help me with that?

{% assign current_variant = product.selected_or_first_available_variant %}
 
 {% if current_variant.available %}
 
 {% if current_variant.inventory_quantity > 0 and current_variant.inventory_quantity <= 10 %}Na zalogi samo še {{ current_variant.inventory_quantity }} kosov

{% else %}

{% elsif current_variant.inventory_quantity > 10 %}Več kot 10 kosov na zalogi

 {% endif %}
 {% endif %}

1 Like

Hi @Lazun27 ,

The liquid code alone is not enough, you have a to add a javascript code to listen to user’s input. Unfortunately, you have to hire a developer to go in your theme and read the code then add the javascript for you.