/** * {@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); }