Show affiliate earning on opencart product page

Posted by Flo on 21 Jun 2014

Having affiliates is a great way to boost your sales, so this article will help you atract more affiliates to your website by displaying somewhere on the product page how much an affiliate wil make by making a sale of that viewed product.

For that you would have to modify 2 files catalog/controller/product/product.php and catalog/view/theme/yourtheme/template/product/product.tpl.

First on the product.php file find the line:

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {

and above it add the following code:

$earning = $this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')) * $this->config->get('config_commission') / 100;

$this->data['youearn'] = "By promoting this product you could earn on a sale " .  $this->currency->format($earning);

And then in product.tpl wherever you want the text to appear add the code:

<?php echo $youearn; ?>

That is it and now your affiliates or potential affiliates will know how much they could make on selling that product.