Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Affiliate Tracking Code - Modern Oscommerce Versions


Sam-AUST

Recommended Posts

Our store has an affiliate program running through Shareasale (for over 10 years now), on building a new website we have found the code on the checkout pages has obviously changed quite a lot. but the tracking code provided for oscommerce is from 2006.

 

This is the code shareasale provides for oscommerce.

There are two pages where you need to make changes. 

In the page: catalog/checkout_process.php, just above the line: 

// load the after_process function from the payment modules 

add the following code:
 // Begin Affiliate Program - Sales Tracking

$orders_total=$currencies->format($cart->show_total()- $total_tax); 

tep_session_register('orders_total'); 

$orders_id=$insert_id; 

tep_session_register('orders_id'); 

// End Affiliate Program - Sales Tracking 


In the page: catalog/checkout_success.php, just below the line,
<h3><?php echo TEXT_THANKS_FOR_SHOPPING; ?></h3></td>
add the following code:

<!-- Start Affiliate Program - Sales Tracking -->
<?php
echo '<img src="https://shareasale.com/sale.cfm?amount='.$orders_total.'&tracking='.$orders_id.'&transtype=sale&merchantID=XXXX" width="1" height="1">'; 
tep_session_unregister('orders_total'); 
tep_session_unregister('orders_id'); 
?> 
<!-- // End Affiliate Program - Sales Tracking -->
Where you replace XXXX with your merchant ID number.

and an alternative for the success page:

If that does not work, try changing the code in the checkout_process page to this:


// Begin Affiliate Program - Sales Tracking
$orders_total=$currencies->format($order->info['subtotal']);
tep_session_register('orders_total');
$orders_id=$insert_id;
tep_session_register('orders_id'); 
// End Affiliate Program - Sales Tracking

Is there any way in the latest oscommerce version to make this work?

 

Link to comment
Share on other sites

For modern versions of osCommerce (2.3.1 onwards, including community Responsive version), this is done ALL in checkout_success.php and would be a Content module.  So, you end up with a Content Module, which you drop into your osCommerce file structure.  You then go into admin and turn it on.  That can be done with zero core code changes, which is the absolute best way to do it.

Link to comment
Share on other sites

Let me know if it still has all the necessary fields. I should probably repackage it and add as its own module in the uploads so people can find it. 

 

Why not use the order_total?  This is the value after any discount if memory serves...then it can be a lot less code...

Link to comment
Share on other sites

Why not use the order_total?  This is the value after any discount if memory serves...then it can be a lot less code...

As I remember (was a long time since I coded them), the order total would also include the shipping - if any. So I would have to get the sub-total, and I believe the subtotal was before any discount applied.

 

Sub total alone would even be better, but I did run into a situation where coupons were in use and the advertisers found themselves paying out commission for orders before discounts were calculated - thus the extra markup to exclude the 2 more popular coupon addons at the time.

Follow the community build:

BS3 to osCommerce Responsive from the Get Go!

Check out the new construction:

Admin Gone to Total BS!

Link to comment
Share on other sites

G'day guys, I was just coming here to mention this. It's installed and I've tested it with and without discount coupons.

 

It gives the full amount of the sale, even if a discount has been applied. It definitely should be the amount AFTER the coupon has been applied. In the meantime we will just have to manually edit the total amount.

Link to comment
Share on other sites

FYI my old store checkout_process had this in it to make sure the right currency was being passed along to SAS.

// Begin Affiliate Program - Sales Tracking
$orders_total = number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value('USD'), $currencies->get_decimal_places('USD'));
tep_session_register('orders_total'); 
$orders_id=$insert_id;
tep_session_register('orders_id');
// End Affiliate Program - Sales Tracking
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...