function uc_order_update_status in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_order/uc_order.module \uc_order_update_status()
- 7.3 uc_order/uc_order.module \uc_order_update_status()
Update an order's status as long as no one objects.
Parameters
$order_id: The ID of the order to be updated.
$status: The new status ID we want to move the order to.
Return value
TRUE or FALSE depending on the success of the update.
5 calls to uc_order_update_status()
- uc_cart_complete_sale in uc_cart/
uc_cart.module - Completes a sale, including adjusting order status and creating user account.
- uc_cybersource_hop_post in payment/
uc_cybersource/ uc_cybersource.module - uc_order_action_update_status in uc_order/
uc_order.ca.inc - Update an order's status.
- uc_order_view_update_form_submit in uc_order/
uc_order.order_pane.inc - Form submit handler for uc_order_view_update_form().
- uc_paypal_ipn in payment/
uc_paypal/ uc_paypal.pages.inc - Process Instant Payment Notifiations from PayPal.
2 string references to 'uc_order_update_status'
- uc_payment_ca_predicate in payment/
uc_payment/ uc_payment.ca.inc - Implements hook_ca_predicate().
- _ca_convert_actions in ca/
ca.admin.inc - Helper function for converting Ubercart's Workflow-ng actions.
File
- uc_order/
uc_order.module, line 1366
Code
function uc_order_update_status($order_id, $status) {
// Return FALSE if an invalid $status is specified.
if (uc_order_status_data($status, 'id') == NULL) {
return FALSE;
}
$order = uc_order_load($order_id);
// Attempt the update if the order exists.
if ($order !== FALSE) {
// Return TRUE if the order status is already set.
if ($order->order_status == $status) {
return TRUE;
}
// Return FALSE if any module says the update is not good to go.
foreach (module_list() as $module) {
$function = $module . '_order';
// $order must be passed by reference.
if (function_exists($function) && $function('can_update', $order, $status) === FALSE) {
return FALSE;
}
}
// Otherwise perform the update and log the changes.
db_query("UPDATE {uc_orders} SET order_status = '%s', modified = %d WHERE order_id = %d", $status, time(), $order_id);
uc_order_module_invoke('update', $order, $status);
$change = array(
t('Order status') => array(
'old' => uc_order_status_data($order->order_status, 'title'),
'new' => uc_order_status_data($status, 'title'),
),
);
uc_order_log_changes($order->order_id, $change);
$updated = uc_order_load($order_id);
ca_pull_trigger('uc_order_status_update', $order, $updated);
return TRUE;
}
// Return FALSE if the order didn't exist.
return FALSE;
}