/**
  * 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;
 }
Beispiel #2
0
 /**
  * @param Order $order
  * @return \Shopware\Models\Article\Detail[]
  */
 private function getProductsOfOrder(Order $order)
 {
     /**@var $repository \Shopware\Components\Model\ModelRepository*/
     $repository = $this->get('models')->getRepository('Shopware\\Models\\Article\\Detail');
     $products = [];
     foreach ($order->getDetails() as $detail) {
         /**@var $detail \Shopware\Models\Order\Detail*/
         if (!$this->isProductPosition($detail)) {
             continue;
         }
         $variant = $repository->findOneBy(['number' => $detail->getArticleNumber()]);
         $products[] = $variant;
     }
     return $products;
 }