首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento折扣未显示在行项目上,但总数正确

问Magento折扣未显示在行项目上,但总数正确
EN

Stack Overflow用户
提问于 2013-08-02 01:37:53
回答 1查看 1.9K关注 0票数 1

我的问题是,当我试图从结帐时,它将应用正确的总折扣在底部的magento管理订单页面的订单,但行项目显示$0折扣。

例如,假设我有一个促销活动,每件东西都有50%的折扣,有人买了2件商品,苹果10美元,橙色5美元,购物车总数是15 - 50% =7.50美元,这已经发生了,但是当你查看行项目时,这两个折扣都设置为0美元,它应该是: apple数量:1价格$10折扣$5总计$5橙色数量:1价格$5折扣2.50总计2.50美元;以下是我的代码:

代码语言:javascript
复制
 $couponCode = (string) $this->getRequest()->getParam('coupon_code');
    if ($this->getRequest()->getParam('remove') == 1) {
        $couponCode = '';
    }
    $oldCouponCode = $this->_getQuote()->getCouponCode();

    if (!strlen($couponCode) && !strlen($oldCouponCode)) {
        $this->_goBack();
        return;
    }

    try {
        $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
        $this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
            ->collectTotals()
            ->save();

        if ($couponCode) {
            if ($couponCode == $this->_getQuote()->getCouponCode()) {
                $this->_getSession()->addSuccess(
                    $this->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlspecialchars($couponCode))
                );
            }
            else {
                $this->_getSession()->addError(
                    $this->__('Coupon code "%s" is not valid.', Mage::helper('core')->htmlspecialchars($couponCode))
                );
            }
        } else {
            $this->_getSession()->addSuccess($this->__('Coupon code was canceled.'));
        }


    echo $this->_getReviewHtml();
    exit;
EN

回答 1

Stack Overflow用户

发布于 2013-08-02 02:08:34

购物车促销规则是针对每个项目的折扣还是针对整个订单的折扣?

代码本身看起来没问题。

您可能还希望为检出会话添加。

代码语言:javascript
复制
Mage::getSingleton("checkout/session")->setData("coupon_code",strlen($couponCode));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18000897

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档