/** * Add a usual line item with amount and qty * * @param Varien_Object $salesItem * @return Varien_Object */ protected function _addRegularItem(Varien_Object $salesItem) { if ($this->_salesEntity instanceof Mage_Sales_Model_Order) { $qty = (int) $salesItem->getQtyOrdered(); $amount = (double) $salesItem->getPrice(); // TODO: nominal item for order } else { $qty = (int) $salesItem->getTotalQty(); $amount = $salesItem->isNominal() ? 0 : (double) $salesItem->getCalculationPrice(); } // workaround in case if item subtotal precision is not compatible with PayPal (.2) $subAggregatedLabel = ''; if ($amount - round($amount, 2)) { $amount = $amount * $qty; $subAggregatedLabel = ' x' . $qty; $qty = 1; } // aggregate item price if item qty * price does not match row total if ($amount * $qty != $salesItem->getRowTotal()) { $amount = (double) $salesItem->getRowTotal(); $subAggregatedLabel = ' x' . $qty; $qty = 1; } return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku()); }