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


PHP Mage_Sales_Model_Quote::getItemById方法代码示例

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


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

示例1: _initData

 /**
  * Loads customer, quote and quote item by request params
  *
  * @return Mage_Adminhtml_Customer_Cart_Product_Composite_CartController
  */
 protected function _initData()
 {
     $customerId = (int) $this->getRequest()->getParam('customer_id');
     if (!$customerId) {
         Mage::throwException($this->__('No customer id defined.'));
     }
     $this->_customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId);
     $quoteItemId = (int) $this->getRequest()->getParam('id');
     $websiteId = (int) $this->getRequest()->getParam('website_id');
     $this->_quote = Mage::getModel('Mage_Sales_Model_Quote')->setWebsite(Mage::app()->getWebsite($websiteId))->loadByCustomer($this->_customer);
     $this->_quoteItem = $this->_quote->getItemById($quoteItemId);
     if (!$this->_quoteItem) {
         Mage::throwException($this->__('Wrong quote item.'));
     }
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:21,代码来源:CartController.php

示例2: updateQuoteCatalogRedemptions

 /**
  * This function will attempt to update the quote catalog redemptions
  * data.  This should be triggered when the cart changes.
  * @param Mage_Sales_Model_Quote $quote
  * @param array $data[=null]
  * @param unknown_type $date[=null]
  * @param int $wId[=null]
  */
 public function updateQuoteCatalogRedemptions($quote, $data = null, $date = null, $wId = null)
 {
     try {
         if (!$quote) {
             return $this;
         }
         if ($data) {
             //@nelkaake -a 17/02/11: A save-on-quote event
             $is_on_quote_save = false;
             $items = $data;
         } else {
             $is_on_quote_save = true;
             $items = $quote->getAllItems();
         }
         if (!is_array($items)) {
             $items = array($items);
         }
         $refactorItems = array();
         foreach ($items as $key => $itemInfo) {
             if ($is_on_quote_save) {
                 $itemId = $itemInfo->getId();
                 $item = $itemInfo;
             } else {
                 $itemId = $key;
                 $item = $quote->getItemById($itemId);
             }
             if (!$itemId || !$item) {
                 continue;
             }
             if (!$is_on_quote_save) {
                 if (!empty($itemInfo['remove']) || isset($itemInfo['qty']) && $itemInfo['qty'] == '0') {
                     continue;
                 }
             }
             $product = $item->getProduct();
             $pId = $product->getId();
             $storeId = $product->getStoreId();
             if (!$date) {
                 $date = Mage::helper('rewards')->now();
             }
             if ($wId) {
                 $wId = Mage::app()->getStore($storeId)->getWebsiteId();
             }
             $gId = Mage::getSingleton('customer/session')->getCustomerGroupId();
             if ($gId !== 0 && empty($gId)) {
                 $gId = Mage_Customer_Model_Group::NOT_LOGGED_IN_ID;
             }
             if ($is_on_quote_save) {
                 $qty = $item->getQty();
             } else {
                 $qty = isset($itemInfo['qty']) ? (double) $itemInfo['qty'] : false;
             }
             // Since the cart has changed, reset our before-redemptions value and let Sweet Tooth recalculate the discount amount.
             Mage::getSingleton('rewards/redeem')->resetBeforeDiscount($item);
             $refactorItems[] = $item;
         }
         Mage::getSingleton('rewards/redeem')->refactorRedemptions($refactorItems);
     } catch (Exception $e) {
         Mage::logException($e);
         Mage::helper('rewards')->log($e->getMessage());
         Mage::helper('rewards')->log($e);
         die($e->getMessage());
     }
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:72,代码来源:Observer.php

示例3: saveOldOrderItems

 /**
  * Save changed order products
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Mage_Sales_Model_Order $order
  * @param                        $changes
  * @return $this
  */
 public function saveOldOrderItems(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order, $changes)
 {
     foreach ($changes as $itemId => $params) {
         $quoteItem = $quote->getItemById($itemId);
         $orderItem = $order->getItemByQuoteItemId($itemId);
         if (!$orderItem) {
             continue;
         }
         $qtyToRefund = $orderItem->getQtyToRefund();
         if ($orderItem->getProductType() == 'bundle') {
             $qtyToRefund = $orderItem->getQtyInvoiced() - $orderItem->getQtyRefunded();
         }
         $orderItemQty = $qtyToRefund + $orderItem->getQtyToCancel();
         if (isset($params['action']) && $params['action'] == 'remove' || isset($params['qty']) && $params['qty'] < 1) {
             $this->returnOrderItem($order, $orderItem);
             $orderItem->setSubtotal(0)->setBaseSubtotal(0)->setTaxAmount(0)->setBaseTaxAmount(0)->setTaxPercent(0)->setDiscountAmount(0)->setBaseDiscountAmount(0)->setRowTotal(0)->setBaseRowTotal(0);
             continue;
         }
         $origQtyOrdered = $orderItem->getQtyOrdered();
         $orderItem = $this->getConvertor()->itemToOrderItem($quoteItem, $orderItem);
         if (isset($params['qty']) && $params['qty'] != $orderItemQty) {
             $qtyDiff = $params['qty'] - $orderItemQty;
             if ($params['qty'] < $orderItemQty) {
                 $qtyToRemove = $orderItemQty - $params['qty'];
                 $this->returnOrderItem($order, $orderItem, $qtyToRemove);
                 $orderItem->setQtyOrdered($origQtyOrdered);
             } else {
                 $orderItem->setQtyOrdered($origQtyOrdered + $qtyDiff);
             }
             if ($orderItem->getProductType() == 'bundle') {
                 foreach ($quote->getAllItems() as $childQuoteItem) {
                     if ($childQuoteItem->getParentItemId() != $quoteItem->getId()) {
                         continue;
                     }
                     $childQuoteItem->save();
                     $childOrderItem = $order->getItemByQuoteItemId($childQuoteItem->getId());
                     $childOrderItem->setParentItem($orderItem);
                     $origChildQtyOrdered = $childOrderItem->getQtyOrdered();
                     $childOrderItem = $this->getConvertor()->itemToOrderItem($childQuoteItem, $childOrderItem);
                     //                        Mage::helper('core')->copyFieldset('sales_convert_quote_item', 'to_order_item', $childQuoteItem, $childOrderItem);
                     if ($params['qty'] < $orderItemQty) {
                         $qtyToRemove = $origChildQtyOrdered - $childOrderItem->getQtyOrdered() - $childOrderItem->getQtyCanceled() - $childOrderItem->getQtyRefunded();
                         $this->returnOrderItem($order, $childOrderItem, $qtyToRemove);
                         $childOrderItem->setQtyOrdered($origChildQtyOrdered);
                     } else {
                         $childQtyDiff = $qtyDiff * $childQuoteItem->getQty();
                         $childOrderItem->setQtyOrdered($origChildQtyOrdered + $childQtyDiff);
                     }
                     $childOrderItem->save();
                     $this->_savedOrderItems[] = $childOrderItem->getItemId();
                 }
             }
         }
         // Check Qty & Price changes
         $itemChange = array('name' => $orderItem->getName(), 'qty_before' => $orderItemQty, 'qty_after' => $orderItem->getQtyToRefund() + $orderItem->getQtyToCancel(), 'price_before' => $orderItem->getOrigData('price'), 'price_after' => $orderItem->getPrice());
         // Check Discount changes
         if (isset($params['use_discount']) && $params['use_discount'] == 1 && $quoteItem->getOrigData('discount_amount') == 0 && $quoteItem->getData('discount_amount') > 0) {
             $itemChange['discount'] = 1;
         } elseif ($quoteItem->getData('discount_amount') < 0.001 && $quoteItem->getOrigData('discount_amount') > 0) {
             $itemChange['discount'] = -1;
         }
         // Add item changes to log
         if ($itemChange['qty_before'] != $itemChange['qty_after'] || $itemChange['price_before'] != $itemChange['price_after'] || isset($itemChange['discount'])) {
             $this->getLogModel()->addItemChange($orderItem->getId(), $itemChange);
         }
         $quoteItem->save();
         $orderItem->save();
         $this->_savedOrderItems[] = $orderItem->getItemId();
     }
     return $this;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:79,代码来源:Edit.php

示例4: loadItem

 /**
  * @param Mage_Sales_Model_Quote $quote
  * @param int                    $id
  *
  * @return Mage_Sales_Model_Quote_Item
  *
  * @throws Exception
  */
 protected function loadItem(Mage_Sales_Model_Quote $quote, $id)
 {
     $id = intval($id);
     if (!$id) {
         $this->_critical('Not Found', Mage_Api2_Model_Server::HTTP_NOT_FOUND);
     }
     /** @var Mage_Sales_Model_Quote_Item $item */
     $item = $quote->getItemById($id);
     if (!$item || $item->isDeleted() || $item->getParentItemId()) {
         $this->_critical('Not Found', Mage_Api2_Model_Server::HTTP_NOT_FOUND);
     }
     return $item;
 }
开发者ID:aoepeople,项目名称:aoe_cartapi,代码行数:21,代码来源:Item.php

示例5: updateItems

 /**
  * Apply updated order items to quote
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param $data
  * @return $this
  */
 public function updateItems(Mage_Sales_Model_Quote $quote, $data)
 {
     foreach ($data as $itemId => $params) {
         $quoteItem = $quote->getItemById($itemId);
         if (!$quoteItem) {
             $this->addNewItems($quote, array($itemId => $params));
             $quoteItem = $quote->getItemById($itemId);
             if (!$quoteItem) {
                 continue;
             }
         }
         if (isset($params['action']) && $params['action'] == 'remove' || isset($params['qty']) && $params['qty'] < 1) {
             $quote->removeItem($itemId);
             continue;
         }
         if (isset($params['qty'])) {
             $quoteItem->setQty($params['qty']);
         }
         if (isset($params['custom_price']) && $params['custom_price'] > 0) {
             $quoteItem->setCustomPrice((double) $params['custom_price']);
             $quoteItem->setOriginalCustomPrice((double) $params['custom_price']);
         }
         $noDiscount = !isset($params['use_discount']);
         $quoteItem->setNoDiscount($noDiscount);
         $quoteItem->save();
     }
     return $this;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:35,代码来源:Quote.php


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