function uc_order_log_changes in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_order/uc_order.module \uc_order_log_changes()
- 6.2 uc_order/uc_order.module \uc_order_log_changes()
Logs changes made to an order.
Parameters
$order_id: The ID of the order that was changed.
$changes: An array of changes. Two formats are allowed:
- keys: Keys being the name of the field changed and the values being associative arrays with the keys 'old' and 'new' to represent the old and new values of the field. These will be converted into a changed message.
- string: A pre-formatted string describing the change. This is useful for logging details like payments.
Return value
TRUE or FALSE depending on whether or not changes were logged.
8 calls to uc_order_log_changes()
- uc_order_edit_form_submit in uc_order/
uc_order.admin.inc - Form submission handler for uc_order_edit_form().
- uc_order_edit_products_add in uc_order/
uc_order.order_pane.inc - Form submit callback: add a product to an order.
- uc_order_edit_products_add_blank in uc_order/
uc_order.order_pane.inc - Form submit callback: add a blank line product to an order.
- uc_order_mail_invoice_form_submit in uc_order/
uc_order.admin.inc - Form submission handler for uc_order_mail_invoice_form().
- uc_order_update_status in uc_order/
uc_order.module - Updates an order's status as long as no one objects.
File
- uc_order/
uc_order.module, line 1568
Code
function uc_order_log_changes($order_id, $changes) {
global $user;
if (count($changes) == 0) {
return FALSE;
}
foreach ($changes as $key => $value) {
if (is_array($value)) {
$items[] = t('@key changed from %old to %new.', array(
'@key' => $key,
'%old' => $value['old'],
'%new' => $value['new'],
));
}
elseif (is_string($value)) {
$items[] = $value;
}
}
db_insert('uc_order_log')
->fields(array(
'order_id' => $order_id,
'uid' => $user->uid,
'changes' => theme('item_list', array(
'items' => $items,
)),
'created' => REQUEST_TIME,
))
->execute();
return TRUE;
}