How can I accurately display stock quantity for product variants using JS?

How can I accurately display stock quantity for product variants using JS?

MarcoAP
Excursionist
36 0 9

Hello,

I have a little problem with our product page. Use the prestige theme.

It's about the correct display of stock for articles with variants. If I click on another variant, the quantity that is displayed does not change. This has to be read with JS, I already know that so far. I just don't understand how to do it yet.

I let the stock amount be spent as follows

<div class="inventoryWrapper">
<p>Only {{ product.selected_or_first_available_variant.inventory_quantity }} pieces available</p>
</div>

How would I best program this, hope you can help me.

greeting
Marco

Reply 1 (1)

nidhipatel
Pathfinder
89 20 24

Hi @MarcoAP 

 

I have checked the prestige theme and found that in the prestige theme by default the inventory code is working properly on variant change.

 

Also, make sure that you have set the inventory threshold to 0 as shown in the given video. If it's set to zero and then also you are facing the issue then I guess you have messed up the code so it is not working in your theme.

 

I have understood your concern. Please send me your store Url so I can check and let you know why it's happening. Also, if everything is perfect from the URL then for giving you a better solution I need to check your theme’s javascript code.

 

Please check attached video for a prestige theme inventory work.

 

 

If our answer is helpful then please feel free to Like and Accept it as solution!
Hire our Shopify Developers for all your small & big needs:
New Store Development | Custom Theme Development | Site Speed Optimization
Email: hello@mintyourstore.com | Instagram: @mintyourstore