PrestaShop 1.6+ Tracking Setup

For PrestaShop cart versions 1.6 and higher, first locate the file /controllers/front/OrderConfirmationController.php.

As always, make a backup of the file first. Once you've made a backup, look for this line in the file:

$this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');

Underneath it, add the following code:

//begin shareasale $order = new Order($this->id_order); $cart = new Cart($order->id_cart); $products = $cart->getProducts(); $discounts = $cart->getDiscounts(); $skulist = $pricelist = $quantitylist = $couponcode = ''; $last_index = array_search(end($products), $products, true); foreach ($products as $index => $product) { $delimiter = $index === $last_index ? '' : ','; $skulist .= $product['id_product'] . $delimiter; $priceReductions = array_map(function($discount) use ($product, $order){ if($discount['product_restriction'] == 1 && $discount['reduction_product'] == $product['id_product']){ return $discount['reduction_amount'] == 0 ? $product['price'] * ($discount['reduction_percent'] / 100) : $discount['reduction_amount']; } elseif ($discount['product_restriction'] == 0) { return $discount['reduction_amount'] == 0 ? $product['price'] * ($discount['reduction_percent'] / 100) : $product['price'] * ($discount['reduction_amount'] / $order->total_products); } }, $discounts); $price = $product['price']; foreach ($priceReductions as $reduction) { $price = $price - $reduction; } $pricelist .= round($price, 2) . $delimiter; $quantitylist .= $product['quantity'] . $delimiter; } $last_index = array_search(end($discounts), $discounts, true); foreach ($discounts as $index => $discount) { $delimiter = $index === $last_index ? '' : ','; $couponcode .= $discount['code'] . $delimiter; } $newcustomer = $this->context->customer->is_guest ? '' : (count(Order::getCustomerOrders((int)$this->context->customer->id)) > 1 ? 0 : 1); $this->context->smarty->assign(array( 'id_order' => $this->id_order, 'subtotal' => $order->total_products - $order->total_discounts_tax_excl, 'skulist' => $skulist, 'pricelist' => $pricelist, 'quantitylist' => $quantitylist, 'couponcode' => $couponcode, 'newcustomer' => $newcustomer )); //end shareasale

Then locate the file /themes/[your-theme]/order-confirmation.tpl.

Where [your-theme] is the name of your current Prestashop theme. The default is "default-bootstrap" in the /themes folder. Back up a copy somewhere safe and then below this line or its equivalent line for your theme:

<h1 class="page-heading">{l s='Order confirmation'}</h1>

Underneath it, add the following code:

<img src="https://shareasale.com/sale.cfm?v=prestashop1&tracking={$id_order}&amp;amount={$subtotal}&amp;transtype=sale&amp;merchantID=XXXXX&amp;couponcode={$couponcode}&amp;skulist={$skulist}&amp;quantitylist={$quantitylist}&amp;pricelist={$pricelist}&amp;newcustomer={$newcustomer}&amp;currency={$currency->iso_code}" width="1" height="1"> <script src='https://www.dwin1.com/!!!!!.js' type='text/javascript' defer='defer'></script>

Make sure that you replace the XXXXX in the code below with your ShareASale Merchant ID. You can find this at the top-left of your ShareASale account when you are logged in.

Replace the !!!!!! in the code with your Master Tag ID.

For merchants in the Setup Wizard, you can find this within Step 4 (Tracking Code Installation). If you are live, you can find this by navigating to MY ACCOUNT > ACCOUNT DETAILS

Account Details: https://account.shareasale.com/m-account.cfm

 If you cannot locate your Master Tag ID, or would like to verify that you have one, please submit a ticket to our ShareASale support staff

Note: Make sure to clear your Prestashop cache under Advanced Parameters >> Performance >> Clear Cache after this is complete. Keep in mind this installation requires modifying core Prestashop files, and may need to be reintegrated if you update your Prestashop version.

Testing

Now that your tracking tags have been installed, we will need to test that everything is working as expected. To do this, we’ll simulate an Affiliate referred purchase by clicking a ShareASale test link and then running a purchase on your store. If the test is successful we’ll see a record appear in your ShareASale console, which we will VOID so that it doesn’t debit commissions from your account.

If you were emailed a link to this document, a test link may have been provided to you. If it wasn’t, you can obtain one from your account by clicking here.

NOTE: If you do not click the test link your order will not track.

The test link should direct you to your own store. Once there, please purchase any item in your store. Sometimes Merchants will have a test item worth $1.00 sale price, but above $0.00 minimum.

After the purchase is complete, navigate to www.shareasale.com in your browser and log into your account. Click Reports and then click Transaction Details from the drop-down menu.

Filter the report for Affiliate ID 178 using the panel on the left. The filtered view should now show your test purchase as an entry with today’s date.

If the order tracked successfully…

Your account is now ready to use ShareASale with your store. Please contact us at ShareASale@ShareASale.com for further information about:

  • Product specific commissions (offer different commissions by product)

  • New customer incentives (offer commission bonuses for new customers)

  • Exclusive coupon codes (used for tracking conversions without link clickthrough)

If the order does not show up in the Transaction Details Report…

Please verify that you have completed all of the steps as instructed. Common mistakes include not entering the correct Merchant ID in your tracking code and forgetting to click the test link.

If after verifying all of these steps your tracking still does not work please contact our support team at ShareASale@ShareASale.com.

Copyright ShareASale 2021