Ejemplo n.º 1
0
 /**
  * {@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;
 }
Ejemplo n.º 2
0
 /**
  * Customer group ID is set to quote object.
  */
 public function testGetCustomerGroupId()
 {
     /** Preconditions */
     $customerGroupId = 33;
     $this->quote->setCustomerGroupId($customerGroupId);
     /** SUT execution */
     $this->assertEquals($customerGroupId, $this->quote->getCustomerGroupId(), "Customer group ID is invalid");
 }