How can I display variant-specific quantities on a product page?

How can I display variant-specific quantities on a product page?

Kamraan
Shopify Partner
8 0 0

Hi,
I am using the below code

 

<strong>{{ product_qty }}</strong> units left in stock.</p> </div>

 

for showing quantities of a product on the product page but this is when a variant gets selected i want to display the variants quantity for that I also have the code

<div class="inventoryWrapper">
  {% if current_variant.inventory_quantity > 0 and current_variant.inventory_management == 'shopify' %}
    <p>Stock: {{ current_variant.inventory_quantity }}</p>
  {% endif %}
</div> 

 Now I want that if someone opens my product then the total first code will run which will show the total quantity and if then someone selects any variant then it will run the second code But in this case, I want to hide the total quantity ( first code ).
I am open to any suggestions please let me know.

Thanks

Replies 0 (0)