Example #1
0
 /**
  * @return $this
  */
 protected function _initShipping()
 {
     $store = $this->getStore();
     $parent = $this->getParentBlock();
     $shipping = $parent->getTotal('shipping');
     if (!$shipping) {
         return $this;
     }
     if ($this->_config->displaySalesShippingBoth($store)) {
         $shipping = (double) $this->_source->getShippingAmount();
         $baseShipping = (double) $this->_source->getBaseShippingAmount();
         $shippingIncl = (double) $this->_source->getShippingInclTax();
         if (!$shippingIncl) {
             $shippingIncl = $shipping + (double) $this->_source->getShippingTaxAmount();
         }
         $baseShippingIncl = (double) $this->_source->getBaseShippingInclTax();
         if (!$baseShippingIncl) {
             $baseShippingIncl = $baseShipping + (double) $this->_source->getBaseShippingTaxAmount();
         }
         $totalExcl = new \Magento\Framework\DataObject(['code' => 'shipping', 'value' => $shipping, 'base_value' => $baseShipping, 'label' => __('Shipping & Handling (Excl.Tax)')]);
         $totalIncl = new \Magento\Framework\DataObject(['code' => 'shipping_incl', 'value' => $shippingIncl, 'base_value' => $baseShippingIncl, 'label' => __('Shipping & Handling (Incl.Tax)')]);
         $parent->addTotal($totalExcl, 'shipping');
         $parent->addTotal($totalIncl, 'shipping');
     } elseif ($this->_config->displaySalesShippingInclTax($store)) {
         $shippingIncl = $this->_source->getShippingInclTax();
         if (!$shippingIncl) {
             $shippingIncl = $this->_source->getShippingAmount() + $this->_source->getShippingTaxAmount();
         }
         $baseShippingIncl = $this->_source->getBaseShippingInclTax();
         if (!$baseShippingIncl) {
             $baseShippingIncl = $this->_source->getBaseShippingAmount() + $this->_source->getBaseShippingTaxAmount();
         }
         $total = $parent->getTotal('shipping');
         if ($total) {
             $total->setValue($shippingIncl);
             $total->setBaseValue($baseShippingIncl);
         }
     }
     return $this;
 }
 /**
  * Retrieve subtotal price include tax html formated content
  *
  * @param \Magento\Framework\DataObject $order
  * @return string
  */
 public function displayShippingPriceInclTax($order)
 {
     $shipping = $order->getShippingInclTax();
     if ($shipping) {
         $baseShipping = $order->getBaseShippingInclTax();
     } else {
         $shipping = $order->getShippingAmount() + $order->getShippingTaxAmount();
         $baseShipping = $order->getBaseShippingAmount() + $order->getBaseShippingTaxAmount();
     }
     return $this->displayPrices($baseShipping, $shipping, false, ' ');
 }