在 magento 前端显示缺货状态 [英] Show backorder status on magento frontend
问题描述
我需要在产品页面(前端)上显示当前商品仅用于延期交货且无库存.
I need to show on the product page (frontend) that the current item is for backorder ONLY and is not in stock.
目前我有库存显示可用数量,而那些延期交货的产品没有显示任何内容.
I have at the moment those in stock showing qty of what is available and those products on backorder doesn't show anything.
有谁知道我可以在 view.phtml 文件中输入的代码,该代码只会在那些设置为延期交货的产品上显示一条消息?
Does anyone know a code I can put in the view.phtml file that will ONLY show a message on those products set as backorder?
谢谢!
西蒙.
推荐答案
为此,请确保您已从库存选项卡启用延期交货.
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";
}
?>
您也可以将此代码放入appdesignfrontendasedefault emplatecatalogproductview ypedefault.phtml
产品可用性消息的来源文件.
You can also put this code in
appdesignfrontendasedefault emplatecatalogproductview ypedefault.phtml
file where availability message of product come from.
这篇关于在 magento 前端显示缺货状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!