You are here

function uc_order_load in Ubercart 6.2

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

Load an order from the database.

38 calls to uc_order_load()
hook_calculate_tax in docs/hooks.php
Calculates tax line items for an order.
test_gateway_charge in payment/uc_credit/test_gateway.module
Callback function to perform the charge operation.
UbercartCartCheckoutTestCase::testCheckoutRoleAssignment in uc_cart/uc_cart.test
UbercartTestHelper::checkout in uc_store/uc_store.test
Executes the checkout process.
uc_2checkout_complete in payment/uc_2checkout/uc_2checkout.pages.inc
@file 2checkout menu items.

... See full list

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

File

uc_order/uc_order.module, line 1186

Code

function uc_order_load($order_id) {
  if (is_null($order_id) || $order_id < 1) {
    return FALSE;
  }
  $result = db_query("SELECT * FROM {uc_orders} WHERE order_id = %d", $order_id);
  $order = db_fetch_object($result);
  if ($order == FALSE) {
    return FALSE;
  }
  $order->data = unserialize($order->data);
  $result = db_query("SELECT * FROM {uc_order_products} WHERE order_id = %d ORDER BY order_product_id", $order_id);
  $order->products = array();
  while ($product = db_fetch_object($result)) {
    $product->data = unserialize($product->data);
    $product->order_uid = $order->uid;
    $order->products[] = $product;
  }
  uc_order_module_invoke('load', $order, NULL);

  // Load line items... has to be last after everything has been loaded.
  $order->line_items = uc_order_load_line_items($order, TRUE);

  // Merge it with the defaultish line items.
  $order->line_items = array_merge($order->line_items, uc_order_load_line_items($order, FALSE));
  usort($order->line_items, 'uc_weight_sort');

  // Make sure the total still matches up...
  if (($total = uc_order_get_total($order)) !== $order->order_total) {
    db_query("UPDATE {uc_orders} SET order_total = %f WHERE order_id = %d", $total, $order->order_id);
    $order->order_total = $total;
  }
  if (($count = uc_order_get_product_count($order)) !== $order->product_count) {
    db_query("UPDATE {uc_orders} SET product_count = %d WHERE order_id = %d", $count, $order->order_id);
    $order->product_count = $count;
  }
  return $order;
}