function add() { if (isset($_POST['products'])) { unset($_SESSION['Basket']); unset($_SESSION['Shipping']); $shipping = new StdClass(); $shipping->first_name = $_POST['shipping']['first_name']; $shipping->last_name = $_POST['shipping']['last_name']; $shipping->address1 = $_POST['shipping']['address1']; $shipping->address2 = $_POST['shipping']['address2']; $shipping->city = $_POST['shipping']['city']; $shipping->state = $_POST['shipping']['state']; $shipping->zip = $_POST['shipping']['zip']; $shipping->country = $_POST['shipping']['country']; $shipping->phone = $_POST['shipping']['phone']; $shipping->email = $_POST['shipping']['email']; $shipping->method = $_POST['shipping']['method']; $shipping->company = $_POST['shipping']['company']; $billing = new StdClass(); $billing->first_name = $_POST['billing']['first_name']; $billing->last_name = $_POST['billing']['last_name']; $billing->address1 = $_POST['billing']['address1']; $billing->address2 = $_POST['billing']['address2']; $billing->city = $_POST['billing']['city']; $billing->state = $_POST['billing']['state']; $billing->zip = $_POST['billing']['zip']; $billing->country = $_POST['billing']['country']; $billing->phone = $_POST['billing']['phone']; $billing->email = $_POST['billing']['email']; $billing->company = $_POST['billing']['company']; $payment = new StdClass(); if (isset($_POST['order']['cc']) && $_POST['order']['cc'] == 'on') { $payment->method = $_POST['card']['type'] . ' Card'; $payment->card = new StdClass(); $payment->card->name = $_POST['card']['name']; $payment->card->type = $_POST['card']['type']; $payment->card->card_num = $_POST['card']['number']; $payment->card->exp_date = $_POST['card']['expdate_month'] . $_POST['card']['expdate_year']; $payment->card->cvv = $_POST['card']['verification']; } else { $payment->method = 'Backend creation with no card data'; } $cart =& $this->getProducts(); $customer = new StdClass(); $customer->ip = '0.0.0.0'; $customer->id = (int) $_POST['order']['user']; $order = new Order(); $order->shipping = $shipping; $order->billing = $billing; $order->payment = $payment; $order->customer = $customer; $order->comment = $_POST['order']['comment']; $order->basket = $cart; if (isset($_POST['order']['discount']) && $_POST['order']['discount'] != '') { $order->setDiscount((int) $_POST['order']['discount']); } try { if (isset($payment->card)) { $order->pay('Authorize'); } $id = $order->create(); $order->confirm(); //$order->sendConfirmation($id); $cart->clear(); url::redirect('/orders'); } catch (Exception $e) { $this->error = $e->getMessage(); } } $view = new View('admin'); $view->header = new View('header'); $view->content = new View('order_add'); $view->footer = new View('footer'); $view->header->title = 'Order >> Add'; // string for variable $title in view header.php $view->footer->copyright = 'Copyright'; // string for variable $copyright in view footer.php $view->render(TRUE); }