0

我想在我的 Magento 产品页面的某处添加“免费送货”标签。该代码非常简单:

<?php echo $this->__('FREE SHIPPING') ?>

问题是,我只为价格超过 199 美元的产品提供免费送货服务。

如何设置 if 语句仅在价格超过 199 美元时显示此标签?

感谢您的帮助(顺便说一下,我正在使用 Magento v1.6.1)

4

1 回答 1

2

你可以尝试做这样的事情:


// somewhere on product page, e.g. view.phtml
<?php if ($_product->getPrice() > 199) :
//if you don't have direct access to $_product variable from your template or to $this->getProduct() method of block template belongs to, try using registry,e.g.
//if (Mage::registry('current_product')->getPrice() > 199):
    echo $this->__('FREE SHIPPING');
endif; ?>

希望它会有所帮助。

于 2012-06-22T21:11:50.480 回答