发现一个奇怪的情况。在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());
}