/** * {@inheritdoc} */ public function createOrderFromCart(CartInterface $cart) { $order = $this->create(); $order->setCurrency($cart->getCurrency()); $order->setPaymentMethod($cart->getPaymentMethod()); $order->setShippingMethod($cart->getShippingMethodCost()->getShippingMethod()); $order->setBillingAddress($cart->getBillingAddress()); $order->setShippingAddress($cart->getShippingAddress()); $order->setContactDetails($cart->getContactDetails()); $order->setShop($cart->getShop()); $order->setSessionId($cart->getSessionId()); $order->setClient($cart->getClient()); $order->setCurrentStatus($cart->getPaymentMethod()->getDefaultOrderStatus()); $order->setCoupon($cart->getCoupon()); $this->prepareOrderProducts($cart, $order); $this->prepareShippingTotals($order, $cart->getShippingMethodCost()); $this->prepareProductTotals($order, $cart); return $order; }
/** * @param CartInterface $cart * * @return \WellCommerce\Bundle\OrderBundle\Entity\OrderInterface */ public function prepareOrderFromCart(CartInterface $cart) { $order = $this->initResource(); $order->setCurrency($cart->getCurrency()); $order->setPaymentMethod($cart->getPaymentMethod()); $order->setShippingMethod($cart->getShippingMethodCost()->getShippingMethod()); $order->setBillingAddress($cart->getBillingAddress()); $order->setShippingAddress($cart->getShippingAddress()); $order->setContactDetails($cart->getContactDetails()); $order->setShop($cart->getShop()); $order->setSessionId($cart->getSessionId()); $order->setClient($cart->getClient()); $order->setCurrentStatus($cart->getPaymentMethod()->getDefaultOrderStatus()); $order->setCoupon($cart->getCoupon()); $this->prepareOrderProducts($cart, $order); $this->prepareOrderShippingDetails($cart, $order); $this->eventDispatcher->dispatchOnPostOrderPrepared($order); return $order; }
/** * {@inheritdoc} */ public function visitCart(CartInterface $cart) { $paymentMethod = $cart->getPaymentMethod(); if (null !== $cart->getShippingMethodCost()) { $shippingMethod = $cart->getShippingMethodCost()->getShippingMethod(); $collection = $shippingMethod->getPaymentMethods(); if (null === $paymentMethod || !$collection->contains($paymentMethod)) { $defaultPaymentMethod = $shippingMethod->getPaymentMethods()->first(); $cart->setPaymentMethod($defaultPaymentMethod); } } }