/** * Adds shipping options if available for order's shipping method * * @param OrderInterface $order * @param FormInterface $form */ private function addShippingOptions(OrderInterface $order, FormInterface $form) { if ($order->hasShippingMethod()) { $provider = $this->getOptionsProvider($order->getShippingMethod()); if ($provider instanceof ShippingMethodOptionsProviderInterface) { $form->addChild($this->getElement('select', ['name' => 'shippingMethodOption', 'label' => $this->trans('order.label.shipping_method'), 'options' => ['Wybierz sklep', 'Kraków', 'Warszawa']])); } } }
/** * Returns the costs collection for existing shipping method or all shipping methods if current method is not longer available * * @param OrderInterface $order * * @return Collection */ private function getCostCollection(OrderInterface $order) : Collection { if ($order->hasShippingMethod()) { $costs = $this->getCurrentShippingMethodCostsCollection($order); if ($costs->count() > 0) { return $costs; } } return $this->getShippingCostCollection($order); }
/** * {@inheritdoc} */ public function visitOrder(OrderInterface $order) { if (false === $order->hasShippingMethod()) { $order->setPaymentMethod(null); return; } $shippingMethod = $order->getShippingMethod(); $paymentMethods = $shippingMethod->getPaymentMethods(); if (false === $order->hasPaymentMethod() || false === $paymentMethods->contains($order->getPaymentMethod())) { $order->setPaymentMethod($paymentMethods->first()); } }