Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

inserting tracking code for TradeTracker


Marco from Holland

Recommended Posts

Hello,

 

I'm trying to install a tracking code for an affilitate program that I would like to join. They told me to install the following code in the checkout_succes page:

 

<!-- start tradetracker code  //-->

<?php

    require(DIR_WS_CLASSES . 'order.php');

          $order = new order($HTTP_GET_VARS['order_id']);

  ?>

<img SRC=http://www.tradetracker.nl/sale.php?trans_amount=<?php echo $orders->totals[0]['value']; ?>&orderid=<?php echo $orders['orders_id']; ?>&merID=73>

<!-- end tradetracker code  //-->

The result should look like this:

<!-- start tradetracker code  //-->

<img SRC=http://www.tradetracker.nl/sale.php?trans_amount=95.30&orderid=12653&merID=73>

<!-- end tradetracker code  //-->

 

But when I try this, the amount and orderid are missing.

 

Anyone suggestions?

 

Thnks,

 

Marco

Link to comment
Share on other sites

$order = new order($HTTP_GET_VARS['order_id']);

I think they meant to say (note orders_id instead of order_id):

$order = new order($orders['orders_id']);

See the code from line 44-50:

    $products_array = array();
   $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
   while ($products = tep_db_fetch_array($products_query)) {
     $products_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name']);
   }

There is no $HTTP_GET_VARS['order_id'] on that page.

Link to comment
Share on other sites

Sorry, I could have known that since you were already echoing $orders['orders_id'] and nothing came out. I don't get why it is not working, but I checked you can get hold of that crucial variable by doing an extra query. Add to the top another query to get last orders_id from that customer like:

 

  $breadcrumb->add(NAVBAR_TITLE_1);
 $breadcrumb->add(NAVBAR_TITLE_2);
 
 $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
 $global = tep_db_fetch_array($global_query);
 
   // BOF Extra Code for Tradetracker
$last_order_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
   $last_order = tep_db_fetch_array($last_order_query);

// EOF Extra Code for Tradetracker 

 if ($global['global_product_notifications'] != '1') {

Then this should (at least partically) work:

<!-- start tradetracker code? //--> 
<?php
? ? require(DIR_WS_CLASSES . 'order.php');
? ? ? ? ? $the_last_order = new order($last_order['order_id']);
? ?>
<img SRC=http://www.tradetracker.nl/sale.php?trans_amount=<?php echo $the_last_order->totals[0]['value']; ?>&orderid=<?php echo $last_order['orders_id']; ?>&merID=73>
<!-- end tradetracker code? //-->

Link to comment
Share on other sites

The piece of code:

<?php
? ? require(DIR_WS_CLASSES . 'order.php');
? ? ? ? ? $the_last_order = new order($last_order['order_id']);
? ?>

isn't working either.

 

Add this to the top of checkout_success.php:

  $breadcrumb->add(NAVBAR_TITLE_1);
 $breadcrumb->add(NAVBAR_TITLE_2);
 
 $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
 $global = tep_db_fetch_array($global_query);
 
   // BOF Extra Code for Tradetracker
$last_order_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
   $last_order = tep_db_fetch_array($last_order_query);
   
$last_order_value_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where class = 'ot_total' and orders_id = '".$last_order['orders_id']."' ");
   $last_order_value = tep_db_fetch_array($last_order_value_query);

// EOF Extra Code for Tradetracker 

 if ($global['global_product_notifications'] != '1') {

Call the tradetracker image with:

<!-- start tradetracker code? //-->

<img SRC=http://www.tradetracker.nl/sale.php?trans_amount=<?php echo tep_round($last_order_value['value'],2) ; ?>&orderid=<?php echo $last_order['orders_id']; ?>&merID=73>

<!-- end tradetracker code? //-->

Link to comment
Share on other sites

Good to hear it works. Just a little note: ot_total is the value of the goods plus shipping. If you just need the value of the goods, you should use ot_subtotal in the query:

$last_order_value_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where class = 'ot_subtotal' and orders_id = '".$last_order['orders_id']."' ");
? ?$last_order_value = tep_db_fetch_array($last_order_value_query);

 

And of course it would be nicer to use valid html:

<img src="http://www.tradetracker.nl/sale.php?trans_amount=<?php echo tep_round($last_order_value['value'],2); ?>&orderid=<?php echo $last_order['orders_id']; ?>&merID=73">

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...