Magento : Availability of configurable products on Cart page

1.4k views Asked by At

I want to show Stock Availability on cart page in magento for a configurable products. The stock status is fine on Product Detail page, however on cart page it always shows "out of stock" for configurable product. I can understand what the reason is, the inventory of the configurable product itself is set to 0. However on a product detail page it does show "In Stock" because the child products are "In Stock". But if I want to check the availability on Cart page, it always shows "Out of Stock". Below is the code how I want to achieve the Stock Availability on a Cart page.

   <?php 
         $thisProduct = Mage::getModel('catalog/product')->load($_item->getId());
         if($thisProduct->isAvailable()):
            echo $this->__('In stock'); 
         else:
            echo $this->__('Out of stock');
         endif;
    ?>
2

There are 2 answers

0
MagePsycho On

You can try with: isSaleable() method instead.
Let me know if that works for you.

Thanks

0
Nandakumar On

In the path template\checkout\cart\item\default.phtml use the below code to check product availability

$_item->getProduct()->isSaleable() or else when you got $_item = $this->getItem(); object

Hope it may helps