OpenCart

A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.

This is integration method for open source shopping cart OpenCart. The integration is done by integrating files of thank you page.

For OpenCart 2.0 use the other integration method please.

1.Edit confirm action

Navigate to your cart directory catalog/controller/checkout and open confirm.php for editing. Find this line:
Put this code below that line:

$this->session->data[‘totals’] = $order_data[‘totals’];
$this->session->data[‘track_products’] = $data[‘products’];
$this->session->data[‘currency_code’] = $order_data[‘currency_code’];

Save these files and continue with next step.

2.Edit success action

Open file catalog/controller/checkout/success.php
Find this line:

if (isset($this->session->data[‘order_id’])) {

$data['track_orderid'] = $this->session->data['order_id'];
$data['track_totals'] = $this->session->data['totals'];
$data['track_products'] = $this->session->data['track_products'];
$data['currency_code'] = $this->session->data['currency_code'];

unset($this->session->data['track_products']);
unset($this->session->data['totals']);

Again save the changes and continue to the next integration step.

3. Per product integration

In case you want to track per product commissions, you should use this integration code instead of the one from step 2.

<script type="text/javascript" src="https://yourname.affberry.com/sales/sale.js"></script>
<script type="text/javascript">
var accountid = '2';
var campaignid='5';
var currencycode='USD';
var pluginc = '2';
var trackurl = 'https://yourname.affberry.com/';

<?php
foreach($track_products as $item)
{
echo "var cost="."'".$item['total']."';";
echo "var orderid="."'".$track_orderid."';";
echo "var productid="."'".$item['product_id']."';";
?>
register(accountid,campaignid,cost,orderid,productid,currencycode,pluginc,trackurl);
<?php
}
?>
</script>

Save the file and your shop is integrated.