当前位置: 首页>>代码示例>>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;未经允许,请勿转载。