Function hook_order() in uc_order.module:
($op, &$arg1, $arg2)


An order in Ãœbercart represents a single transaction. Orders are created during the checkout process where they sit in the database with a status of In Checkout. When a customer completes checkout, the order's status gets updated to show that the sale has gone through. Once an order is created, and even during its creation, it may be acted on by any module to connect extra information to an order. Every time an action occurs to an order, hook_order() gets invoked to let your modules know what's happening and make stuff happen.

  • $op - The action being performed.
  • &$arg1 - This is the order object or a reference to it as noted below.
  • $arg2 - This is variable and will be specified in the table below.
$op Use
new Called when an order is created. $arg1 is a reference to the new order object, so modules may add to or modify the order at creation.
save When an order object is being saved, the hook gets invoked with this op to let other modules do any necessary saving. $arg1 is a reference to the order object.
load Called when an order is loaded after the order and product data has been loaded from the database. Passes $arg1 as the reference to the order object, so modules may add to or modify the order object when it's loaded.
submit When a sale is being completed and the customer has clicked the Submit order button from the checkout screen, the hook is invoked with this op. This gives modules a chance to determine whether or not the order should be allowed. An example use of this is the credit module attempting to process payments when an order is submitted and returning a failure message if the payment failed. To prevent an order from passing through, you must return an array resembling the following one with the failure message:
return array(array('pass' => FALSE, 'message' => t('We were unable to process your credit card.')));
can_update Called before an order's status is changed to make sure the order can be updated. $arg1 is the order object with the old order status ID ($arg1->order_status), and $arg2 is simply the new order status ID. Return FALSE to stop the update for some reason.
update Called when an order's status is changed. $arg1 is the order object with the old order status ID ($arg1->order_status), and $arg2 is the new order status ID.
can_delete Called before an order is deleted to verify that the order may be deleted. Returning FALSE will prevent a delete from happening. (For example, the payment module returns FALSE by default when an order has already received payments.)
delete Called when an order is deleted and before the rest of the order information is removed from the database. Passes $arg1 as the order object to let your module clean up it's tables.
total Called when the total for an order is being calculated after the total of the products has been added. Passes $arg1 as the order object. Expects in return a value (positive or negative) by which to modify the order total.
Return value:
No return value.

function uc_payment_order($op, &$arg1, $arg2) {
  switch (
$op) {
// Do something to save payment info!