skip to Main Content
Drupal Ubercart Hook After Complete Purchase Order Object Saved.

Drupal Ubercart hook after complete purchase order object saved.

Ubercart is the best and highly used e-commerce framework for Drupal. Ubercart provides awesome hook functionality. Using hook we can able to change some functionality without touching or modify the Ubercart code file.

If we want to change or update our database after complete order purchase on Ubercart we can be using the hook. Like we want to change the user role after user purchase any product from the site. We can change the user role using hook after the user successfully purchase any product from the site.

Let’s see how we change the user role to the premium user after complete the purchase using the hook.

function thecodingstuff_uc_checkout_complete($order, $account) {

    $productRole = "Premium Member";

    $uid = $account->uid;

    $role = user_role_load_by_name($productRole);
    user_multiple_role_edit(array($account->uid), 'add_role', $role->rid);        


the “uc_checkout_complete” hook called when any user completes the product purchase process.

So when this hook called we change the user role to “Premium Member”.

If you face any issue after using above code write the comment below.


I am a web designer and developer part-time blogger. Write something on some free time. Find my every day thought here :)

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top