解决Magento在paypal里订单qty变为1,商品名x数量 的情况

本文介绍了一个Magento系统中订单商品数量在PayPal支付时显示异常的问题,并提供了解决方案,即通过修改Cart.php文件中的_qty设置来避免数量被错误地固定为1。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发现一个奇怪的情况。在Magento订单里, 商品数量qty为3,到 paypal里 qty变为1了,商品名变成了:productname  x3  。 但是 总价格还是一样。

解决方法:

1.找到 app/code/Mage/Paypal/Model/Cart.php文件

大约434行的 _addRegularItem() 方法里,可以看到是 2个if判断里  qty都被设置为1。

2.注释2个if判断,最后代码为:

 protected function _addRegularItem(Varien_Object $salesItem)
    {

        if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
            $qty = (int) $salesItem->getQtyOrdered();
            $amount = (float) $salesItem->getBasePrice();
            // TODO: nominal item for order
        } else {
            $qty = (int) $salesItem->getTotalQty();
            $amount = $salesItem->isNominal() ? 0 : (float) $salesItem->getBaseCalculationPrice();
        }
        // workaround in case if item subtotal precision is not compatible with PayPal (.2)
        /*2015年4月27日
        处理最后 商品名称x3  这种情况,把 2个if判断注释掉
        */
       /* $subAggregatedLabel = '';
        if ($amount - round($amount, 2)) {
            $amount = $amount * $qty;
            $subAggregatedLabel = ' x' . $qty;
            $qty = 1;
            //Mage::log('11111');
        }*/
        //Mage::log('amount:'.$amount);
        //Mage::log('$qty:'.$qty);
        // aggregate item price if item qty * price does not match row total
       /* if (($amount * $qty) != $salesItem->getBaseRowTotal()) {
            //Mage::log('2222');
            $amount = (float) $salesItem->getBaseRowTotal();
            $subAggregatedLabel = ' x' . $qty;
            $qty = 1;
        }*/


        //Mage::log('getBaseRowTotal:'.$salesItem->getBaseRowTotal());
        //Mage::log('============================================================');
        //Mage::log($salesItem->getName() . $subAggregatedLabel);
        return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
    }




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值