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

9 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?

Created by programmer 45 weeks 4 days ago
  Tags:

Answer(s):

1 point

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>

Created by HadaclEaf

Post your Answer

  • Lines and paragraphs break automatically.
  • 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 <% ... %>.
  • Links to specified hosts will have a rel="nofollow" added to them.

More information about formatting options