You are here

function uc_order_save in Ubercart 6.2

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

Save an order to the database.

9 calls to uc_order_save()
UbercartCartCheckoutTestCase::createOrder in uc_cart/uc_cart.test
Creates a new order.
UbercartCreditCardTestCase::createOrder in payment/uc_credit/uc_credit.test
Helper function. Creates a new order.
UbercartOrderTestCase::ucCreateOrder in uc_order/uc_order.test
uc_2checkout_complete in payment/uc_2checkout/uc_2checkout.pages.inc
@file 2checkout menu items.
uc_cart_checkout_form_validate in uc_cart/uc_cart.pages.inc
Form validation for uc_cart_checkout_form().

... See full list

1 string reference to 'uc_order_save'
uc_order_ca_entity in uc_order/uc_order.ca.inc
Implements hook_ca_entity().

File

uc_order/uc_order.module, line 1123

Code

function uc_order_save($order) {
  if (is_null($order->order_id) || intval($order->order_id) == 0) {
    return FALSE;
  }
  uc_order_module_invoke('presave', $order, NULL);
  $order->order_total = uc_order_get_total($order);
  $order->product_count = uc_order_get_product_count($order);
  if (is_null($order->delivery_country) || $order->delivery_country == 0) {
    $order->delivery_country = variable_get('uc_store_country', 840);
  }
  if (is_null($order->billing_country) || $order->billing_country == 0) {
    $order->billing_country = variable_get('uc_store_country', 840);
  }
  $order->host = ip_address();
  $order->modified = time();
  drupal_write_record('uc_orders', $order, 'order_id');
  if (isset($order->products) && is_array($order->products)) {
    foreach ($order->products as $product) {
      drupal_alter('order_product', $product, $order);
      uc_order_product_save($order->order_id, $product);
    }
  }
  uc_order_module_invoke('save', $order, NULL);
}