Author: Adam Piotrowski (adam@wellcommerce.org)
 /**
  * {@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);
 }
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     if ($order->hasCoupon()) {
         $coupon = $order->getCoupon();
         $modifierValue = $this->calculateCouponModifier($coupon, $order);
         $modifier = $this->orderModifierProvider->getOrderModifier($order, 'coupon_discount');
         $modifier->setCurrency($order->getCurrency());
         $modifier->setGrossAmount($order->getProductTotal()->getGrossPrice() * $modifierValue);
         $modifier->setNetAmount($order->getProductTotal()->getNetPrice() * $modifierValue);
         $modifier->setTaxAmount($order->getProductTotal()->getTaxAmount() * $modifierValue);
     } else {
         $order->removeModifier('coupon_discount');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     $costs = $this->getCostCollection($order);
     if (0 === $costs->count()) {
         throw new \Exception('There are no possible shipping methods for cart');
     }
     $cost = $costs->first();
     $modifier = $this->modifierProvider->getOrderModifier($order, 'shipping_cost');
     $modifier->setCurrency($cost->getShippingMethod()->getCurrency()->getCode());
     $modifier->setGrossAmount($cost->getCost()->getGrossAmount());
     $modifier->setNetAmount($cost->getCost()->getNetAmount());
     $modifier->setTaxAmount($cost->getCost()->getTaxAmount());
     $order->setShippingMethod($cost->getShippingMethod());
 }
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     $costs = $this->getCostCollection($order);
     if (0 === $costs->count()) {
         $order->removeModifier('shipping_cost');
         $order->setShippingMethod(null);
         return;
     }
     $cost = $costs->first();
     $modifier = $this->modifierProvider->getOrderModifier($order, 'shipping_cost');
     $modifier->setCurrency($cost->getShippingMethod()->getCurrency()->getCode());
     $modifier->setGrossAmount($cost->getCost()->getGrossAmount());
     $modifier->setNetAmount($cost->getCost()->getNetAmount());
     $modifier->setTaxAmount($cost->getCost()->getTaxAmount());
     $order->setShippingMethod($cost->getShippingMethod());
 }