You are here

function uc_order_delete in Ubercart 5

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

Deletes an order and tells other modules to do the same.

Parameters

$order_id: The ID of the order you wish to delete.

1 call to uc_order_delete()
uc_order_delete_confirm_form_submit in uc_order/uc_order.module

File

uc_order/uc_order.module, line 2602

Code

function uc_order_delete($order_id) {
  global $user;
  $order = uc_order_load($order_id);

  // Perform the operations if we're deleting a valid order.
  if ($order !== FALSE) {

    // Invoke hook_order() in enabled modules.
    foreach (module_implements('order') as $module) {
      $func = $module . '_order';
      $null = NULL;
      $func('delete', $order, $null, NULL);
    }

    // Delete data from the appropriate Ubercart order tables.
    db_query("DELETE FROM {uc_orders} WHERE order_id = %d", $order_id);
    db_query("DELETE FROM {uc_order_products} WHERE order_id = %d", $order_id);
    db_query("DELETE FROM {uc_order_comments} WHERE order_id = %d", $order_id);
    db_query("DELETE FROM {uc_order_admin_comments} WHERE order_id = %d", $order_id);
    db_query("DELETE FROM {uc_order_log} WHERE order_id = %d", $order_id);

    // Delete line items for the order.
    uc_order_delete_line_item($order_id, TRUE);

    // Log the action in the database.
    watchdog('uc_order', t('Order @order_id deleted by user @uid.', array(
      '@order_id' => $order_id,
      '@uid' => $user->uid,
    )));
  }
}