/** * Process a checkout and mark it as completed if successful. * Processing a checkout means creating an order object. * * @return \Shop\Models\Checkout */ public function createOrder($refresh = false) { if (!empty($this->__order) && empty($refresh)) { return $this; } // Convert the cart to an Order object $this->__order = \Shop\Models\Orders::fromCart($this->cart()); // Add payment details if applicable // Don't add the credit card number form the PaymentData to the cart, it shouldn't be stored in the order object in the DB $payment_data = (array) $this->paymentData(); \Dsc\ArrayHelper::clear($payment_data, 'card'); $this->__order->addPayment($payment_data); return $this; }
/** * Converts a cart to an Order * */ public function convertToOrder() { return \Shop\Models\Orders::fromCart($this); }