コード例 #1
0
ファイル: OrderController.php プロジェクト: ranjiva/Elmet
 /** * @codeCoverageIgnore */
 public function createAction()
 {
     $repository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainColour');
     $curtainColour = $repository->findOneById('2');
     $order = new Order();
     $order->setAmountPaid(113.25);
     $order->setBillingAddress("20 Sussex Gardens");
     $order->setBillingAddress2("Ancells Park");
     $order->setBillingName("R K Prasad");
     $order->setBillingPostcode("GU51 2TL");
     $order->setBillingTown("Fleet");
     $order->setDeliveryAddress("8 Southwood Close");
     $order->setDeliveryAddress2("Great Lever");
     $order->setDeliveryName("Ranjiva Prasad");
     $order->setDeliveryPostcode("BL3 2DJ");
     $order->setDeliveryTown("Bolton");
     $order->setEmail("*****@*****.**");
     $order->setFirstName("Ranjiva");
     $order->setLastName("Prasad");
     $order->setMobile("07769901335");
     $order->setNotes("Ring the Doorbell");
     $order->setOrderStatus("Pending");
     $order->setOrderTotal(106.75);
     $order->setDeliveryCharge(6.5);
     $order->setTelephone("01252 643872");
     $orderItem = new OrderItem();
     $orderItem->setColour($curtainColour->getName());
     $orderItem->setDescription("Curtains");
     $orderItem->setDropAlteration("18");
     $orderItem->setItemFilepath($curtainColour->getThumbnailFilepath());
     $orderItem->setName("Ranjiva");
     $orderItem->setPrice(100.25);
     $orderItem->setCurtainColour($curtainColour);
     $orderItem->setProductType("Curtain");
     $orderItem->setQuantity(10);
     $orderItem->setSize("120 X 90");
     $orderItem->setSubtotal(125.67);
     $orderItem->setOrder($order);
     $orderItem->setProductCategoryId($curtainColour->getId());
     $orderItems = $order->getOrderItems();
     $orderItems->add($orderItem);
     $em = $this->getDoctrine()->getEntityManager();
     $em->persist($order);
     $em->flush();
     $session = $this->getRequest()->getSession();
     $session->set('order', $order);
     return new Response('Created order id ' . $order->getId() . ' Created curtain order item id ' . $orderItem->getId());
 }
コード例 #2
0
 private function createOrderTracking($em, $email, $billingName, $postCode, $status)
 {
     $repository = $this->em->getRepository('ElmetSiteBundle:CurtainColour');
     $curtainColour = $repository->findOneById('2');
     $order = new Order();
     $order->setBillingAddress("20 Sussex Gardens");
     $order->setBillingAddress2("Ancells Park");
     $order->setBillingName($billingName);
     $order->setBillingPostcode($postCode);
     $order->setBillingTown("Fleet");
     $order->setDeliveryAddress("8 Southwood Close");
     $order->setDeliveryAddress2("Great Lever");
     $order->setDeliveryName("Ranjiva Prasad");
     $order->setDeliveryPostcode($postCode);
     $order->setDeliveryTown("Bolton");
     $order->setEmail($email);
     $order->setFirstName("Ranjiva");
     $order->setLastName("Prasad");
     $order->setMobile("07769901335");
     $order->setNotes("Ring the Doorbell");
     $order->setOrderStatus($status);
     $order->setTelephone("01252 643872");
     $orderItems = $order->getOrderItems();
     $orderItem = new OrderItem();
     $orderItem->setColour($curtainColour->getName());
     $orderItem->setDescription("Geneva Ready-made (Jacquard) Curtains");
     $orderItem->setItemFilepath($curtainColour->getThumbnailFilepath());
     $orderItem->setName("Ready-made Curtains (pair)");
     $orderItem->setPrice(100.25);
     $orderItem->setCurtainColour($curtainColour);
     $orderItem->setProductType("Curtain");
     $orderItem->setQuantity(1);
     $orderItem->setSize("52 X 90");
     $orderItem->setSubtotal(100.25);
     $orderItem->setProductCategoryId($curtainColour->getId());
     $orderItem->setOrder($order);
     $orderItems->add($orderItem);
     $order->updateOrderTotal();
     $orderTracking = new OrderTracking();
     $orderTracking->setOrder($order);
     $orderTracking->setTrackingStatus('Received');
     $em->persist($order);
     $em->persist($orderTracking);
     $em->flush();
     return $orderTracking;
 }