| @@ 410-419 (lines=10) @@ | ||
| 407 | ||
| 408 | public function calculateShippingCosts(Order $order) |
|
| 409 | { |
|
| 410 | if (!$order->deliveryAddress) { |
|
| 411 | return new Shipping([ |
|
| 412 | 'isShippable' => false, |
|
| 413 | 'messages' => [ |
|
| 414 | new Message([ |
|
| 415 | 'message' => 'Delivery address could not be empty' |
|
| 416 | ]) |
|
| 417 | ] |
|
| 418 | ]); |
|
| 419 | } |
|
| 420 | ||
| 421 | $countryIso3 = $order->deliveryAddress->country; |
|
| 422 | $country = $this->manager->getRepository('Shopware\Models\Country\Country')->findOneBy(['iso3' => $countryIso3]); |
|
| @@ 446-455 (lines=10) @@ | ||
| 443 | ||
| 444 | /* @var \Shopware\Models\Shop\Shop $shop */ |
|
| 445 | $shop = $this->manager->getRepository('Shopware\Models\Shop\Shop')->getActiveDefault(); |
|
| 446 | if (!$shop) { |
|
| 447 | return new Shipping([ |
|
| 448 | 'isShippable' => false, |
|
| 449 | 'messages' => [ |
|
| 450 | new Message([ |
|
| 451 | 'message' => 'Default shop could not be found' |
|
| 452 | ]) |
|
| 453 | ] |
|
| 454 | ]); |
|
| 455 | } |
|
| 456 | $shop->registerResources(Shopware()->Container()->get('bootstrap')); |
|
| 457 | ||
| 458 | /** @var /Enlight_Components_Session_Namespace $session */ |
|
| @@ 470-479 (lines=10) @@ | ||
| 467 | ||
| 468 | // todo: if products are not shippable with default shipping |
|
| 469 | // todo: do we need to check with other shipping methods |
|
| 470 | if (!$shipping) { |
|
| 471 | return new Shipping([ |
|
| 472 | 'isShippable' => false, |
|
| 473 | 'messages' => [ |
|
| 474 | new Message([ |
|
| 475 | 'message' => 'Default shipping could not be found' |
|
| 476 | ]) |
|
| 477 | ] |
|
| 478 | ]); |
|
| 479 | } |
|
| 480 | ||
| 481 | $session->offsetSet('sDispatch', $shipping->getId()); |
|
| 482 | ||
| @@ 504-513 (lines=10) @@ | ||
| 501 | } |
|
| 502 | ||
| 503 | $result = Shopware()->Modules()->Admin()->sGetPremiumShippingcosts(['id' => $country->getId()]); |
|
| 504 | if (!is_array($result)) { |
|
| 505 | return new Shipping([ |
|
| 506 | 'isShippable' => false, |
|
| 507 | 'messages' => [ |
|
| 508 | new Message([ |
|
| 509 | 'message' => 'Checkout is not possible at the moment possible reasons are: inactive product, removed product, etc.' |
|
| 510 | ]) |
|
| 511 | ] |
|
| 512 | ]); |
|
| 513 | } |
|
| 514 | ||
| 515 | $sql = 'DELETE FROM s_order_basket WHERE sessionID=?'; |
|
| 516 | Shopware()->Db()->executeQuery($sql, [ |
|