/** * Returns the shipping costs or null * * @return integer|null */ protected function getShippingCosts() { $isOrderNet = (bool) $this->Order->getNet() || (bool) $this->Order->getTaxFree(); if ($this->Order->getInvoiceShipping() >= 0) { if (!$isOrderNet) { return $this->Order->getInvoiceShipping(); } else { $taxRate = 0; // Use the highest tax rate if ($this->Order->getDispatch()->getTaxCalculation() == 0) { /** @var $detail Shopware\Models\Order\Detail */ foreach ($this->Order->getDetails() as $detail) { $taxRate = max($taxRate, $detail->getTaxRate()); } } else { $tax = Shopware()->Models()->find('Shopware\\Models\\Tax\\Tax', $this->Order->getDispatch()->getTaxCalculation()); if ($tax instanceof Shopware\Models\Tax\Tax) { $taxRate = $tax->getTax(); } } if (!$taxRate) { return $this->Order->getDispatch()->getTaxCalculation(); } else { return $this->Order->getInvoiceShipping() * ((100 + $taxRate) / 100); } } } return null; }