Ubercart Conditional Actions - Publish Node Upon Successful Payment

My current project involved allowing visitors to apply for an apartment online. There is a small application fee to be paid for processing this application. I used UC Node Checkout to get this done. Basically it allows you to map a node type to an Ubercart product. When a user creates a node of that type, the specified product is added to the shopping cart and they can click off straight to PayPal to pay right away.

I setup the application content type to be unpublished by default but wanted it to be published upon successful payment.

I used http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart and http://drupal.org/node/376384 as a guide to pull it all together but the following code worked for me.

foreach ($order->products as $product) {
  $node = node_load($product->data['node_checkout_nid']);
  $node->status = 1;
  node_save($node);
}

Contact Me

Feel free to contact me.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.