开发者

Magento Backorder Availability Message

In my Magen开发者_StackOverflowto store I have it set up to allow backorders on some products. When these items are out of stock they still show as 'In Stock' on the product page but the user gets notified when they visit the cart that the item is on backorder.

I would like to change the product page so it also shows there that the item is on backorder in place of the 'In Stock' text.


In the file template/catalog/product/view/type/simple.phtml (and the same for bundled, configurable, grouped and virtual - you must override them all) there is some code that looks like this:

<?php if($_product->isSaleable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Availability:') ?>
    <span><?php echo $this->__('In stock') ?></span></p>

My guess is you need to change it a bit like this:

<?php if($_product->isSaleable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Availability:') ?>
    <span><?php echo $this->__($_product->isInStock() ? 'In stock' : 'On Backorder') ?></span></p>

Do a search of all template files for "availability" to see the various places that might need fixing.


I have found the following solution which worked for me at link below: Show backorder status on magento frontend

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜