예제 #1
0
 /**
  * @param ObjectManager $om
  * @param Store         $store
  * @param Integration   $integration
  * @param Customer      $customer
  * @param string        $status
  * @param Cart          $cart
  * @param string        $paymentMethod
  * @param string        $paymentMethodDetails
  * @param mixed         $origin
  *
  * @return Order
  */
 protected function generateOrder(ObjectManager $om, Store $store, Integration $integration, Customer $customer, $status, Cart $cart, $paymentMethod, $paymentMethodDetails, $origin)
 {
     $order = new Order();
     $order->setOrganization($this->organization);
     $order->setChannel($integration);
     $order->setCustomer($customer);
     $order->setOwner($customer->getOwner());
     $order->setStatus($status);
     $order->setStore($store);
     $order->setStoreName($store->getName());
     $order->setIsGuest(0);
     $order->setIncrementId((string) $origin);
     $order->setCreatedAt(new \DateTime('now'));
     $order->setUpdatedAt(new \DateTime('now'));
     $order->setCart($cart);
     $order->setCurrency($cart->getBaseCurrencyCode());
     $order->setTotalAmount($cart->getGrandTotal());
     $order->setTotalInvoicedAmount($cart->getGrandTotal());
     $order->setDataChannel($this->dataChannel);
     if ($status == 'Completed') {
         $order->setTotalPaidAmount($cart->getGrandTotal());
     }
     $order->setSubtotalAmount($cart->getSubTotal());
     $order->setShippingAmount(rand(5, 10));
     $order->setPaymentMethod($paymentMethod);
     $order->setPaymentDetails($paymentMethodDetails);
     $order->setShippingMethod('flatrate_flatrate');
     $address = $this->getOrderAddress($om);
     $order->addAddress($address);
     $address->setOwner($order);
     $om->persist($order);
     return $order;
 }
예제 #2
0
 /**
  * @param Customer|object|null $customer
  * @param float $subtotal
  * @param string $status
  * @return Order
  */
 protected function createOrder($customer = null, $subtotal = 10.1, $status = 'complete')
 {
     $order = new Order();
     $order->setId(1);
     if ($customer) {
         $order->setCustomer($customer);
     }
     $order->setSubtotalAmount($subtotal);
     $order->setStatus($status);
     return $order;
 }