Wednesday, August 18, 2010

Doing something after a customer has bought a product in Ubercart

To do something in DRUPAL after a customer has bought a product in Ubercart you can use Ubercart's Conditional Action feature.

We were trying to figure out how to:
  • update a interger field (counter) in a node
  • call a print/email function
  • send a user to a certain DRUPAL page
once they bought a product through Ubercart. However we needed to be sure that the user actually bought and paid for the product and that the payment was successful.

The simplest way for us was to create a predicate in Ubercart's Conditional Actions where the tigger was "User Completes Checkout" with the following Conditions:
  • order balance = $0.00
  • AND product type = (we were able to set the appropriate product type we wanted given the resulting action we wanted to take place)
This trigger and conditions combination allows us to then call an action "Run Custom PHP Code" where we were able to write the custom code we wanted to occur after a user has successfully purchased a specific product.

With the right conditions and the custom PHP code we were home.

- Daniel Casey
dcasey@data-that.com
www.data-that.com

No comments:

Post a Comment