OK So i was wondering if someone could point me in the right direction. Currently I'm running User Points Module with UberCart in order to purchase items with currency or use points for purchases. Now i've managed to get the transaction to work as needed except for one small thing. The Ubercart API only allows me to subtract the purchase points from a single category like "General". Id like to subtract the points used to buy the product from ALL the categories the use has points in. Does anybody know a way this can be done?

1 Answer 1


You have few options that depend on the number of userpoints categories and the way you want to do it (w or w/o code):

Option 1: Create separate actions for each userpoint category within Ubercart.

Option 2: Enter custom PHP code and do the following:

  • Load userpoints dictionary - userpoints_get_vid()
  • Loop through all terms in it and subtract the points.

Sample code:

$userpoints_vid = userpoints_get_vid();
$userpoints_terms = taxonomy_get_tree($userpoints_vid);
foreach ($userpoints_terms as $term) {
  // Build the params for this transaction.
  $params = array(
    'points' => -100,
    'moderate' => FALSE,
    'term_id' => $term->tid,
    'entity_id' => $order->order_id,
    'entity_type' => 'order',
  // Subtract the points. This will call automatically all UP hooks.

Option 3: You could also create a Rules action from the code above that will accept $order as an argument. This will take slightly more time, but is the right way to do things.

  • Thanks very much! this seems like what i need, except one thing. I need the amt(-100) to be subtracted equally among the categories. (i.e -25 from 4 different categories) or (a -1++ that can loop thru all the categories subtracting -1 point until it subtracts the full -100 from all points categories.) can this be don without code i would prefer code as a last resort? thnks for the help :) Oct 8, 2013 at 15:12
  • You could do it manually, but that depends on the number of products you have. Otherwise, I think you will have to get your hands dirty and write some code. It should be pretty straightforward though. Oct 8, 2013 at 15:58
  • Ok, so where would i put my variation of this code? In Rules Actions, or is this more of a custom module type of job? Oct 8, 2013 at 16:38
  • If you want to go with the easiest option, enable core "PHP Filter" module and for rules action select "Execute PHP code". In this case there's no need for a custom module. Oct 8, 2013 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.