[Drupal] How to cancel recurring fee order in Ubercart in a Drupal 6 website?

| | 2 min read

One of our Drupal clients required us to cancel the recurring fee order option which was pre-configured in Ubercart using Ubercart recurring fee module in their Drupal 6 site. If you are a Drupal user facing the same situation with Ubercart in your Drupal site and would like to know how to cancel the recurring fee order then read on to find out the solution.

The client wanted us to implement the recurring fee functionality, i.e., collect the recurring price of a product at a fixed date, For eg: if a client purchases a monthly subscription plan on the 10th of January. So during the first purchase he/she must give their credit card details when they subscribe for the monthly plan product. After that the recurring order will be renewed and the recurring price taken from their credit card until the custom cancels the order, for every month on a fixed date(10th Feb, 10th march etc).

Ubercart provides a recurring fee module for managing recurring functionality. Using the recurring module, the order is automatically renewed so that we are not bothered about the renewal and expiration of the recurring product order. However sometimes we might want to cancel the order before next renewal date of the recurring product .

We can cancel the order in two ways

  1. Go to Adminstration Menu -> Store administration -> Order -> Recurring fees and click on cancel link, the recurring order will cancel.
  2. We can also do it programmatically .
//take rfid from corresponding order 
$recurring_result = db_fetch_array(db_query("select rfid,next_charge from {uc_recurring_users} where order_id = '%'", $order_id'));     
$rfid = $recurring_result['rfid'];
//cancel recurring fee