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


PHP Quote::getAllVisibleItems方法代码示例

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


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

示例1: aroundAddItem

 public function aroundAddItem(\Magento\Quote\Model\Quote $subject, \Closure $proceed, \Magento\Quote\Model\Quote\Item $item)
 {
     $product = $item->getProduct();
     $attribute = $product->getResource()->getAttribute('enable_subscription');
     $value = null;
     if ($attribute) {
         $value = $attribute->getFrontend()->getValue($product);
     }
     $flag = 0;
     foreach ($subject->getAllVisibleItems() as $item) {
         $itemAttrValue = null;
         $itemProduct = $item->getProduct();
         $itemAttr = $itemProduct->getResource()->getAttribute('enable_subscription');
         if ($itemAttr) {
             if ($itemAttr->getFrontend()->getValue($itemProduct)) {
                 $flag = 1;
             }
         }
     }
     if ($value && $subject->hasItems() || $flag) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Nominal item can be purchased standalone only.'));
     }
     $proceed($item);
     return $subject;
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:25,代码来源:PluginRender.php

示例2: addQuote

 /**
  * Push quote contents to given tracker
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Henhed\Piwik\Model\Tracker $tracker
  * @return \Henhed\Piwik\Helper\Tracker
  */
 public function addQuote(Quote $quote, TrackerModel $tracker)
 {
     foreach ($quote->getAllVisibleItems() as $item) {
         $this->addQuoteItem($item, $tracker);
     }
     $this->addQuoteTotal($quote, $tracker);
     return $this;
 }
开发者ID:henkelund,项目名称:magento2-henhed-piwik,代码行数:15,代码来源:Tracker.php

示例3: merge

 /**
  * Merge quotes
  *
  * @param   Quote $quote
  * @return $this
  */
 public function merge(Quote $quote)
 {
     $this->_eventManager->dispatch($this->_eventPrefix . '_merge_before', [$this->_eventObject => $this, 'source' => $quote]);
     foreach ($quote->getAllVisibleItems() as $item) {
         $found = false;
         foreach ($this->getAllItems() as $quoteItem) {
             if ($quoteItem->compare($item)) {
                 $quoteItem->setQty($quoteItem->getQty() + $item->getQty());
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $newItem = clone $item;
             $this->addItem($newItem);
             if ($item->getHasChildren()) {
                 foreach ($item->getChildren() as $child) {
                     $newChild = clone $child;
                     $newChild->setParentItem($newItem);
                     $this->addItem($newChild);
                 }
             }
         }
     }
     /**
      * Init shipping and billing address if quote is new
      */
     if (!$this->getId()) {
         $this->getShippingAddress();
         $this->getBillingAddress();
     }
     if ($quote->getCouponCode()) {
         $this->setCouponCode($quote->getCouponCode());
     }
     $this->_eventManager->dispatch($this->_eventPrefix . '_merge_after', [$this->_eventObject => $this, 'source' => $quote]);
     return $this;
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:43,代码来源:Quote.php

示例4: submit

 /**
  * Delete quote item
  *
  * @param Quote $quote
  * @param array $orderData
  * @return \Magento\Framework\Model\AbstractExtensibleModel|\Magento\Sales\Api\Data\OrderInterface|object|void
  * @throws \Exception
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function submit(QuoteEntity $quote, $orderData = [])
 {
     if (!$quote->getAllVisibleItems()) {
         $quote->setIsActive(false);
         return;
     }
     return $this->submitQuote($quote, $orderData);
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:QuoteManagement.php

示例5: calculateQuoteChecksum

 /**
  * calculate quote checksum, it's verified after the return from the payment page
  * detect fraud attempts (cart modifications during checkout)
  *
  * @param \Magento\Quote\Model\Quote $quote
  *
  * @return string
  */
 public function calculateQuoteChecksum($quote)
 {
     $data = round($quote->getGrandTotal(), $this->getPrecision()) . $quote->getBaseCurrencyCode() . $quote->getCustomerEmail();
     foreach ($quote->getAllVisibleItems() as $item) {
         /** @var \Magento\Quote\Model\Quote\Item $item */
         $data .= $item->getSku();
         $data .= round($item->getRowTotal(), $this->getPrecision());
         $data .= round($item->getTaxAmount(), $this->getPrecision());
     }
     $address = $quote->getBillingAddress();
     $data .= $address->getName() . $address->getCompany() . $address->getCity() . $address->getPostcode() . $address->getCountryId() . $address->getCountry() . $address->getRegion() . $address->getStreetLine(1) . $address->getStreetLine(2);
     $address = $quote->getShippingAddress();
     $data .= $address->getName() . $address->getCompany() . $address->getCity() . $address->getPostcode() . $address->getCountryId() . $address->getCountry() . $address->getRegion() . $address->getStreetLine(1) . $address->getStreetLine(2);
     return hash_hmac('sha512', $data, $this->getConfigData('basicdata/secret'));
 }
开发者ID:wirecard,项目名称:magento2-wcp,代码行数:23,代码来源:Data.php

示例6: sendPaymentFailedEmail

 /**
  * Send email id payment was failed
  *
  * @param \Magento\Quote\Model\Quote $checkout
  * @param string $message
  * @param string $checkoutType
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     $this->inlineTranslation->suspend();
     $template = $this->scopeConfig->getValue('checkout/payment_failed/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
     $copyMethod = $this->scopeConfig->getValue('checkout/payment_failed/copy_method', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $bcc = [];
     if ($copyTo && $copyMethod == 'bcc') {
         $bcc = $copyTo;
     }
     $_receiver = $this->scopeConfig->getValue('checkout/payment_failed/receiver', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $sendTo = [['email' => $this->scopeConfig->getValue('trans_email/ident_' . $_receiver . '/email', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId()), 'name' => $this->scopeConfig->getValue('trans_email/ident_' . $_receiver . '/name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId())]];
     if ($copyTo && $copyMethod == 'copy') {
         foreach ($copyTo as $email) {
             $sendTo[] = ['email' => $email, 'name' => null];
         }
     }
     $shippingMethod = '';
     if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
         $data = explode('_', $shippingInfo);
         $shippingMethod = $data[0];
     }
     $paymentMethod = '';
     if ($paymentInfo = $checkout->getPayment()) {
         $paymentMethod = $paymentInfo->getMethod();
     }
     $items = '';
     foreach ($checkout->getAllVisibleItems() as $_item) {
         /* @var $_item \Magento\Quote\Model\Quote\Item */
         $items .= $_item->getProduct()->getName() . '  x ' . $_item->getQty() . '  ' . $checkout->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
     }
     $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
     foreach ($sendTo as $recipient) {
         $transport = $this->_transportBuilder->setTemplateIdentifier($template)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $checkout->getStoreId()])->setTemplateVars(['reason' => $message, 'checkoutType' => $checkoutType, 'dateAndTime' => $this->_localeDate->formatDateTime(new \DateTime(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'customerEmail' => $checkout->getCustomerEmail(), 'billingAddress' => $checkout->getBillingAddress(), 'shippingAddress' => $checkout->getShippingAddress(), 'shippingMethod' => $this->scopeConfig->getValue('carriers/' . $shippingMethod . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'paymentMethod' => $this->scopeConfig->getValue('payment/' . $paymentMethod . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'items' => nl2br($items), 'total' => $total])->setFrom($this->scopeConfig->getValue('checkout/payment_failed/identity', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId()))->addTo($recipient['email'], $recipient['name'])->addBcc($bcc)->getTransport();
         $transport->sendMessage();
     }
     $this->inlineTranslation->resume();
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:49,代码来源:Data.php

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