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


PHP Quote::collectTotals方法代码示例

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


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

示例1: place

 /**
  * Place the order when customer returned from PayPal until this moment all quote data must be valid.
  *
  * @param string $token
  * @param string|null $shippingMethodCode
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function place($token, $shippingMethodCode = null)
 {
     if ($shippingMethodCode) {
         $this->updateShippingMethod($shippingMethodCode);
     }
     $isNewCustomer = false;
     switch ($this->getCheckoutMethod()) {
         case \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST:
             $this->_prepareGuestQuote();
             break;
         case \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER:
             $this->_prepareNewCustomerQuote();
             $isNewCustomer = true;
             break;
         default:
             $this->_prepareCustomerQuote();
             break;
     }
     $this->_ignoreAddressValidation();
     $this->_quote->collectTotals();
     $order = $this->quoteManagement->submit($this->_quote);
     if ($isNewCustomer) {
         try {
             $this->_involveNewCustomer();
         } catch (\Exception $e) {
             $this->_logger->critical($e);
         }
     }
     if (!$order) {
         return;
     }
     // commence redirecting to finish payment, if paypal requires it
     if ($order->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_REDIRECT)) {
         $this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
     }
     switch ($order->getState()) {
         // even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
         case \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT:
             // TODO
             break;
             // regular placement, when everything is ok
         // regular placement, when everything is ok
         case \Magento\Sales\Model\Order::STATE_PROCESSING:
         case \Magento\Sales\Model\Order::STATE_COMPLETE:
         case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW:
             $this->orderSender->send($order);
             $this->_checkoutSession->start();
             break;
         default:
             break;
     }
     $this->_order = $order;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:62,代码来源:Checkout.php

示例2: buildQuote

 public function buildQuote()
 {
     try {
         // do not change invoke order
         // ---------------------------------------
         $this->initializeQuote();
         $this->initializeCustomer();
         $this->initializeAddresses();
         $this->configureStore();
         $this->configureTaxCalculation();
         $this->initializeCurrency();
         $this->initializeShippingMethodData();
         $this->initializeQuoteItems();
         $this->initializePaymentMethodData();
         $this->quote->collectTotals()->save();
         // todo investigate
         //            $this->prepareOrderNumber();
         // ---------------------------------------
     } catch (\Exception $e) {
         $this->quote->setIsActive(false)->save();
         throw $e;
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:23,代码来源:Quote.php

示例3: _assignProducts

 /**
  * Add products to items and item options
  *
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _assignProducts()
 {
     \Magento\Framework\Profiler::start('QUOTE:' . __METHOD__, ['group' => 'QUOTE', 'method' => __METHOD__]);
     $productIds = [];
     foreach ($this as $item) {
         $productIds[] = (int) $item->getProductId();
     }
     $this->_productIds = array_merge($this->_productIds, $productIds);
     $productCollection = $this->_productCollectionFactory->create()->setStoreId($this->getStoreId())->addIdFilter($this->_productIds)->addAttributeToSelect($this->_quoteConfig->getProductAttributes())->addOptionsToResult()->addStoreFilter()->addUrlRewrite()->addTierPriceData();
     $this->_eventManager->dispatch('prepare_catalog_product_collection_prices', ['collection' => $productCollection, 'store_id' => $this->getStoreId()]);
     $this->_eventManager->dispatch('sales_quote_item_collection_products_after_load', ['collection' => $productCollection]);
     $recollectQuote = false;
     foreach ($this as $item) {
         $product = $productCollection->getItemById($item->getProductId());
         if ($product) {
             $product->setCustomOptions([]);
             $qtyOptions = [];
             $optionProductIds = [];
             foreach ($item->getOptions() as $option) {
                 /**
                  * Call type-specific logic for product associated with quote item
                  */
                 $product->getTypeInstance()->assignProductToOption($productCollection->getItemById($option->getProductId()), $option, $product);
                 if (is_object($option->getProduct()) && $option->getProduct()->getId() != $product->getId()) {
                     $optionProductIds[$option->getProduct()->getId()] = $option->getProduct()->getId();
                 }
             }
             if ($optionProductIds) {
                 foreach ($optionProductIds as $optionProductId) {
                     $qtyOption = $item->getOptionByCode('product_qty_' . $optionProductId);
                     if ($qtyOption) {
                         $qtyOptions[$optionProductId] = $qtyOption;
                     }
                 }
             }
             $item->setQtyOptions($qtyOptions)->setProduct($product);
         } else {
             $item->isDeleted(true);
             $recollectQuote = true;
         }
         $item->checkData();
     }
     if ($recollectQuote && $this->_quote) {
         $this->_quote->collectTotals();
     }
     \Magento\Framework\Profiler::stop('QUOTE:' . __METHOD__);
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:54,代码来源:Collection.php


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