We will see in this tutorial how you can display the stock on your shopify product page

It is important for your customer to know if you have any units left in stock for your products and it also makes your product page more attractive.

Remember that in this tutorial we will display the real stock that combines all variants. This means that it is not recommended for dropshipping stores because the notion of out of stock is not the same.

You can see the end result on this demo store : https://speed-ecom-tutorials.myshopify.com/products/product-1

Password : speedfly

Let’s get technical ! 🙂

How to install the code

Go to the code editor of your shopify theme and open the “sections” folder.

Find the product-template.liquid file and use the search bar with Ctrl + F (or cmd + R) to find the line that contains “price”. Here is an example for the Debut theme.

If you can’t find this area try putting a random word at different places and refresh your product page to find the right spot.

You will now copy/paste the following code to that spot

<style>
.sd-items-count p { color:#ff2200; font-size:15px; padding:7px 0; margin:0; }
.sd-items-count img { float:left; width:20px !important;height:auto !important;margin:0 7px 0 0; padding:0; }
</style>
{% assign product_qty = 0 %}
{% for variant in product.variants %}
{% if variant.inventory_quantity > 0 %}
{% assign product_qty = product_qty | plus: variant.inventory_quantity %}
{% endif %}
{% endfor %}
{% if product_qty > 0 %}
<div class="sd-items-count">          
<p><img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDM5LjQxMSAzOS40MTEiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM5LjQxMSAzOS40MTE7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iNTEycH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cGF0aCBkPSJNMjQuNTU1LDUuODVjLTAuMTI4LDAtMC4yNTYtMC4wNDktMC4zNTQtMC4xNDZsLTQuNDk1LTQuNDk2bC00LjQ5Nyw0LjQ5NmMtMC4xOTUsMC4xOTUtMC41MTIsMC4xOTUtMC43MDcsMCAgICBzLTAuMTk1LTAuNTEyLDAtMC43MDdsNC44NTEtNC44NUMxOS40NDcsMC4wNTMsMTkuNTc0LDAsMTkuNzA3LDBsMCwwYzAuMTMzLDAsMC4yNiwwLjA1MywwLjM1NCwwLjE0Nmw0Ljg0OSw0Ljg1ICAgIGMwLjE5NSwwLjE5NSwwLjE5NSwwLjUxMiwwLDAuNzA3QzI0LjgxMSw1LjgwMSwyNC42ODMsNS44NSwyNC41NTUsNS44NXoiIGZpbGw9IiMwMDAwMDAiLz4KCTwvZz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
There are <span class="sd-count"><strong>{{ product_qty }}</strong></span> units left in stock.</p>
</div>
{% endif %}

If you want to put it on the featured product of your homepage, you will just have to find the file featured-product.liquid file in the sections folder.

Depending on the theme the name of the file may not necessarily be the same but if it is well coded then it will be 😉.

This tutorial is also available in video format

Hope you found this tutorial helpful !

You have any ideas for new tutorials ? Any questions about this one ? Leave me a comment 😉

182 Responses

  1. This was EXCELENT and did almost exactly what I was looking for!

    One thing, is it possible to do the same thing for variants? So it shows inventory on a specific variant enventory…

    Example:
    Shoe Size
    9 (5 in stock)
    10 (2 in stock)
    11(Out Of Stock)
    12 (Out Of Stock)
    13 (1 in stock)

    instead of how it is now that shows 8 In Stock regardless of what variant you click on.

    Here’s one of my products as example…
    https://www.hellonwheelsperformanceltd.ca/products/fleece-second-gen-hardware-kit?_pos=1&_sid=c05702763&_ss=r

    1. Thank you for your comment 🙂

      Hmm, unfortunately, from what it know it is not possible on Shopify because of technical limitations, not out of lack of wanting. Shopify groups the stock of all variants together.

  2. I want to hide product variants if variant quantity is less than three. or show out of stock if variant quantity is less than three.

  3. Thank you very much! It was very easy to follow your instructions and I was able to display the total quantities remaining for the total number of variants.

    Is it easy to modifiy the code to only show the quanities for specific items with a specific tag referenced?

  4. OMG! Thank you so much for this great tutorial! It did exactly what I needed quick simple and easy! I was very nervous about modifying adding to my code… This is all extremely new to me, but you made it easy to follow and understand! Thank you thank you thank you.

  5. Good day! I just want to offer you a big thumbs up for your excellent information you have got here on this post. Ill be coming back to your blog for more soon.

  6. [url=https://propecia1st.science/#]order generic propecia without prescription[/url] order cheap propecia no prescription

  7. can i get mobic prices [url=https://mobic.store/#]where can i get mobic without dr prescription[/url] order cheap mobic for sale

  8. how can i get mobic price [url=https://mobic.store/#]how can i get generic mobic without prescription[/url] buying mobic no prescription

  9. reputable mexican pharmacies online medication from mexico pharmacy or best online pharmacies in mexico
    http://girlequation.net/__media__/js/netsoltrademark.php?d=mexpharmacy.sbs п»їbest mexican online pharmacies
    [url=http://blackcreekcheddar.com/__media__/js/netsoltrademark.php?d=mexpharmacy.sbs]reputable mexican pharmacies online[/url] mexico drug stores pharmacies and [url=https://masterbationtube.com/user/zzeasvillj/videos]buying prescription drugs in mexico[/url] mexican mail order pharmacies

  10. mexican pharmaceuticals online mexico drug stores pharmacies or reputable mexican pharmacies online
    http://movie.newyouth.beida-online.com/__media__/js/netsoltrademark.php?d=mexpharmacy.sbs buying from online mexican pharmacy
    [url=http://xgluc.biz/__media__/js/netsoltrademark.php?d=mexpharmacy.sbs]mexico drug stores pharmacies[/url] mexico pharmacies prescription drugs and [url=https://www.support-groups.org/memberlist.php?mode=viewprofile&u=86462]buying from online mexican pharmacy[/url] mexican pharmaceuticals online

  11. buy medicines online in india buy medicines online in india or п»їlegitimate online pharmacies india
    http://bq–3cplxd5d.org/__media__/js/netsoltrademark.php?d=indiamedicine.world online shopping pharmacy india
    [url=http://bluesagesecrets.com/__media__/js/netsoltrademark.php?d=indiamedicine.world]india pharmacy[/url] indian pharmacy paypal and [url=https://www.support-groups.org/memberlist.php?mode=viewprofile&u=86714]indian pharmacy[/url] indian pharmacy online

  12. mexico drug stores pharmacies п»їbest mexican online pharmacies or mexico pharmacies prescription drugs
    http://jockeykidsstore.com/__media__/js/netsoltrademark.php?d=mexpharmacy.sbs mexican border pharmacies shipping to usa
    [url=http://www.dorienalongmire.com/__media__/js/netsoltrademark.php?d=mexpharmacy.sbs]buying prescription drugs in mexico[/url] mexican drugstore online and [url=http://www.lspandeng.com.cn/home.php?mod=space&uid=14997]pharmacies in mexico that ship to usa[/url] mexican drugstore online

  13. neurontin prescription coupon buying neurontin without a prescription or buy gabapentin online
    http://cnhfinancial.com/__media__/js/netsoltrademark.php?d=gabapentin.pro neurontin price comparison
    [url=http://bosanci.org/__media__/js/netsoltrademark.php?d=gabapentin.pro]neurontin prescription cost[/url] purchase neurontin online and [url=http://www.9kuan9.com/home.php?mod=space&uid=109157]buying neurontin without a prescription[/url] cost of brand name neurontin

  14. zithromax over the counter canada zithromax 500mg or zithromax 500 mg lowest price pharmacy online
    http://nhmunicipalassociation.org/__media__/js/netsoltrademark.php?d=azithromycin.men can i buy zithromax over the counter
    [url=http://pilgrimrewards.com/__media__/js/netsoltrademark.php?d=azithromycin.men]zithromax 500 mg[/url] zithromax online australia and [url=http://bbs.cheaa.com/home.php?mod=space&uid=2930965]zithromax for sale online[/url] order zithromax over the counter

  15. zithromax 500 mg lowest price online [url=https://azithromycin.men/#]can you buy zithromax online[/url] where can i buy zithromax in canada

  16. where to get avodart no prescription where can i get generic avodart tablets or where to get generic avodart pills
    http://icravethewave.com/__media__/js/netsoltrademark.php?d=avodart.pro how can i get generic avodart online
    [url=http://celebraterecovery.co/__media__/js/netsoltrademark.php?d=avodart.pro]where to get avodart pills[/url] cost avodart prices and [url=https://quantrinet.com/forum/member.php?u=493263]where to buy generic avodart[/url] how can i get generic avodart without rx

  17. can you get cheap avodart get generic avodart no prescription or can i get generic avodart no prescription
    http://discoverchickasaw.com/__media__/js/netsoltrademark.php?d=avodart.pro where can i buy generic avodart pill
    [url=http://cocokeywaterresort.com/__media__/js/netsoltrademark.php?d=avodart.pro]how to get cheap avodart pill[/url] can i buy cheap avodart without a prescription and [url=http://www.gearcup.cn/home.php?mod=space&uid=115498]avodart price[/url] how can i get avodart without rx

  18. indian pharmacy online [url=https://indiapharmacy.cheap/#]online shopping pharmacy india[/url] top online pharmacy india

  19. buying prescription drugs in mexico mexico pharmacies prescription drugs or mexico drug stores pharmacies
    http://cosaralisdesign.com/__media__/js/netsoltrademark.php?d=mexicanpharmacy.guru buying prescription drugs in mexico online
    [url=http://toter.us/__media__/js/netsoltrademark.php?d=mexicanpharmacy.guru]pharmacies in mexico that ship to usa[/url] п»їbest mexican online pharmacies and [url=http://byauto.net/home.php?mod=space&uid=636485]reputable mexican pharmacies online[/url] mexican online pharmacies prescription drugs

  20. Nice post. I learn something new and challenging on websites I
    stumbleupon every day. It will always be interesting to read articles from other writers and use
    something from other sites.

  21. canada drugs online review [url=http://certifiedcanadapills.pro/#]canada drugs reviews[/url] my canadian pharmacy

  22. Usually I don’t learn article on blogs, however I wish to say that this write-up very pressured me to try and do it!

    Your writing taste has been surprised me. Thank you, very great article.

  23. you’re actually a excellent webmaster. The site loading speed is amazing.
    It seems that you are doing any distinctive trick. Also, The
    contents are masterpiece. you’ve done a wonderful job on this subject!

  24. neurontin 4 mg neurontin 600 mg tablet or prescription drug neurontin
    http://small-reels-big-fish.com/__media__/js/netsoltrademark.php?d=gabapentin.tech neurontin 1200 mg
    [url=http://yourwaybrands.net/__media__/js/netsoltrademark.php?d=gabapentin.tech]neurontin 800 mg[/url] neurontin price comparison and [url=http://www.empyrethegame.com/forum/memberlist.php?mode=viewprofile&u=262624]neurontin prescription medication[/url] neurontin 600 mg price

  25. I do not even know how I ended up here, however I assumed this post used to be great.
    I don’t know who you are but definitely you are going to a well-known blogger if you happen to aren’t already.
    Cheers!

  26. Software program and work process modifications should be documented
    and validated, together with verification that
    documented work process restoration tasks and supporting disaster restoration infrastructure permit
    staff to get better inside the.

  27. Thanks for your post on this blog site. From my personal experience, occasionally softening right up a photograph may provide the photography with a bit of an inventive flare.

  28. It’s in fact very complicated in this active life to listen news on Television, so I
    just use the web for that purpose, and get the latest news.

  29. canadianpharmacymeds is canadian pharmacy legit or pharmacies in canada that ship to the us
    http://commercialsuretybonds.com/__media__/js/netsoltrademark.php?d=canadaph.pro canadian pharmacy online ship to usa
    [url=http://crainsapps.com/__media__/js/netsoltrademark.php?d=canadaph.pro]canadian pharmacy india[/url] best canadian online pharmacy reviews and [url=http://80tt1.com/home.php?mod=space&uid=82396]canadian pharmacy[/url] canadian pharmacy online reviews

  30. Hello there, You have done an excellent job.
    I’ll certainly digg it and personally suggest to my friends.
    I am sure they’ll be benefited from this site.

  31. 77 canadian pharmacy canadian drug or canadian pharmacy meds
    http://horizoninformationservices.com/__media__/js/netsoltrademark.php?d=canadaph.pro canadian pharmacy online reviews
    [url=http://innertainment.com/__media__/js/netsoltrademark.php?d=canadaph.pro]canadian pharmacy checker[/url] trustworthy canadian pharmacy and [url=http://www.mmecaw.com/home.php?mod=space&uid=422763]ed drugs online from canada[/url] certified canadian international pharmacy

  32. buying prescription drugs online without a prescription online canadian pharmacies or buy without perscription
    http://webinformer.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu no prescription drugs online
    [url=http://atriumwizard.net/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu]online meds without prescription[/url] buy perscription drugs and [url=http://bbs.cheaa.com/home.php?mod=space&uid=2960598]canada mail order prescription[/url] buy canadian pharmacy

  33. buying online prescription drugs canadian pharmacy world coupon or how to buy prescriptions from canada safely
    http://sheldonduncan.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu best canadian mail order pharmacy
    [url=http://591capital.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu]canadian international pharmacy[/url] canadian pharmecy and [url=http://www.118btc.com/home.php?mod=space&uid=656069]mail order pharmacy canada[/url] top rated online pharmacy

  34. Hello, i read your blog occasionally and i own a similar one and i was just wondering if you get a
    lot of spam comments? If so how do you reduce it, any plugin or anything you can advise?
    I get so much lately it’s driving me crazy so any help is very much appreciated.

  35. best canadian drugstore canada drug store or ordering prescription drugs from canada
    http://www.cn-eximus.biz/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu international online pharmacy
    [url=http://exec-recruitment.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu]top online pharmacies[/url] how to get a prescription in canada and [url=https://kwik.adriensosa.fr/forums/users/cbtauxivyq/]mexican pharmacies online[/url] online pharmacy no rx needed

  36. buy medication online without prescription top canada drugs discount code or us based online pharmacy
    http://threefirersllc.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu discount canadian pharmacy
    [url=http://sno-ho.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu]us pharmacy in india[/url] canadian rx prescription drugstore and [url=http://www.fxwenxue.com/home.php?mod=space&uid=650465]canadian pharmacies online[/url] meds online no prescription

  37. Today, I went to the beach front with my kids. I found a
    sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the
    shell to her ear and screamed. There was a hermit crab
    inside and it pinched her ear. She never wants
    to go back! LoL I know this is completely off topic but I had to tell someone!

  38. buy rx online buying prescription medicine online or canada pharm
    http://freshipes.net/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu on line pharmacy canada
    [url=http://cleanisnotasmell.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu]no prescription needed pharmacy[/url] india online pharmacy and [url=http://tc.k33888.cn/home.php?mod=space&uid=2244444]legitimate online pharmacy usa[/url] certified canadian international pharmacy

  39. This piece of writing will help the internet visitors for setting up new blog or even a blog from start to end.

  40. online canadian pharmacy no prescription how to buy prescriptions from canada safely or canadian drugstores
    http://dokodemodoor.biz/__media__/js/netsoltrademark.php?d=interpharm.pro candaian pharmacies
    [url=http://openjfx.org/__media__/js/netsoltrademark.php?d=interpharm.pro]online canadian pharmacys[/url] canadian phamacy and [url=http://bbs1.857moli.com/home.php?mod=space&uid=466549]how to stop calls from canadian online pharmacy[/url] how to order prescription drugs from canada

  41. no prescription drugs online no prescription online pharmacy or canada drug center promo code
    http://www.callvillagepizza.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu canada pharmacies online prescriptions
    [url=http://wwfpiemonte.com/__media__/js/netsoltrademark.php?d=internationalpharmacy.icu]best online drugstores[/url] how to buy prescriptions from canada safely and [url=https://forex-bitcoin.com/members/287076-hzmyeaboea]order medication without prescription[/url] online drugs without prescription

  42. Pharmacie en ligne livraison gratuite Pharmacie en ligne fiable or acheter medicament a l etranger sans ordonnance
    http://stopmyrepairbills.net/__media__/js/netsoltrademark.php?d=pharmacieenligne.icu acheter mГ©dicaments Г  l’Г©tranger
    [url=http://berkshirehathawaytriangle.com/__media__/js/netsoltrademark.php?d=pharmacieenligne.icu]Pharmacie en ligne livraison gratuite[/url] Pharmacie en ligne sans ordonnance and [url=http://bbs.94kk.net/home.php?mod=space&uid=8063350]Pharmacies en ligne certifiГ©es[/url] pharmacie ouverte 24/24

  43. farmacia online miglior prezzo п»їfarmacia online migliore or acquistare farmaci senza ricetta
    http://907weather.com/__media__/js/netsoltrademark.php?d=farmaciaonline.men acquisto farmaci con ricetta
    [url=http://workingtv.com/__media__/js/netsoltrademark.php?d=farmaciaonline.men]farmacie on line spedizione gratuita[/url] farmacia online migliore and [url=http://www.ziyuangroup.com/space-uid-83206.html]acquisto farmaci con ricetta[/url] farmacia online senza ricetta

Leave a Reply

Your email address will not be published. Required fields are marked *