Page 1 of 1

Reward point with decimal

Posted: Tue May 14, 2013 8:53 pm
by darksecu
i am planning to reward all my customer with reward point on purchase with the formula.

1 Reward Point = 100 INR(Currenct) Purchase (Purchase Amount/100)
so if user make purchase of 349 then i want to reward him with 3.49.

But opencart not allowing me to set it as decimal, is there some way i can enable decimals in rewards ?

Re: Reward point with decimal

Posted: Tue May 14, 2013 10:48 pm
by rph
You'll have to modify the database and change points from integer to decimal and modify the model files so the data is cast as a float rather than an integer.

Re: Reward point with decimal

Posted: Wed May 15, 2013 1:16 pm
by darksecu
Modified Tables product_reward & customer_reward (Point Column is now decimal 8,2)

=> admin/model/catalog/product.php
(int)$value['points'] Replaced With $value['points']
(int)$product_reward['points'] Replaced With $product_reward['points']

=> catalog/controller/account/reward.php
$this->data['total'] = (int)$this->customer->getRewardPoints(); Replaced With $this->data['total'] = $this->customer->getRewardPoints();


Is there anything else i need to modify, may any php file which credit the points in users account (For confirming to be on secure side :D)?

Thanks a lot for helping me out :)


Update => admin/model/sale/customer.php
(int)$points Replaced With $points

Re: Reward point with decimal

Posted: Wed May 15, 2013 4:08 pm
by rph
You should replace (int) with (float), otherwise you're susceptible to database injection.