本文整理汇总了PHP中Mage_Sales_Model_Order_Invoice::getItemsCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Invoice::getItemsCollection方法的具体用法?PHP Mage_Sales_Model_Order_Invoice::getItemsCollection怎么用?PHP Mage_Sales_Model_Order_Invoice::getItemsCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Invoice
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Invoice::getItemsCollection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractFromCreditMemoItems
/**
* extracts all data from the invoice according to the credit memo items
*
* @param $itemContainer
*/
protected function extractFromCreditMemoItems(Mage_Sales_Model_Order_Invoice $invoice)
{
foreach ($invoice->getItemsCollection() as $item) {
if (array_key_exists($item->getOrderItemId(), $this->creditmemo['items'])) {
if ($item->getParentItemId() && $item->getParentItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE || $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
continue;
}
$this->additionalParams['ITEMID' . $this->itemIdx] = substr($item->getOrderItemId(), 0, 15);
$this->additionalParams['ITEMNAME' . $this->itemIdx] = substr($item->getName(), 0, 30);
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($item->getBasePriceInclTax());
$this->amount += $this->getOpsDataHelper()->getAmount($item->getBasePriceInclTax()) * $this->creditmemo['items'][$item->getOrderItemId()]['qty'];
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = $this->creditmemo['items'][$item->getOrderItemId()]['qty'];
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = str_replace(',', '.', (string) (double) $item->getTaxPercent()) . '%';
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
++$this->itemIdx;
}
}
}
示例2: extractFromInvoiceItems
/**
* extracts all necessary data from the invoice items
*
* @param Mage_Sales_Model_Order_Invoice $invoice
*/
protected function extractFromInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
{
foreach ($invoice->getItemsCollection() as $item) {
/** @var $item Mage_Sales_Model_Order_Invoice_Item */
// filter out configurable products
if ($item->getParentItemId() && $item->getParentItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE || $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
continue;
}
$this->additionalParams['ITEMID' . $this->itemIdx] = substr($item->getOrderItemId(), 0, 15);
$this->additionalParams['ITEMNAME' . $this->itemIdx] = substr($item->getName(), 0, 30);
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($item->getBasePriceInclTax());
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = $item->getQty();
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = str_replace(',', '.', (string) (double) $item->getTaxPercent()) . '%';
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
++$this->itemIdx;
}
return $this;
}
示例3: collect
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$invoice->setGiftwrapAmount(0);
$totalAmount = 0;
$giftwrapPrice = 0;
$giftcardPrice = 0;
$giftbox = array();
$parentItemChildQty = array();
$order = $invoice->getOrder();
$tax_info = $order->getFullTaxInfo();
$rate = $tax_info[0]['percent'];
//lay ra cac giftbox co trong order
foreach ($invoice->getAllItems() as $item) {
$orderItemModel = Mage::getResourceModel('sales/order_item_collection');
$orderItem = $orderItemModel->addFieldToFilter('item_id', $item->getOrderItemId())->getFirstItem();
if (!$orderItem->getParentItemId() && $item->getQty() > 0) {
$quoteItemId = $orderItem->getQuoteItemId();
$selectionItem = Mage::getResourceModel('giftwrap/selectionitem_collection')->addFieldToFilter('item_id', $quoteItemId)->getFirstItem();
$selection = Mage::getModel('giftwrap/selection')->load($selectionItem->getSelectionId());
if ($selection && !$selection->getIsInvoiced()) {
if (!in_array($selection->getId(), $giftbox)) {
$giftwrapPrice = 0;
$giftcardPrice = 0;
$totalQtyInBox = 0;
$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()) {
$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;
}
}
}
} else {
$parentItemChildQty[$orderItem->getParentItemId()] += $item->getQty();
}
}
if (count($parentItemChildQty) > 0) {
foreach ($parentItemChildQty as $orderItemId => $qty) {
if ($qty == 0) {
$quoteItemId = Mage::getModel('sales/order_item')->load($orderItemId)->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;
if (($key = array_search($selection->getId(), $giftbox)) !== false) {
unset($giftbox[$key]);
$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()) {
$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);
$lastItem = $invoice->getItemsCollection()->getLastItem();
if ($lastItem->getOrderItem()->getParentItemId()) {
$lastId = $lastItem->getOrderItem()->getParentItemId();
} else {
$lastId = $lastItem->getOrderItem()->getId();
}
Mage::getSingleton('adminhtml/session')->setSubtotalGiftwrap($totalAmount);
Mage::getSingleton('adminhtml/session')->setGiftbox($giftbox);
Mage::getSingleton('adminhtml/session')->setInvoiceLastId($lastId);
$orderGiftwrapAmount = $totalAmount;
if (Mage::getStoreConfig('giftwrap/calculation/tax', Mage::app()->getStore(true)->getId())) {
if ($rate) {
$orderGiftwrapTax = $totalAmount * $rate;
}
}
if ($orderGiftwrapAmount || $orderGiftwrapAmount == 0) {
$invoice->setGiftwrapAmount($orderGiftwrapAmount);
$invoice->setGrandTotal($invoice->getGrandTotal() + $orderGiftwrapAmount);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $orderGiftwrapAmount);
if ($orderGiftwrapTax) {
$invoice->setGiftwrapTax($orderGiftwrapTax);
$invoice->setGrandTotal($invoice->getGrandTotal() + $orderGiftwrapTax);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $orderGiftwrapTax);
}
}
return $this;
}