protected function recalculateShippingTotal(OrderInterface $order) { $grossAmount = $order->getShippingTotal()->getGrossAmount(); $taxRate = $order->getShippingMethod()->getTax()->getValue(); $currency = $order->getCurrency(); $orderTotal = $this->orderTotalFactory->createFromSpecifiedValues($grossAmount, $taxRate, $currency); $order->setShippingTotal($orderTotal); }
/** * 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']])); } } }
/** * {@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()); } }
/** * {@inheritdoc} */ public function visitOrder(OrderInterface $order) { $shippingMethod = $order->getShippingMethod(); $paymentMethods = $shippingMethod->getPaymentMethods(); if (false === $order->hasPaymentMethod() || false === $paymentMethods->contains($order->getPaymentMethod())) { $order->setPaymentMethod($paymentMethods->first()); } $modifier = $this->orderModifierProvider->getOrderModifier($order, 'payment_surcharge'); $modifier->setCurrency($order->getCurrency()); $modifier->setGrossAmount(0); $modifier->setNetAmount(0); $modifier->setTaxAmount(0); }
/** * Returns the collection of costs for current shipping method * * @param OrderInterface $order * * @return Collection */ private function getCurrentShippingMethodCostsCollection(OrderInterface $order) : Collection { return $this->methodProvider->getShippingMethodCosts($order->getShippingMethod(), new OrderContext($order)); }