【问题标题】:Display Percentage or Amount of discount for catalog price rule in Magento在 Magento 中显示目录价格规则的折扣百分比或金额
【发布时间】:2009-12-03 10:38:06
【问题描述】:

我正在努力弄清楚如何通过目录价格规则在 Magento 中显示应用到产品的折扣百分比或金额。

例如:我希望价格在前端显示如下:[old-price] [special-price] [discount info] where [old-price]有一个css删除线。

[old-price] 和 [special-price] 默认情况下可通过税务助手获得。我尝试使用 CatalogRule 模型,但我无法使用产品 ID 加载它,因为加载函数需要一个实体 ID,据我所知,没有任何其他有用的按产品 ID 加载的方法。我已经转储了(以及使用 get_class_methods)我在 price.phtml 文件中找到的所有内容(当然除了 $this),但没有任何帮助.

我可以只使用简单的计算来计算折扣百分比或金额,但我无法知道目录规则是基于百分比还是固定金额。

我希望这一切都有意义?
感谢您的帮助。
Rémy

【问题讨论】:

    标签: magento catalog discounts


    【解决方案1】:

    我同意 Magento 让这种事情变得有点太难了。我想在输入的优惠券代码旁边显示优惠券代码的描述。我怀疑我的代码将能够帮助您。我把这段代码放在模板 checkout/cart/coupon.phtml 的顶部:

    <?php $c = Mage::getResourceModel('salesrule/rule_collection'); $c->addBindParam('coupon_code', $this->getCouponCode()); $c->getSelect()->where("coupon_code is null or coupon_code='' or coupon_code=:coupon_code"); foreach ($c->getItems() as $item) { $coupon_description = $item->getDescription(); } ?>

    因此您可以看到 $coupon_description 现在包含购物车价格规则的描述,只要用户指定了优惠券代码。您可以通过这种方式从优惠券中添加更多属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 1970-01-01
      相关资源
      最近更新 更多