You are here

function uc_order_new in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_order/uc_order.module \uc_order_new()
  2. 7.3 uc_order/uc_order.module \uc_order_new()

Generate a new order for user $uid.

4 calls to uc_order_new()
uc_cart_checkout_form_validate in uc_cart/uc_cart.module
uc_importer_orders in uc_importer/uc_importer.module
Specific order importer for a certain osCommerce site.
uc_order_create_form_submit in uc_order/uc_order.module
uc_paypal_ec_form_submit in payment/uc_paypal/uc_paypal.module

File

uc_order/uc_order.module, line 2453

Code

function uc_order_new($uid = 0, $state = 'in_checkout') {
  $order = new stdClass();
  if ($uid > 0) {
    $user = user_load(array(
      'uid' => $uid,
    ));
    $email = $user->mail;
  }
  $order->order_id = db_next_id('{uc_orders}_order_id');
  $order->uid = $uid;
  $order->order_status = uc_order_state_default($state);
  $order->primary_email = $email;
  db_query("INSERT INTO {uc_orders} (order_id, uid, order_status, order_total, " . "primary_email, delivery_first_name, delivery_last_name, delivery_phone, " . "delivery_company, delivery_street1, delivery_street2, delivery_city, " . "delivery_zone, delivery_postal_code, delivery_country, billing_first_name, " . "billing_last_name, billing_phone, billing_company, billing_street1, " . "billing_street2, billing_city, billing_zone, billing_postal_code, " . "billing_country, payment_method, data, created, modified) VALUES " . "(%d, %d, '%s', 0, '%s', '', '', '', '', '', '', '', 0, '', 0, '', " . "'', '', '', '', '', '', 0, 0, 0, '', '', %d, %d)", $order->order_id, $uid, $order->order_status, $email, time(), time());
  module_invoke_all('order', 'new', $order, NULL);
  return $order;
}