How to setup a Zen Cart Affiliate Program 

If you have the Zen Cart Shopping Cart and you are looking to setup your own affiliate program, this can be easily done. If you do not already have an affiliate software system you can sign up for one of the Omnistar Affiliate Software Plans.

After you have your Affiliate Software account setup the integration into Zen Cart is really easy. Simply follow the steps below.

We have made it easy to integrate your affiliate software with your shopping cart or gateway by following the instructions below. If you would like our technical team to integrate the software for you then you can sign up for our Managed Integration option.

Step 1. Add Code to your Landing Pages

Move the following code to your landing page. The landing page is the main page of your web site where web users will end up after clicking on the affiliate link. 
Please Note: Where it says, please replace that URL with the actual URL of where your software is installed.

var resource = document.createElement('script'); 
resource.src = "";
var script = document.getElementsByTagName('script')[0];
script.parentNode.insertBefore(resource, script);

 Step 2. Add the Sale Tracking code

1. Open includes emplates emplate_default emplates pl_checkout_success_default.php 

2. Find the following line in the page's code: 

<div id="checkoutSuccessOrderNumber"><?php echo TEXT_YOUR_ORDER_NUMBER . $zv_orders_id; ?></div> 

3. Copy and paste the following code into the file, under the line found above:

$dbreq = $db->Execute("select * from ".TABLE_ORDERS_TOTAL." where orders_id = '".$orders->fields['orders_id']."' AND class in ('ot_coupon', 'ot_gv', 'ot_subtotal', 'ot_group_pricing', 'ot_quantity_discount')");
while (!$dbreq->EOF) {
switch ($dbreq->fields['class']) {
case 'ot_subtotal': $order_subtotal = $dbreq->fields['value']; break;
case 'ot_coupon': $coupon_amount = $dbreq->fields['value']; break;
case 'ot_group_pricing': $group_pricing_amount = $dbreq->fields['value']; break;
case 'ot_gv': $gv_amount = $dbreq->fields['value']; break;
case 'ot_quantity_discount': $quantity_discount_amount = $dbreq->fields['value']; break;
$totalCost = ($order_subtotal - $gv_amount - $coupon_amount - $group_pricing_amount - $quantity_discount_amount);
$totalCost = number_format($totalCost,2,'.','');
$orderId = $dbreq->fields['orders_id'];

// -------------products---------------------------------------------------------
$productId = "";
$dbreqa = $db->Execute("select products_id from ".TABLE_ORDERS_PRODUCTS." where orders_id = '".$orders->fields['orders_id']."' ");
while (!$dbreqa->EOF) {
$productId = $dbreqa->fields['products_id'];
// ----------end products--------------------------------------------------------

function hideIF() { 
document.getElementById('IF').style.display = '';
function getSaleInfo() {

document.getElementById('st_code').innerHTML='<iframe src="<?=$totalC...?>" alt="" id=IF width=50 height=50 border="0" frameborder="0" onload="hideIF()">';
window.onload = getSaleInfo;

<div id="st_code"></div>

Step 3. Test

Now you should test the affiliate program by creating a test user from your user area. Once you create a test user, sign in as that test user and copy the link under where it says "Link To Promote" and then click on the affiliate link that is shown. Next you should go through the entire process of completing an order with your shopping cart or order form by using a test credit card. Once you go through the process then you can make sure the test user received credit for the sale.