Cart66 and ShareASale Integration

Cart66 and ShareASale Integration

Posted on December 13, 2016 nerdymind

Recently, we set out to integrate a WordPress eCommerce site running Cart66 with the ShareASale affiliate program and found the process to be less than sufficiently documented. After mulling over several options, we grudgingly settled on the unfortunate solution of going through the Cart66 code and modifying the file that displays the cart receipt in order to include the proper tracking code for ShareASale. Anyone familiar with WordPress and plugin development probably just cringed. Modifying plugins in WordPress is a great way to set yourself up for a headache down the line. Sure, everything might work swimmingly out of the box, but if Cart66 pushes out an update for it's plugin, it could wipe out the modifications you made, breaking the integration with ShareASale. We looked at other options like a helper plugin, or a modification to functions.php, but unfortunately the data we need to send ShareASale from Cart66 isn't a global variable.  Now that you have been warned, here's how we did it.

First off, we need to open up the file that is used to display the receipt after an order is placed within Cart66. It's located at


With the file open, scroll down to around line 197. We need a nice consistent place to put the tracking code for ShareASale. Just after the 'bill_country' if statement should work just fine.

At this point, if you haven't already, log into ShareASale, and complete the steps up to step 4. Select 'I am not using a shopping cart platform' and click 'View Tracking Code Instructions' Make a note of your Merchant ID#.

Paste in the following code after the endif statement and replace XXXXX with your Merchant ID#:

/*****This code adds tracking for****/
} else {
$tracking_string = "<img src=""".CART66_CURRENCY_SYMBOL.number_format($order->total, 2)."&tracking=".$order->trans_id."&transtype=sale&merchantID=XXXXX" width="1" height="1">";
echo $tracking_string;
/*****end of the shareasale code******/

That's it! Continue through Step 5 in order to test ShareASale, and you should be set to go!

Now that you have modified a file within the plugin, you will need to be extra vigilant when upgrading Cart66. Make a note, tie a string around your finger, whatever it takes. When Cart66 is upgraded, you will need to check and see if the changes you made are still intact and working.