How to display the quantity of products in stock on the Magento 1 front end product page

This is how you enable the display of the quantity of products in inventory on the front end product page.

Open /app/design/frontend/default/YOURTHEME/template/catalog/product/view.phtml

In there you can paste this code anywhere you would like the stock quantity to display:

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty Available:') ?> <span><!--<?php echo $this->__('In stock') ?>--><?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?></span></p>
<?php else: ?>
    <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>

5 Replies to “How to display the quantity of products in stock on the Magento 1 front end product page”

  1. Hi, i recently find this site and i use you code in my site. It work perfectly, but i stumble with something an i cannot find an properly answer.
    In my site i use grouped products, and in my grouped products tables when i use this code….
    Magento don’t display out of stock when the stock is “0” and also display stock “0” in category list. And this creates confusion when the user sees “stock 0” immediately after beginning with “for grouped products.

    Can you please help me to solve this issue, i try everything, but i’m not an advanced coder so it beats me!
    you can see a demo in my page link

Leave a Reply

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