Ubercart: How to update a variable on payment received or status completed

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


10 points

 I have ubercart 2 installed and I want to update a variable once the order has been paid (this means the order status is changed to complete or payment received. What is the best way of doing that in the code? What hook?



8 points

You are looking for following piece of code for sure:

<php>

 function hook_order($op, $order, $status) {

  switch ($op) {
    case 'update':

    if (($order->uid > 0) && ($order_user = user_load(array('uid' => $order->uid))) !== FALSE && ($status == 'completed' || $status == 'payment_received')) {

   // your code here
    break;
    }
  }
}

</php>

HadaclEaf's picture
Created by HadaclEaf

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.