當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Quote::getAllItems方法代碼示例

本文整理匯總了PHP中Magento\Quote\Model\Quote::getAllItems方法的典型用法代碼示例。如果您正苦於以下問題:PHP Quote::getAllItems方法的具體用法?PHP Quote::getAllItems怎麽用?PHP Quote::getAllItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Quote\Model\Quote的用法示例。


在下文中一共展示了Quote::getAllItems方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAllItems

 /**
  * {@inheritdoc}
  */
 public function getAllItems()
 {
     $resultItems = [];
     foreach ($this->_salesModel->getAllItems() as $item) {
         $resultItems[] = new \Magento\Framework\DataObject(['parent_item' => $item->getParentItem(), 'name' => $item->getName(), 'qty' => (int) $item->getTotalQty(), 'price' => (double) $item->getBaseCalculationPrice(), 'original_item' => $item]);
     }
     return $resultItems;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:Quote.php

示例2: _getQuoteItemIdByProductId

 /**
  * Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @param mixed $productId
  * @return \Magento\Quote\Model\Quote\Item|null
  */
 private function _getQuoteItemIdByProductId(\Magento\Quote\Model\Quote $quote, $productId)
 {
     /** @var $quoteItems \Magento\Quote\Model\Quote\Item[] */
     $quoteItems = $quote->getAllItems();
     foreach ($quoteItems as $quoteItem) {
         if ($productId == $quoteItem->getProductId()) {
             return $quoteItem;
         }
     }
     return null;
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:18,代碼來源:CartTest.php

示例3: testGetAllItems

 public function testGetAllItems()
 {
     $itemOneMock = $this->getMockBuilder('Magento\\Quote\\Model\\Resource\\Quote\\Item')->setMethods(['isDeleted'])->disableOriginalConstructor()->getMock();
     $itemOneMock->expects($this->once())->method('isDeleted')->willReturn(false);
     $itemTwoMock = $this->getMockBuilder('Magento\\Quote\\Model\\Resource\\Quote\\Item')->setMethods(['isDeleted'])->disableOriginalConstructor()->getMock();
     $itemTwoMock->expects($this->once())->method('isDeleted')->willReturn(true);
     $items = [$itemOneMock, $itemTwoMock];
     $itemResult = [$itemOneMock];
     $this->quote->setData('items_collection', $items);
     $this->assertEquals($itemResult, $this->quote->getAllItems());
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:11,代碼來源:QuoteTest.php

示例4: resolveItems

 /**
  * @param Quote $quote
  * @return array
  */
 protected function resolveItems(QuoteEntity $quote)
 {
     $quoteItems = [];
     foreach ($quote->getAllItems() as $quoteItem) {
         /** @var \Magento\Quote\Model\Resource\Quote\Item $quoteItem */
         $quoteItems[$quoteItem->getId()] = $quoteItem;
     }
     $orderItems = [];
     foreach ($quoteItems as $quoteItem) {
         $parentItem = isset($orderItems[$quoteItem->getParentItemId()]) ? $orderItems[$quoteItem->getParentItemId()] : null;
         $orderItems[$quoteItem->getId()] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
     }
     return array_values($orderItems);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:18,代碼來源:QuoteManagement.php

示例5: getQuoteItemTotalsData

 /**
  * Fetch quote item totals data from quote
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @return array
  */
 protected function getQuoteItemTotalsData(\Magento\Quote\Model\Quote $quote)
 {
     $items = $quote->getAllItems();
     $item = array_shift($items);
     return [ItemTotals::KEY_ITEM_ID => $item->getItemId(), ItemTotals::KEY_PRICE => intval($item->getPrice()), ItemTotals::KEY_BASE_PRICE => intval($item->getBasePrice()), ItemTotals::KEY_QTY => $item->getQty(), ItemTotals::KEY_ROW_TOTAL => intval($item->getRowTotal()), ItemTotals::KEY_BASE_ROW_TOTAL => intval($item->getBaseRowTotal()), ItemTotals::KEY_ROW_TOTAL_WITH_DISCOUNT => intval($item->getRowTotalWithDiscount()), ItemTotals::KEY_TAX_AMOUNT => intval($item->getTaxAmount()), ItemTotals::KEY_BASE_TAX_AMOUNT => intval($item->getBaseTaxAmount()), ItemTotals::KEY_TAX_PERCENT => intval($item->getTaxPercent()), ItemTotals::KEY_DISCOUNT_AMOUNT => intval($item->getDiscountAmount()), ItemTotals::KEY_BASE_DISCOUNT_AMOUNT => intval($item->getBaseDiscountAmount()), ItemTotals::KEY_DISCOUNT_PERCENT => intval($item->getDiscountPercent()), ItemTotals::KEY_PRICE_INCL_TAX => intval($item->getPriceInclTax()), ItemTotals::KEY_BASE_PRICE_INCL_TAX => intval($item->getBasePriceInclTax()), ItemTotals::KEY_ROW_TOTAL_INCL_TAX => intval($item->getRowTotalInclTax()), ItemTotals::KEY_BASE_ROW_TOTAL_INCL_TAX => intval($item->getBaseRowTotalInclTax()), ItemTotals::KEY_WEEE_TAX_APPLIED_AMOUNT => $item->getWeeeTaxAppliedAmount(), ItemTotals::KEY_WEEE_TAX_APPLIED => $item->getWeeeTaxApplied(), ItemTotals::KEY_NAME => $item->getName()];
 }
開發者ID:kid17,項目名稱:magento2,代碼行數:12,代碼來源:CartTotalRepositoryTest.php

示例6: resolveItems

 /**
  * @param Quote $quote
  * @return array
  */
 protected function resolveItems(QuoteEntity $quote)
 {
     $quoteItems = $quote->getAllItems();
     for ($i = 0; $i < count($quoteItems) - 1; $i++) {
         for ($j = 0; $j < count($quoteItems) - $i - 1; $j++) {
             if ($quoteItems[$i]->getParentItemId() == $quoteItems[$j]->getId()) {
                 $tempItem = $quoteItems[$i];
                 $quoteItems[$i] = $quoteItems[$j];
                 $quoteItems[$j] = $tempItem;
             }
         }
     }
     $orderItems = [];
     foreach ($quoteItems as $quoteItem) {
         $parentItem = isset($orderItems[$quoteItem->getParentItemId()]) ? $orderItems[$quoteItem->getParentItemId()] : null;
         $orderItems[$quoteItem->getId()] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
     }
     return array_values($orderItems);
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:23,代碼來源:QuoteManagement.php

示例7: resolveItems

 /**
  * @param Quote $quote
  * @return array
  */
 protected function resolveItems(QuoteEntity $quote)
 {
     $quoteItems = $quote->getAllItems();
     $orderItems = [];
     foreach ($quoteItems as $quoteItem) {
         $parentItem = isset($orderItems[$quoteItem->getParentItemId()]) ? $orderItems[$quoteItem->getParentItemId()] : null;
         $orderItems[$quoteItem->getId()] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
     }
     return array_values($orderItems);
 }
開發者ID:kid17,項目名稱:magento2,代碼行數:14,代碼來源:QuoteManagement.php


注:本文中的Magento\Quote\Model\Quote::getAllItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。