osCommerce

osCommerce

Integration with osCommerce is made by placing sale tracking script into the confirmation page. To obtain the values of OrderID and TotalSale, snippet connects to osCommerce database and retrieves the values from there.

1. Find and open file checkout_success.php


2. Inside the file find this line
if ($global['global_product_notifications'] != '1') {
...

3. insert the following code just above that line

//--------------------------------------------------------------------------
// integration code
//--------------------------------------------------------------------------
$sql = "select orders_id from ".TABLE_ORDERS.
    " where customers_id='".(int)$customer_id.
    "' order by date_purchased desc limit 1";
$pap_orders_query = tep_db_query($sql);
$pap_orders = tep_db_fetch_array($pap_orders_query);
$pap_order_id = $pap_orders['orders_id'];
// get total amount of order
$sql = "select value from ".TABLE_ORDERS_TOTAL.
    " where orders_id='".(int)$pap_order_id."' and class='ot_subtotal'";
$pap_orders_total_query = tep_db_query($sql);
$pap_orders_total = tep_db_fetch_array($pap_orders_total_query);
$pap_total_value = $pap_orders_total['value'];
// draw invisible image to register sale
if($pap_total_value != "" && $pap_order_id != "") {
    $img = "<script id=\"pap_x2s6df8d\" src=\"https://www.yoursite.com/affiliate/scripts/salejs.php\" type=\"text/javascript\"></script>
<script type=\"text/javascript\">
var sale = PostAffTracker.createSale();
sale.setTotalCost('".$pap_total_value."');
sale.setOrderID('".$pap_order_id."');
sale.setProductID('');
PostAffTracker.register();
</script>";

    print $img;
}
//--------------------------------------------------------------------------
// END of integration code
//--------------------------------------------------------------------------

Make sure you define the correct path to your scripts directory instead of https://www.yoursite.com/affiliate/scripts/salejs.php


4. It is now integrated. Every time customer enters the order confirmation page the tracking code is called and it will register a sale for referring affiliate.






×