system_error86 Posted February 7, 2017 Share Posted February 7, 2017 Hello I am trying to add the reduction percent in each product but I do not understand what I am doing wrong! First I created a public function inside the OrderDetail.php class which I call an sql query with the reduction percent of the order public function getProductReduction(){ $sql = 'SELECT `reduction_percent` FROM `'._DB_PREFIX_.'order_detail` WHERE `id_order_detail` = '.(int)$id_order_detail; return Db::getInstance()->execute($sql); } The second step was in PaymentModule.php class I added a variable which name is $reduction_percent and I call the function I created like this $reduction_percent = OrderDetail::getProductReduction(); . Next on line 754 which has all the other elements I created an element that I named {reduction_percent} = $reduction_percent. Now when I am doing an order in the mail I recieved in the place I put the {reduction_percent} displays the value 1! Can anyone help me please?? Thanks a lot Link to comment Share on other sites More sharing options...
system_error86 Posted February 9, 2017 Author Share Posted February 9, 2017 Any one?? Please Link to comment Share on other sites More sharing options...
rocky Posted February 10, 2017 Share Posted February 10, 2017 That query will get an array containing the value, not the value itself. Try instead: return Db::getInstance()->getValue($sql); Link to comment Share on other sites More sharing options...
system_error86 Posted February 10, 2017 Author Share Posted February 10, 2017 Hello, thanks for the reply but it doesn't work. Link to comment Share on other sites More sharing options...
rocky Posted February 11, 2017 Share Posted February 11, 2017 The problem must be somewhere else then. Unfortunately, I can't help without seeing all the related code. Link to comment Share on other sites More sharing options...
system_error86 Posted February 11, 2017 Author Share Posted February 11, 2017 First of all thanks a lot for the help. I am sending you the two files I changed. In the PaymentModule file I added the line 695 and the line 754. In the OrderDetail I added the line 305 up to 311. Maybe is another way to display the reduction of each product in the template of mail confirmation. Thanks a lot PaymentModule.php OrderDetail.php Link to comment Share on other sites More sharing options...
rocky Posted February 12, 2017 Share Posted February 12, 2017 I'm seeing different code than you posted above: public function getProductReduction($id_order_detail){ $sql = 'SELECT `reduction_percent` FROM `'._DB_PREFIX_.'order_detail` WHERE `id_order_detail` = '.(int)$this->id; return Db::getInstance()->getValue($sql); } It should be: public static function getProductReduction($id_order_detail) { $sql = 'SELECT `reduction_percent` FROM `'._DB_PREFIX_.'order_detail` WHERE `id_order_detail` = '.(int)$id_order_detail; return (float)Db::getInstance()->getValue($sql); } Otherwise, the code in those files looks fine to me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now