Add Qty or message to Availability: In Stock

In the product view page, there are 2 availability messages – In Stock and Out of Stock. Additional information such as qty on hand or shipping times would also be helpful to your customers.

In this example, we’re going to add “Availability: In Stock – Leaves whse in 1-2 business days” (You can change the message or display the qty on hand if desired)

in app/design/frontend/default/default/template/catalog/product/view/type/default.phtml

Change to the following:

<?php /* @var $this Mage_Catalog_Block_Product_View_Abstract */?>
$_product = $this->getProduct();
$_quantity = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());

<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><b><?php echo $this->__('In stock') ?></b></span><?php if ($_quantity > 0) { echo $this->__(' - Leaves whse in 1-2 business days'); } ?></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) ?>

The change is to add the $_quantity line and also modifying the line that displays the in stock message

Leave a Reply