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


PHP Quote::setItemsCount方法代码示例

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


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

示例1: initializeQuoteItems

 private function initializeQuoteItems()
 {
     foreach ($this->proxyOrder->getItems() as $item) {
         $this->clearQuoteItemsCache();
         /** @var $quoteItemBuilder \Ess\M2ePro\Model\Magento\Quote\Item */
         $quoteItemBuilder = $this->modelFactory->getObject('Magento\\Quote\\Item', ['quote' => $this->quote, 'proxyItem' => $item]);
         $product = $quoteItemBuilder->getProduct();
         $request = $quoteItemBuilder->getRequest();
         // ---------------------------------------
         $productOriginalPrice = (double) $product->getPrice();
         $price = $item->getBasePrice();
         $product->setPrice($price);
         $product->setSpecialPrice($price);
         // ---------------------------------------
         // see Mage_Sales_Model_Observer::substractQtyFromQuotes
         $this->quote->setItemsCount($this->quote->getItemsCount() + 1);
         $this->quote->setItemsQty((double) $this->quote->getItemsQty() + $request->getQty());
         $result = $this->quote->addProduct($product, $request);
         if (is_string($result)) {
             throw new \Ess\M2ePro\Model\Exception($result);
         }
         $quoteItem = $this->quote->getItemByProduct($product);
         if ($quoteItem !== false) {
             $quoteItem->setStoreId($this->quote->getStoreId());
             $quoteItem->setOriginalCustomPrice($item->getPrice());
             $quoteItem->setOriginalPrice($productOriginalPrice);
             $quoteItem->setBaseOriginalPrice($productOriginalPrice);
             $quoteItem->setNoDiscount(1);
             $giftMessageId = $quoteItemBuilder->getGiftMessageId();
             if (!empty($giftMessageId)) {
                 $quoteItem->setGiftMessageId($giftMessageId);
             }
             $quoteItem->setAdditionalData($quoteItemBuilder->getAdditionalData($quoteItem));
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:36,代码来源:Quote.php

示例2: _collectItemsQtys

 /**
  * Collect items qty
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @return $this
  */
 protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote)
 {
     $quote->setItemsCount(0);
     $quote->setItemsQty(0);
     $quote->setVirtualItemsQty(0);
     foreach ($quote->getAllVisibleItems() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $children = $item->getChildren();
         if ($children && $item->isShipSeparately()) {
             foreach ($children as $child) {
                 if ($child->getProduct()->getIsVirtual()) {
                     $quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $child->getQty() * $item->getQty());
                 }
             }
         }
         if ($item->getProduct()->getIsVirtual()) {
             $quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $item->getQty());
         }
         $quote->setItemsCount($quote->getItemsCount() + 1);
         $quote->setItemsQty((double) $quote->getItemsQty() + $item->getQty());
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:31,代码来源:TotalsCollector.php


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