Prestashop - 将PHP文件跟踪到页脚

I need to insert affiliate tracking file to footer in Prestashop 1.6 but I absolutely don't know how to :(

Integration guide tells this:

Step 1. Include this php tracking file on any page you wish to track

include('affiliate-pro/controller/affiliate-tracking.php');

Can someone tell me where to place this php code? What file in Prestashop 1.6 I have to edit?

And then there is step 2:

Step 2. Once a sale has been completed (for example a thank you page) include the file to record the sale into Affiliate Pro

$sale_amount = '21.98';
$product = 'My Product Description';
include('affiliate-pro/controller/record-sale.php');

Where should i place this code? What Prestashop file?

Thank you very much!

The best way is to create a module, you can use the module generator here

Name it "tracker", fill the description (min 20 characters), hit next twice then in the Hooks pick "Footer" & "New orders" and click "create"

In the backoffice modules page, install the module using the "Add a new module" button or extract the zip in "modules" folder of your installation

Next, you will need to modify the functions hookDisplayFooter & hookActionValidateOrderin the file "tracker.php" inside the module.

Here's the code to get you going:

public function hookActionValidateOrder($params)
{
    $products = $params['order']->product_list;
    foreach ($products as $product) {
        $sale_amount = $product['total_wt'];
        $product = $product['name'];
        include('affiliate-pro/controller/record-sale.php');
    }
}

public function hookDisplayFooter()
{
    ob_start();
    include('test.php'); //use full path to your php file
    return ob_get_clean();
}