在magento前端上显示缺货状态 [英] Show backorder status on magento frontend

查看:96
本文介绍了在magento前端上显示缺货状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在产品页面(前端)上显示当前商品仅供缺货,没有库存.

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";
}
?>

您也可以将此代码放入 产品的可用性消息来自的app\design\frontend\base\default\template\catalog\product\view\type\default.phtml文件.

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.

这篇关于在magento前端上显示缺货状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆