Post by darksecu » Tue May 14, 2013 8:53 pm

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 ?

Newbie

Posts

Joined
Fri May 10, 2013 8:03 pm

Post by rph » Tue May 14, 2013 10:48 pm

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.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by darksecu » Wed May 15, 2013 1:16 pm

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

Newbie

Posts

Joined
Fri May 10, 2013 8:03 pm

Post by rph » Wed May 15, 2013 4:08 pm

You should replace (int) with (float), otherwise you're susceptible to database injection.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska
Who is online

Users browsing this forum: No registered users and 93 guests