Dawn Theme Help Needed - Show Inventory Quantities with Variants

New Member
2 0 0


I'm currently working on building a new Shopify site, and I'm looking for some help with the code needed to show inventory quantities with variants with the Dawn theme. I found this article, and have been able to add the first part of the code on the main-product.liquid template. Show Inventory quantities on product pages



<div id="variant-inventory">
{% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity > 0 %}
We currently have {{ product.variants.first.inventory_quantity }} in stock.
{% endif %}



However, this only shows the quantity for the 1st variant, and does not change when a different variant is selected. Or if the 1st variant has 0 in stock, the "we currently have in stock" disappears completely. 

The article I referenced above says Most Shopify themes will already have the selectCallback function. It is usually located towards the bottom of the theme.liquid file, or at the bottom of the product.liquid file. Look for this piece of code: 


var selectCallback = function(variant, selector) {



I cannot locate this code in the theme.liquid file. The article references to follow this https://shopify.dev/themes/product-merchandising/variants but I'm really unsure of where to add any of that code to get this to work. 

Would someone be able to explain in detail, what code I need to add and to which templates in the Dawn theme to get the quantities to change based on the variant selected? 

Thank you in advance!

Replies 2 (2)
Shopify Partner
3404 224 651

updateVariantInput called from onVariantChange dispatches a change event  



selectCallback is meant for themes using shopifys  js lib option_selection.js 

Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
New Member
2 0 0

Thanks, but I'm not quite sure what to do with this information.

I've been searching the forums for the code needed to make this work. But cannot find the exact code and where to put it to make the quantity change with the variations. There are many solutions for this, however, none of them work with the Dawn theme as described. 

Can someone please provide the code and what templates to put it on to make this work?