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


PHP Quote::getCouponCode方法代码示例

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


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

示例1: isFreeShipping

 /**
  * {@inheritDoc}
  */
 public function isFreeShipping(\Magento\Quote\Model\Quote $quote, $items)
 {
     /** @var \Magento\Quote\Api\Data\CartItemInterface[] $items */
     if (!count($items)) {
         return false;
     }
     $addressFreeShipping = true;
     $store = $this->storeManager->getStore($quote->getStoreId());
     $this->calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode());
     /** @var \Magento\Quote\Api\Data\CartItemInterface $item */
     foreach ($items as $item) {
         if ($item->getNoDiscount()) {
             $addressFreeShipping = false;
             $item->setFreeShipping(false);
             continue;
         }
         /** Child item discount we calculate for parent */
         if ($item->getParentItemId()) {
             continue;
         }
         $this->calculator->processFreeShipping($item);
         $itemFreeShipping = (bool) $item->getFreeShipping();
         $addressFreeShipping = $addressFreeShipping && $itemFreeShipping;
         /** Parent free shipping we apply to all children*/
         $this->applyToChildren($item, $itemFreeShipping);
     }
     return $addressFreeShipping;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:31,代码来源:FreeShipping.php

示例2: 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


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