当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Order_Invoice::setGiftwrapAmount方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Order_Invoice::setGiftwrapAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Invoice::setGiftwrapAmount方法的具体用法?PHP Mage_Sales_Model_Order_Invoice::setGiftwrapAmount怎么用?PHP Mage_Sales_Model_Order_Invoice::setGiftwrapAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Order_Invoice的用法示例。


在下文中一共展示了Mage_Sales_Model_Order_Invoice::setGiftwrapAmount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: collect

 public function collect(Mage_Sales_Model_Order_Invoice $invoice)
 {
     $invoice->setOnestepcheckoutGiftwrapAmount(0);
     $orderGiftwrapAmount = $invoice->getOrder()->getOnestepcheckoutGiftwrapAmount();
     $baseOrderShippingAmount = $invoice->getOrder()->getOnestepcheckoutGiftwrapAmount();
     if ($orderGiftwrapAmount) {
         $invoice->setGiftwrapAmount($orderGiftwrapAmount);
         $invoice->setGrandTotal($invoice->getGrandTotal() + $orderGiftwrapAmount);
         $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $orderGiftwrapAmount);
     }
     return $this;
 }
开发者ID:ausger,项目名称:onestepcheckout-v340,代码行数:12,代码来源:Giftwrap.php

示例2: 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;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:100,代码来源:Giftwrap.php


注:本文中的Mage_Sales_Model_Order_Invoice::setGiftwrapAmount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。