this is way cool! exactly what i was looking for. but i need some help. im getting this error:
* warning: Invalid argument supplied for foreach() in ../includes/common.inc on line 744.
* warning: strtr() [function.strtr]: The second argument is not an array. in ../includes/common.inc on line 759.everytime i complete a transaction. it's probably because i inserted the code for userpoints_ubercart_order inside the submit case of the function. is this correct?
also, i think it's these lines causing the error:
userpoints_userpointsapi(array('uid' => $order->uid,'points' => $totalPoints,));
userpoints_userpointsapi($params);because the moment i commented them out, the error stopped showing. of course, the points weren't awarded either.
im sure this is a really stupid error on my part.. but im lost.
any help would be appreciated.
thanks!
-- sarah
[edit - 13.43p the next day]
okay, i found the cause of the error. it was stupid. there was a typo in the code.
this:
uc_order_comment_save($order->order_id, 0, t('User earned '.$totalPoints.' Points!', 'admin'));
should be:
uc_order_comment_save($order->order_id, 0, t('User earned '.$totalPoints.' Points!'), 'admin');
after i fixed that up, it was okay. no more errors.
for the sake of whoever else, this was what worked for me. i edited the code given above to this: (line 54 of uc_points_payment.inc)
case 'submit':
// fires when the order is submitted and adds/subtracts thier points
if ($paymethod == 'points') {
userpoints_ubercart_payment($order);
} else {
// for points assigning - by torgosPizza
// commented out the $arg2 line as it was not being satisfied. could be a problem on my placement? - sarah20080417
//if ($arg2 == 'completed') {
foreach ($order->products as $product) {
//print_r($product);
$node = node_load($product->nid);
//print_r($node);
$qty = $product->qty;
$points = db_result(db_query("SELECT points FROM {uc_userpoints_products} WHERE nid=%d", $product->nid));
//drupal_set_message('<pre>'.print_r($item, TRUE).'</pre>');
if ($points > 0) {
//drupal_set_message($product->title.' has '.$points.' Points attached');
$totalPoints .= ($points * $qty);
}
}
//}
$params = array(
'points' => $totalPoints,
'uid' => $product->uid,
'operation' => 'insert',
'description' => 'User made a purchase of points (Order ID ' . $order->order_id . ')',
'entity_id' => $order->order_id,
'entity_type' => 'Ubercart Transaction'
);
userpoints_userpointsapi($params);
//uc_order_comment_save($order->order_id, 0, t('User earned '.$totalPoints.' Points!'), 'admin');
uc_order_comment_save($order->order_id, 0, t('User purchased '.$totalPoints.' Credits!'), 'admin');
// end points assigning - by torgosPizza
userpoints_ubercart_insert($order);
if (variable_get(USERPOINTS_DISCOUNT,0) != 0) {
ptdiscount_submit($op, $arg1, $arg2);
}
}
break;
Oh, and an observation on roles & userpoints (kinda OT), i noticed that whenever i assign points to a category (using userpoints taxonomy) it doesn't work with the role assigning contribution of userpoints. i haven't been able to figure out why, but in any case, i decided i didn't need userpoints taxonomy, so i just kept the points 'uncategorized' and the roles started being assigned. 



