Magneto 1.9 rwd display stock quantity

nightmare99

Free Member
Jan 31, 2011
195
32
Portsmouth
I am trying to display the actual stock quantity instead of "IN STOCK" in a magento 1.9 rwd theme based store but so far every bit of code I have tried does not seem to work.

Any ideas, I tried using the below code in default.phtml but it did not seem to work

<?php /* @var $this Mage_Catalog_Block_Product_View_Abstract */?>
<?php $_product = $this->getProduct() ?>
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Qty on Hand:') ?> <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; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>
 

zigojacko

Free Member
Dec 7, 2009
3,795
1,222
Plymouth, UK
clubnet.digital
Open up catalog/product/view/type/availability/default.phtml...

Replace the following:-

Code:
$_product = $this->getProduct(); ?>
<?php if ($this->displayProductStockStatus()): ?>
    <?php if ($_product->isAvailable()): ?>
        <p class="availability in-stock">
            <span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
            <span class="value"><?php echo $this->helper('catalog')->__('In stock') ?></span>
        </p>
    <?php else: ?>
        <p class="availability out-of-stock">
            <span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
            <span class="value"><?php echo $this->helper('catalog')->__('Out of stock') ?></span>
        </p>
    <?php endif; ?>
<?php endif; ?>

With the following:-

Code:
$_product = $this->getProduct(); ?>
<?php if ($this->displayProductStockStatus()): ?>
    <?php if ($_product->isAvailable()): ?>
        <p class="availability in-stock"><?php $quantity=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); if($quantity<11) { echo "Only " . intval($quantity) . " left in stock.";} else { echo "In stock"; }  ?> </span></p>
    <?php else: ?>
        <p class="availability out-of-stock">
            <span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
            <span class="value"><?php echo $this->helper('catalog')->__('Out of stock') ?></span>
        </p>
    <?php endif; ?>
<?php endif; ?>

This will change the default 'Availability: In Stock' text to show `Only 1 left in stock` or 'X in stock'. Give that a go and see if that does what you need.
 
Upvote 0

zigojacko

Free Member
Dec 7, 2009
3,795
1,222
Plymouth, UK
clubnet.digital
Perfect I will give that a go, out of interest are you familiar with a plugin called stock in the channel ?

Yes, we work with Stock in the Channel and were on their partners list (but they've just recently redesigned their website and I can't find where the partner profiles are listed on the website any longer). Brendon is our representative at SITC.
 
Upvote 0

Latest Articles

Join UK Business Forums for free business advice