コード例 #1
0
ファイル: SessionOrder.php プロジェクト: GregerA/livecart
 public static function setOrder(CustomerOrder $order)
 {
     $session = new Session();
     $session->set('CustomerOrder', $order->getID());
     $currency = $order->getCurrency();
     $currID = $currency->getID();
     $total = $order->getTotal();
     $orderArray = array('total' => array($currID => $total));
     $orderArray['formattedTotal'] = array($currID => $currency->getFormattedPrice($orderArray['total'][$currID]));
     $orderArray['basketCount'] = $order->getShoppingCartItemCount();
     $orderArray['currencyID'] = $currID;
     $isOrderable = $order->isOrderable();
     $orderArray['isOrderable'] = is_bool($isOrderable) ? $isOrderable : false;
     $items = array();
     foreach ($order->getPurchasedItems() as $item) {
         $items[] = $item->toArray();
     }
     $orderArray['items'] = new RuleOrderContainer($items);
     $orderArray['items']->setCoupons($order->getCoupons());
     $orderArray['items']->setTotal($total);
     $session->set('orderData', $orderArray);
 }
コード例 #2
0
 protected function getOrderValues(CustomerOrder $order)
 {
     $orderArray = array('total' => $order->getTotal());
     $currID = $order->getCurrency()->getID();
     $orderArray['currencyID'] = $currID;
     $orderArray['formattedTotal'] = $order->getCurrency()->getFormattedPrice($orderArray['total']);
     $orderArray['basketCount'] = $order->getShoppingCartItemCount();
     $isOrderable = isset($GLOBALS['isOrderable']) ? $GLOBALS['isOrderable'] : $order->isOrderable();
     $GLOBALS['isOrderable'] = $isOrderable;
     $orderArray['isOrderable'] = is_bool($isOrderable) ? $isOrderable : false;
     $orderArray['isShippingRequired'] = $order->isShippingRequired();
     return $orderArray;
 }
コード例 #3
0
 /**
  *	Determines if the necessary steps have been completed, so the order could be finalized
  *
  *	@return RedirectResponse
  *	@return ActionRedirectResponse
  *	@return false
  */
 protected function validateOrder(CustomerOrder $order, $step = 0)
 {
     if ($order->isFinalized->get()) {
         return false;
     }
     // no items in shopping cart
     if (!count($order->getShoppingCartItems())) {
         if ($this->request->isValueSet('return')) {
             return new RedirectResponse($this->router->createUrlFromRoute($this->request->get('return')));
         } else {
             return new ActionRedirectResponse('index', 'index');
         }
     }
     // order is not orderable (too few/many items, etc.)
     $isOrderable = $order->isOrderable(true, false);
     if (!$isOrderable || $isOrderable instanceof OrderException) {
         return new ActionRedirectResponse('order', 'index');
     }
     $valStep = $this->config->get('CHECKOUT_CUSTOM_FIELDS');
     $validateFields = 'CART_PAGE' == $valStep || 'BILLING_ADDRESS_STEP' == $valStep && self::STEP_ADDRESS <= $step || 'SHIPPING_ADDRESS_STEP' == $valStep && (self::STEP_ADDRESS == $step && 'shipping' == $this->request->get('step') || self::STEP_ADDRESS < $step) || 'SHIPPING_METHOD_STEP' == $valStep && self::STEP_SHIPPING < $step;
     $isOrderable = $order->isOrderable(true, $validateFields);
     // custom fields selected in cart page?
     if ('CART_PAGE' == $valStep && !$isOrderable) {
         return new ActionRedirectResponse('order', 'index');
     }
     // shipping address selected
     if ($step >= self::STEP_SHIPPING) {
         if (!$order->shippingAddress->get() && $order->isShippingRequired() && !$order->isMultiAddress->get() || !$order->billingAddress->get() || !$isOrderable) {
             return new ActionRedirectResponse('checkout', 'selectAddress', $this->request->get('step') ? array('step' => $this->request->get('step')) : null);
         }
     }
     // shipping method selected
     if ($step >= self::STEP_PAYMENT && $order->isShippingRequired() || !$isOrderable) {
         foreach ($order->getShipments() as $shipment) {
             if (!$shipment->getSelectedRate() && $shipment->isShippable()) {
                 return new ActionRedirectResponse('checkout', 'shipping');
             }
         }
     }
     return false;
 }