本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::getItemsCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::getItemsCollection方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::getItemsCollection怎么用?PHP Mage_Sales_Model_Order_Creditmemo::getItemsCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::getItemsCollection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getReturnedItems
/**
* Returns array of ReturnOrderLineData
*
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
* @return array
*/
protected function _getReturnedItems(Mage_Sales_Model_Order_Creditmemo $creditMemo)
{
$returnedItems = array();
/** @var $item Mage_Sales_Model_Order_Creditmemo_Item */
foreach ($creditMemo->getItemsCollection() as $item) {
if ($item->getQty() == 0 || $item->getPrice() == 0) {
continue;
}
$returnedItems[] = $this->_createReturnOrderLineData($item);
}
return $returnedItems;
}
示例2: collect
//.........这里部分代码省略.........
$orderItem = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $giftboxItem->getItemId())->getFirstItem();
$itemOfBox[$orderItem->getItemId()] = $gbox->getId();
$totalRefundedOfBox[$gbox->getId()] += (int) $orderItem->getQtyRefunded();
}
}
foreach ($creditmemo->getAllItems() as $item) {
$orderItem = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('item_id', $item->getOrderItemId())->getFirstItem();
if (!$orderItem->getParentItemId() && $item->getQty() > 0) {
if (isset($itemOfBox[$item->getOrderItemId()])) {
$prepareQty[$itemOfBox[$item->getOrderItemId()]] += (int) $totalRefundedOfBox[$itemOfBox[$item->getOrderItemId()]] + (int) $item->getQty();
if ($prepareQty[$itemOfBox[$item->getOrderItemId()]] == (int) $totalQtyOfBox[$itemOfBox[$item->getOrderItemId()]]) {
$giftwrapPrice = 0;
$giftcardPrice = 0;
$totalQtyInBox = 0;
$selection = Mage::getModel('giftwrap/selection')->load($itemOfBox[$item->getOrderItemId()]);
$giftbox[] = $selection->getId();
$giftwrapPrice += (double) Mage::getModel('giftwrap/giftwrap')->load($selection->getStyleId())->getPrice();
if ($selection->getGiftcardId()) {
$giftcardPrice += (double) Mage::getModel('giftwrap/giftcard')->load($selection->getGiftcardId())->getPrice();
}
if ($selection->getCalculateByItem()) {
$totalQtyInBox = $totalQtyOfBox[$selection->getId()];
$totalAmount += $totalQtyInBox * ($giftwrapPrice + $giftcardPrice);
} else {
$totalAmount += $giftwrapPrice + $giftcardPrice;
}
}
}
} else {
$parentItemChildQty[$orderItem->getParentItemId()] += (int) $orderItem->getQtyRefunded() + (int) $item->getQty();
$parentItemOrderedQty[$orderItem->getParentItemId()] += (int) $orderItem->getQtyOrdered();
}
}
if (count($parentItemChildQty) > 0) {
foreach ($parentItemChildQty as $orderItemId => $qty) {
$orderItem = Mage::getModel('sales/order_item')->load($orderItemId);
$quoteItemId = $orderItem->getQuoteItemId();
$selectionItem = Mage::getResourceModel('giftwrap/selectionitem_collection')->addFieldToFilter('item_id', $quoteItemId)->getFirstItem();
$selection = Mage::getModel('giftwrap/selection')->load($selectionItem->getSelectionId());
$giftwrapPrice = 0;
$giftcardPrice = 0;
$totalQtyInBox = 0;
$giftwrapPrice += (double) Mage::getModel('giftwrap/giftwrap')->load($selection->getStyleId())->getPrice();
if ($selection->getGiftcardId()) {
$giftcardPrice += (double) Mage::getModel('giftwrap/giftcard')->load($selection->getGiftcardId())->getPrice();
}
$key = array_search($selection->getId(), $giftbox);
if ($key !== false) {
if ($qty != $parentItemOrderedQty[$orderItemId]) {
if ($selection->getCalculateByItem()) {
$selectionItems = Mage::getResourceModel('giftwrap/selectionitem_collection')->addFieldToFilter('selection_id', $selection->getId());
foreach ($selectionItems as $sItem) {
$totalQtyInBox += $sItem->getQty();
}
$totalAmount -= $totalQtyInBox * ($giftwrapPrice + $giftcardPrice);
} else {
$totalAmount -= $giftwrapPrice + $giftcardPrice;
}
unset($giftbox[$key]);
}
} else {
$qtyToRefund = (int) $qty;
if ($qtyToRefund == (int) $parentItemOrderedQty[$orderItemId]) {
$giftbox[] = $selection->getId();
if ($selection->getCalculateByItem()) {
$selectionItems = Mage::getResourceModel('giftwrap/selectionitem_collection')->addFieldToFilter('selection_id', $selection->getId());
foreach ($selectionItems as $sItem) {
$totalQtyInBox += $sItem->getQty();
}
$totalAmount += $totalQtyInBox * ($giftwrapPrice + $giftcardPrice);
} else {
$totalAmount += $giftwrapPrice + $giftcardPrice;
}
}
}
}
}
$giftbox = array_filter($giftbox);
Mage::getSingleton('adminhtml/session')->setSubtotalGiftwrap($totalAmount);
Mage::getSingleton('adminhtml/session')->setGiftboxRefund($giftbox);
$lastId = $creditmemo->getItemsCollection()->getLastItem()->getId();
Mage::getSingleton('adminhtml/session')->setLastId($lastId);
$orderGiftwrapAmount = $totalAmount;
if (Mage::getStoreConfig('giftwrap/calculation/tax', Mage::app()->getStore(true)->getId())) {
if ($rate) {
$orderGiftwrapTax = $totalAmount * $rate;
}
}
if ($orderGiftwrapAmount || $orderGiftwrapAmount == 0) {
$creditmemo->setGiftwrapAmount($orderGiftwrapAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderGiftwrapAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderGiftwrapAmount);
if ($orderGiftwrapTax) {
$creditmemo->setGiftwrapTax($orderGiftwrapTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderGiftwrapTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderGiftwrapTax);
}
}
return $this;
}