userpoints_ecommerce price/points multiplier only takes integers.

jguffey - October 29, 2008 - 05:21
Project:User Points Contributed modules
Version:5.x-3.x-dev
Component:Code: userpoints_ecommerce
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

userpoints_ecommerce price/points multiplier only takes integers.

I noticed a issue (not sure if this is a bug or just a functionality difference) in userpoints_ecommerce_ecommerceapi method. On line 81 the multiplier variable is initialized as a integer. Therefore if you have the multiplier set to something like "0.1" it will register as 0, causing no points to be awarded even when the cost of the product is 10 (In this example one would expect 1 point per $10 in transactions).

Solutions:
A-
In the userpoints_ecommerce settings, make it clear that only whole numbers can be used, make sure that integers are not saved.
or B-
change line 81 to

<?php
$multiplier
= (float)variable_get(USERPOINTS_EC_EARN, 0);
?>

so that the multiplier can be a decimal value.

This is what I needed in my example because I want each point to cost $10, this may not be a safe way of doing this for other users, who may not be careful enough to make sure that only whole number points are awarded. (I'm sure users have .1 points would get confusing.)

Please advise

Also if solution B is chosen, be advised that in line 132, the userpoints_ecommerce_paymentapi, there is another multiplier that is also read as a integer. The same 2 solutions I proposed above should also work here.

 
 

Drupal is a registered trademark of Dries Buytaert.