Jump to content

Add to order confirmation mail the reduction percent of each product


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...