Show backorder status on magento frontend

余生长醉 提交于 2019-12-05 08:12:56
Mufaddal

To do this make sure you have enabled backorders from inventory tab.

If you are on product page then first of all retrieve product qty.

<?php
$inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);

if( (int)$inventory->getQty() == 0 && $inventory->getBackorders() )
{
  // No Backorders => getBackorders() = 0
  // Allow Qty Below 0 => getBackorders() = 1
  // Allow Qty Below 0 and Notify Customer => getBackorders() = 2
  echo "display your backordedr message";
}
?>

You can also put this code in app\design\frontend\base\default\template\catalog\product\view\type\default.phtml file where availability message of product come from.

Raj

Here is the code that you need to add in view.phtml. This will show the backorder message:

$inventory =  Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
$inv_qty = (int)$inventory->getQty();
if($inventory->getBackorders() >= 0 && $inv_qty == 0)
{ 
    echo "Your backorder message goes here";
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!