getStoreId(); $items = $shippingAssignment->getItems(); if (!$items) { return $this; } //Add shipping $shippingDataObject = $this->getShippingDataObject($shippingAssignment, $total, false); $baseShippingDataObject = $this->getShippingDataObject($shippingAssignment, $total, true); if ($shippingDataObject == null || $baseShippingDataObject == null) { return $this; } $quoteDetails = $this->prepareQuoteDetails($shippingAssignment, [$shippingDataObject]); $taxDetails = $this->taxCalculationService ->calculateTax($quoteDetails, $storeId); $baseQuoteDetails = $this->prepareQuoteDetails($shippingAssignment, [$baseShippingDataObject]); $baseTaxDetails = $this->taxCalculationService ->calculateTax($baseQuoteDetails, $storeId); $this->processShippingTaxInfo( $shippingAssignment, $total, $taxDetails->getItems()[self::ITEM_CODE_SHIPPING], $baseTaxDetails->getItems()[self::ITEM_CODE_SHIPPING] ); return $this; } /** * @param \Magento\Quote\Model\Quote $quote * @param Address\Total $total * @return array|null */ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total) { if ($total->getShippingInclTax()) { return [ 'code' => 'shipping', 'shipping_incl_tax' => $total->getShippingInclTax() ]; } return null; } }