Dawn 2.0 - Adding quantity available to product page

VividFrameworks
New Member
2 0 0

I feel like this really shouldn't be that difficult. Would anybody have the code that I need to copy and paste into the product page template?

Replies 11 (11)
PaulNewton
Shopify Partner
3407 224 655

Merchants that need to buy this customization can contact me at paull.newton+shopifyforums@gmail.com 

Different approaches :

  • Shopify has a tutorial for a few themes, they will install it as well for some themes:
  • There are also various solutions for implementing 'available inventory' throughout the forums found with search.
    • Though the complication will be updating the available amount when the variant changes.
  • A rough non-updating solution is to make a metafield definition then just add a text block and wire it to that metafield definition as a dynamic source, note this is a number you have to manually update.

 

 

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
BeholdGames
Tourist
3 0 2

I've tried using the same code I used in the old shoplify themes but its not working and only showing me the "this product is available"

So I am also keen for the solution.

 

{% comment %} Inventory tracking on product page {% endcomment %}
<div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}">
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
We have {{ current_variant.inventory_quantity }} in stock.
{% else %}
This product is available.
{% endif %}
</div>

BeholdGames
Tourist
3 0 2

Ok ii found this code and it seems to work for me.

 

<DIV>{% 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 %}</DIV>

jmp
Excursionist
19 2 29

Thank you! Exactly what I was looking for.

mstav2u
Excursionist
17 0 1

This goes in the product template then?  Does it matter where exactly?  Thanks.

BeholdGames
Tourist
3 0 2

Screen Shot 2021-10-26 at 3.36.56 pm.png


On the products page, in the GUI editor I added a code snippet and added it in there and then moved it around until I like where it displayed. 

Screen Shot 2021-10-26 at 3.37.43 pm.png

mstav2u
Excursionist
17 0 1

Thank you for the information.  I guess what I'm looking for is actually where the quantity selector stops at the amount left in stock.  Right now it goes on for infinity and then if you click add to cart, it is then that it tells you, you can't add that many.  It may not seem like a big deal, but customers may not notice the amount that's left in stock, even though it's right there.  Maybe since the quantity left is showing, that's all a seller can do with the Shopify themes?  I would like the quantity selector to stop where the stock quantity is.  In other words, 10 left in stock, so when a customer goes to order they click up to 10 and the quantity selector stops at 10 and won't go higher.  I have a large variety of variants, so just wondering about this. 

Diashop
Tourist
9 0 3

I used the code posted above in a snippet and it works for the first variant only. If a different variant is selected the text does not change. 

Any idea on how this can be done to have the numbers updating with different variants being selected?

Thanks in advance for any advice!

critters21
New Member
1 0 0

Did you find out how this is done? I need to know this also.