Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Support Thread for Supertracker Contribution


equilla

Recommended Posts

I THINK U DON'T UNDERSTAND ME.... JUST I WANT TO CHANGE THE ADD TO SPANISH!!!

 

THANKS ANY WAYS,!! I CHANGE THE CONFIGURATION!

 

 

Angry guy that was not a reply to you, it was an upgrade for all users. This is not your private forum, it is for the benefit and sharing ideas for all. Please consult your spanish-english dictionary before posting angry nonsense next time.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

Mark

 

Well done - great contribution.

 

Regarding the earlyMYSQL versions, pre- version 4.0, the problem is it needs the WHERE and ORDER by is not recognised.

 

I know nothing about MYSQL syntax but the following seems to work.

 

$del_query  = "DELETE from supertracker WHERE tracking_id>0 LIMIT " . $rows_to_delete;

 

It seems to start from the lowest tracking_id this way.

 

 

A quick question - when using shared SSL we see two records. The customer entering the non-SSL part carrying the real refferer and then the customer entering the SSL part and the refferer is the non-SSL URL. Anyway these records could be joined, especially after a sale.

 

Danny

Link to comment
Share on other sites

A quick question - when using shared SSL we see two records. The customer entering the non-SSL part carrying the real refferer and then the customer entering the SSL part and the refferer is the non-SSL URL. Anyway these records could be joined, especially after a sale.

 

Danny

 

Hi Danny,

 

many thanks for your help with the MySQL issue - perhaps other people experiencing this issue can report back to confirm whether this solution works for them.

 

Regarding SSL - yes, I am aware of the problem. Some of the changes in the most recent version were to try and nail this one. It seems that in some cases it works and in some cases it doesn't. The biggest issues come when client's ISPs route their connection through complete different proxies when the connection is switched to SSL. There's definitely more that can be done here in terms of intelligently looking for a session from which an access to login.php, checkout_shipping.php, etc, have really come from. Unfortunately, that's unlikely to be before xmas as I have so little coding time available due to other commitments away from my computer.

 

Regards,

 

 

 

Mark

Link to comment
Share on other sites

Mark

 

Well done - great contribution.

 

Regarding the earlyMYSQL versions, pre- version 4.0, the problem is it needs the WHERE and ORDER by is not recognised.

 

I know nothing about MYSQL syntax but the following seems to work.

 

$del_query  = "DELETE from supertracker WHERE tracking_id>0 LIMIT " . $rows_to_delete;

 

It seems to start from the lowest tracking_id this way.

 

 

The above fix worked perfectly for me. Thanks Danny!!

Link to comment
Share on other sites

Hi there,

 

got a problem with Supertracker.

 

Today I included a new contribution, its called Actual Attribute Price (AAP), as shown here.

It displays the absolute price when you have product attributes (instead to have it displayed as plus/minus).

 

Sofar so good, Site is loading, but when I want to add a product in the cart, I got an error message from supertracker.php :

 

Fatal error: Call to undefined function: show_total() in /***/***/***/htdocs/includes/classes/supertracker.php on line 135

 

Seems to be that something is messing around.

 

AAP has modified the shopping_cart.php, so I guess, that there is something that does not fit to supertracker.

Here is the code of my shopping cart.php:

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;

function shoppingCart() {
  $this->reset();
}

function restore_contents() {
  global $customer_id;

  if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $qty = $this->contents[$products_id]['qty'];
	  $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  if (!tep_db_num_rows($product_query)) {
		tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
		if (isset($this->contents[$products_id]['attributes'])) {
		  reset($this->contents[$products_id]['attributes']);
		  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
			tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
		  }
		}
	  } else {
		tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  }
	}
  }

// reset per-session cart contents, but not the database contents
  $this->reset(false);

  $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
	$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	}
  }

  $this->cleanup();
}

function reset($reset_database = false) {
  global $customer_id;

  $this->contents = array();
  $this->total = 0;
  $this->weight = 0;
  $this->content_type = false;

  if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
  }

  unset($this->cartID);
  if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;

  $products_id = tep_get_uprid($products_id, $attributes);
  if ($notify == true) {
	$new_products_id_in_cart = $products_id;
	tep_session_register('new_products_id_in_cart');
  }

  if ($this->in_cart($products_id)) {
	$this->update_quantity($products_id, $qty, $attributes);
  } else {
	$this->contents[] = array($products_id);
	$this->contents[$products_id] = array('qty' => $qty);
// insert into database
	if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		$this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
		if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
	  }
	}
  }
  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
  global $customer_id;

  if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

  $this->contents[$products_id] = array('qty' => $quantity);
// update database
  if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  $this->contents[$products_id]['attributes'][$option] = $value;
// update database
	  if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
	}
  }
}

function cleanup() {
  global $customer_id;

  reset($this->contents);
  while (list($key,) = each($this->contents)) {
	if ($this->contents[$key]['qty'] < 1) {
	  unset($this->contents[$key]);
// remove from database
	  if (tep_session_is_registered('customer_id')) {
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
	  }
	}
  }
}

function count_contents() {  // get total number of items in cart 
  $total_items = 0;
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $total_items += $this->get_quantity($products_id);
	}
  }

  return $total_items;
}

function get_quantity($products_id) {
  if (isset($this->contents[$products_id])) {
	return $this->contents[$products_id]['qty'];
  } else {
	return 0;
  }
}

function in_cart($products_id) {
  if (isset($this->contents[$products_id])) {
	return true;
  } else {
	return false;
  }
}

function remove($products_id) {
  global $customer_id;

  unset($this->contents[$products_id]);
// remove from database
  if (tep_session_is_registered('customer_id')) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function remove_all() {
  $this->reset();
}

function get_product_id_list() {
  $product_id_list = '';
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $product_id_list .= ', ' . $products_id;
	}
  }

  return substr($product_id_list, 2);
}

function calculate() {
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;

  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];

// products price
	$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	if ($product = tep_db_fetch_array($product_query)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $product['products_price'];
	  $products_weight = $product['products_weight'];

	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }

	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
// BOF contrib nr.1716 - Actual attribute price
//	  $this->weight += ($qty * $products_weight);
//	}
// phpmom.com advanced attribute price
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
} elseif ($attribute_price['price_prefix'] == '-') {
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
elseif ($attribute_price['price_prefix'] == '')
{ //comment where you see //'0' if want '0' value
// if ($attribute_price['options_values_price'] == '0') { //'0'
// $this->total += 0; //'0'
// } //'0'

// if ($attribute_price['options_values_price'] != '0') { //'0'
$this->total += tep_add_tax($attribute_price['options_values_price'], $products_tax) * $qty - (tep_add_tax($products_price, $products_tax) * $qty);
// }//'0'
}else $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
}
// EOF contrib nr.1716 - Actual attribute price	

// attributes price
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
		$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
		$attribute_price = tep_db_fetch_array($attribute_price_query);
		if ($attribute_price['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }
}

// BOF contrib nr.1716 - Actual attribute price
// function attributes_price($products_id) {
//   $attributes_price = 0;

//   if (isset($this->contents[$products_id]['attributes'])) {
//	 reset($this->contents[$products_id]['attributes']);
//	 while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
//	   $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
//	   $attribute_price = tep_db_fetch_array($attribute_price_query);
//	   if ($attribute_price['price_prefix'] == '+') {
//		 $attributes_price += $attribute_price['options_values_price'];
//	   } else {
//		 $attributes_price -= $attribute_price['options_values_price'];
//	   }
//	 }
//   }

//   return $attributes_price;
// }

//PHPMOM.COM AAP
function attributes_price($products_id) {
$attributes_price = 0;

if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$attributes_price += $attribute_price['options_values_price'];
} elseif ($attribute_price['price_prefix'] == '-') {
$attributes_price -= $attribute_price['options_values_price'];
}
else
$attributes_price+= $attribute_price['options_values_price'];
}
}

return $attributes_price;
}
//BOF PHPMOM.COM AAP
 function attributes_prefix($products_id) {

if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_prefix_query = tep_db_query("select price_prefix from ". TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id ."' and options_id = '" . (int)$option . "' and options_values_id = '" .(int)$value . "'");
$attribute_prefix = tep_db_fetch_array($attribute_prefix_query);
$attributes_prefix = $attribute_prefix['price_prefix'];
}
}

return $attributes_prefix;
}//eof aap
// EOF contrib nr.1716 - Actual attribute price
function get_products() {
  global $languages_id;

  if (!is_array($this->contents)) return false;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
	if ($products = tep_db_fetch_array($products_query)) {
	  $prid = $products['products_id'];
	  $products_price = $products['products_price'];

	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
// BOF contrib nr.1716 - Actual attribute price
//BOF PHPMOM.COM AAP//hadir
if (isset($this->contents[$products_id]['attributes'])) { 
if ($this->attributes_prefix($products_id) == ''){
$the_final_price = $this->attributes_price($products_id);
} else
$the_final_price = ($products_price + $this->attributes_price($products_id));
	}else $the_final_price = ($products_price); //eof actual attribute//hadir 
// EOF contrib nr.1716 - Actual attribute price
	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
					// BOF contrib nr.1716 - Actual attribute price			
				// 'final_price' => ($products_price + $this->attributes_price($products_id)),
				'final_price' => $the_final_price, //PHPMOM.COM AAP
		// EOF contrib nr.1716 - Actual attribute price		
								'tax_class_id' => $products['products_tax_class_id'],
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
	}
  }

  return $products_array;
}

function show_total() {
  $this->calculate();

  return $this->total;
}

function show_weight() {
  $this->calculate();

  return $this->weight;
}

function generate_cart_id($length = 5) {
  return tep_create_random_value($length, 'digits');
}

function get_content_type() {
  $this->content_type = false;

  if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  if (isset($this->contents[$products_id]['attributes'])) {
		reset($this->contents[$products_id]['attributes']);
		while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
		  $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);

		  if ($virtual_check['total'] > 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
	  } else {
		switch ($this->content_type) {
		  case 'virtual':
			$this->content_type = 'mixed';

			return $this->content_type;
			break;
		  default:
			$this->content_type = 'physical';
			break;
		}
	  }
	}
  } else {
	$this->content_type = 'physical';
  }

  return $this->content_type;
}

function unserialize($broken) {
  for(reset($broken);$kv=each($broken);) {
	$key=$kv['key'];
	if (gettype($this->$key)!="user function")
	$this->$key=$kv['value'];
  }
}

 }
 }
?>

 

And here is the code of the supertracker contribution :

<?php
/*
 $Id: supertracker.php,v3.1 2005/10/22

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

class supertracker {
 function supertracker(){

}

function update() {
  global $cart, $HTTP_GET_VARS, $customer_id;
//// **** CONFIGURATION SECTION  **** ////

  //Comma Separate List of IPs which should not be recorded, for instance, your own PCs IP address, or 
 //that of your server if you are using Cron Jobs, etc
  $excluded_ips = '';

//// **** CONFIGURATION SECTION EOF **** ////
$record_session = true;
	$ip_address = $_SERVER['REMOTE_ADDR'];

	if ($excluded_ips != '') {
	  $ex_array = explode(',',$excluded_ips);
	   foreach ($ex_array as $key => $ex_ip) {
		 if ($ip_address == $ex_ip) $record_session = false;
	   }
	}

//Big If statement that stops us doing anything more if this IP is one of the 
//ones we have chosen to exclude
if ($record_session) {		

	  $existing_session = false;
	  $thirty_ago_timestamp = strtotime("now") - (30*60);
	  $thirty_mins_ago = date('Y-m-d H:i:s', $thirty_ago_timestamp);	
	  $browser_string = $_SERVER['HTTP_USER_AGENT'];
		$ip_array = explode ('.',$ip_address);
		$ip_start = $ip_array[0] . '.' . $ip_array[1];			
  //Find out if this user already appears in the supertracker db table

//First thing to try is customer_id, if they are signed in

   if (isset($customer_id)) {
		$query = "select * from supertracker where customer_id ='" . $customer_id . "'  and last_click > '" . $thirty_mins_ago . "'";
		$result = tep_db_query($query);
		if (tep_db_num_rows ($result) > 0) { 
		  $existing_session = true;
	}
		 }

		//Next, we try this: compare first 2 parts of the IP address (Class B), and the browser
		//Identification String, which give us a good chance of locating the details for a given user. I reckon 
		//that the chances of having more than 1 user within a 30 minute window with identical values
		//is pretty small, so hopefully this will work and should be more reliable than using Session IDs....


	  if (!$existing_session) {			
		$query = "select * from supertracker where browser_string ='" . $browser_string . "' and ip_address like '" . $ip_start . "%' and last_click > '" . $thirty_mins_ago . "'";
		$result = tep_db_query($query);
		if (tep_db_num_rows ($result) > 0) { 
		  $existing_session = true;
	}
		}

		//If that didn't work, and we have something in the cart, we can use that to try and find the 
		//record instead. Obviously, people with things in their cart don't just appear from nowhere!
		if (!$existing_session) {
		  if ($cart->count_contents()>0) {
		  $query = "select * from supertracker where cart_total ='" . $cart->show_total() . "'  and last_click > '" . $thirty_mins_ago . "'";
		  $result = tep_db_query($query);
		  if (tep_db_num_rows ($result) > 0) { 
			$existing_session = true;
	  }
			}
		}


	  //Having worked out if we have a new or existing user session lets record some details....!
	  if ($existing_session) {
	   //Existing tracked session, so just update relevant existing details
		$tracking_data = tep_db_fetch_array($result);
		$tracking_id = $tracking_data['tracking_id'];			
		$products_viewed=$tracking_data['products_viewed'];
		  $added_cart = $tracking_data['added_cart'];
		  $completed_purchase = $tracking_data['completed_purchase'];
		  $num_clicks = $tracking_data['num_clicks']+1;
		$categories_viewed = unserialize($tracking_data['categories_viewed']);	
			$cart_contents = unserialize($tracking_data['cart_contents']);
			$cart_total = $tracking_data['cart_total'];				
			$order_id = $tracking_data['order_id'];		
	if (isset($customer_id)) $cust_id=$customer_id;
		else $cust_id=$tracking_data['customer_id'];				

		$current_page=$_SERVER['PHP_SELF'];
		$last_click = date('Y-m-d H:i:s');


		  //Find out if the customer has added something to their cart for the first time
		  if (($added_cart!='true') && ($cart->count_contents()>0)) $added_cart = 'true';

		  //Has a purchase just been completed?
		  if ((strstr($current_page, 'checkout_success.php'))&& ($completed_purchase!='true')) {
			  $completed_purchase='true';
				$order_q = "select orders_id from orders where customers_id = '" . $cust_id . "' ORDER BY date_purchased DESC";
				$order_result = tep_db_query($order_q);
				if (tep_db_num_rows($order_result) > 0) {
				  $order_row = tep_db_fetch_array($order_result);
					$order_id = $order_row['orders_id'];
				}
			}

		  //If customer is looking at a product, add it to the list of products viewed
		  if (strstr($current_page, 'product_info.php')) {
			$current_product_id = $HTTP_GET_VARS['products_id'];
			if (!strstr($products_viewed, '*' . $current_product_id . '?')) {
			  //Product hasn't been previously recorded as viewed
				$products_viewed .= '*' . $current_product_id . '?';	 
			}
		  }

		  //Store away their cart contents
			//But, the cart is dumped at checkout, so we don't want to overwrite the stored cart contents
			//In this case
		   $current_cart_contents = serialize($cart->contents);
			 if (strlen($current_cart_contents)>6) {
			   $cart_contents = $current_cart_contents;
				 $cart_total = $cart->show_total();
			 }



		  //If we are on index.php, but looking at category results, make sure we record which category
		  if (strpos($current_page, 'index.php')) {
			if (isset($_GET['cPath'])) {
				$cat_id = $_GET['cPath'];
				  $cat_id_array = explode('_',$cat_id);
				  $cat_id = $cat_id_array[sizeof($cat_id_array)-1];
				  $categories_viewed[$cat_id]=1;
			  }
		  }

		  $categories_viewed = serialize($categories_viewed);			
		  $query = "UPDATE supertracker set last_click='" . $last_click . "', exit_page='" . $current_page . "', num_clicks='" . $num_clicks . "', added_cart='" . $added_cart . "', categories_viewed='" . $categories_viewed . "', products_viewed='" . $products_viewed . "', customer_id='" . $cust_id . "', completed_purchase='" . $completed_purchase . "', cart_contents='" . $cart_contents . "', cart_total = '" . $cart_total . "', order_id = '" . $order_id . "' where tracking_id='" . $tracking_id . "'";
		tep_db_query($query);

	  }
	  else {
	   //New vistor, so record referrer, etc
		 //Next line defines pages on which a new visitor should definitely not be recorded
		 $prohibited_pages = 'login.php,checkout_shipping.php,checkout_payment.php,checkout_process.php,ch
eckout_confirmation.php,checkout_success.php';
	   $current_page=$_SERVER['PHP_SELF'];

		 if (!strpos($prohibited_pages, $current_page)) {			 
		 $refer_data = $_SERVER['HTTP_REFERER'];
		 $refer_data = explode('?', $refer_data);
		 $referrer=$refer_data[0];
		 $query_string=$refer_data[1];

		 $ip = $_SERVER['REMOTE_ADDR'];
		   $browser_string = $_SERVER['HTTP_USER_AGENT'];

	 include(DIR_WS_INCLUDES . "geoip.inc");
	 $gi = geoip_open(DIR_WS_INCLUDES . "GeoIP.dat",GEOIP_STANDARD);	 
	 $country_name = geoip_country_name_by_addr($gi, $ip);
	   $country_code = strtolower(geoip_country_code_by_addr($gi, $ip));		
	 geoip_close($gi);			  


		 $time_arrived = date('Y-m-d H:i:s');
		 $landing_page = $_SERVER['REQUEST_URI'];
	 $query = "INSERT INTO `supertracker` (`ip_address`, `browser_string`, `country_code`, `country_name`, `referrer`,`referrer_query_string`,`landing_page`,`exit_page`,`time_arrived`,`last_click`) VALUES ('" . $ip . "','" . $browser_string . "','" . $country_code . "', '" . $country_name . "', '" . $referrer . "', '" . $query_string . "','" . $landing_page . "','" . $current_page . "','" . $time_arrived . "','" . $time_arrived . "')";		 
		 tep_db_query($query);

		 }//end if for prohibited pages   
	}//end else
	}//End big If statement (Record Exclusion for certain IPs)

	}//End function update
}//End Class

?>

 

Can you please be so kind and give me advise, what to change, that your great contribution is running also with AAP ?

Unfortunately, I cannot review the code by myself.

 

Thank you very much, I appreciate all your help,

 

kind regards and sorry for the long posting,

Andreas

Link to comment
Share on other sites

Hi there,

 

got a problem with Supertracker.

 

Today I included a new contribution, its called Actual Attribute Price (AAP), as shown here.

It displays the absolute price when you have product attributes (instead to have it displayed as plus/minus).

 

Sofar so good, Site is loading, but when I want to add a product in the cart, I got an error message from supertracker.php :

 

Fatal error: Call to undefined function: show_total() in /***/***/***/htdocs/includes/classes/supertracker.php on line 135

 

Seems to be that something is messing around.

 

AAP has modified the shopping_cart.php, so I guess, that there is something that does not fit to supertracker.

Here is the code of my shopping cart.php:

 

Can you please be so kind and give me advise, what to change, that your great contribution is running also with AAP ?

Unfortunately, I cannot review the code by myself.

 

Thank you very much, I appreciate all your help,

 

kind regards and sorry for the long posting,

Andreas

 

Try the simple fix I suggested a few posts before.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

@homewetbar,

 

thanks for your reply.

I guess you mean your posting from Nov 7 2005, 10:58 PM ?!

I made the changes you told us there, but I am still receiving the same error message, when I put a product in the cart.

 

Still the same message :

Fatal error: Call to undefined function: generate_cart_id() in /***/***/***/htdocs/includes/classes/shopping_cart.php on line 107

 

Any other ideas ?

 

Thanks in advance,

Regards

Andreas

Link to comment
Share on other sites

Here's a quick upgrade for you guys,

 

Basically what it will do is fix the bug I described many pages back where if you have the Option Type contrib where you can submit text for option values on your products it locks up the system after you add the item to your cart with any special text and a ' such as john's in the text field and then re-visit the product page.

 

For those of you who do not have that previously mentioned contrib it will clean off the attributes in only the supertracker data (shopping cart not affected). What this will do is allow you to see which products are being viewed more accurately since you will not have many instances of the product every time they view it and change an option, which could be dozens of variants of the same product and will also help optimize the database field usage.

 

Here is the quick and easy modification

 

in catalog/includes/classes/supertracker.php

 

FIND:

			  //If customer is looking at a product, add it to the list of products viewed
		  if (strstr($current_page, 'product_info.php')) {
			$current_product_id = $HTTP_GET_VARS['products_id'];
			if (!strstr($products_viewed, '*' . $current_product_id . '?')) {
			  //Product hasn't been previously recorded as viewed
				$products_viewed .= '*' . $current_product_id . '?';	 
			}
		  }

 

REPLACE WITH:

			  //If customer is looking at a product, add it to the list of products viewed
		  if (strstr($current_page, 'product_info.php')) {
		  $prodID = $HTTP_GET_VARS['products_id'];
		  $bracketPosition = 0;
		$bracketPosition = strpos($prodID, '{');
		if ($bracketPosition != 0){
			$cleanProdID = substr($prodID, 0, $bracketPosition);
		} else {
			$cleanProdID = $prodID;
		}
			$current_product_id = $cleanProdID;
			if (!strstr($products_viewed, '*' . $current_product_id . '?')) {
			  //Product hasn't been previously recorded as viewed
				$products_viewed .= '*' . $current_product_id . '?';
			}
		  }

 

Let me know if you all like the fix and I'll post a small update to the contrib.... :thumbsup:

 

 

Keith,

 

I had the same thing happen as you did earlier. Scared the crap out of me, because as you said it shut down the entire site. What I'm wondering is will this clean up the textarea field in the Option Type when a customer is on the "checkout_confirmation.php" page. We are getting customers who see the html code for an apostrophe (') rather than the apostrophe itself. So when they see this they go back to correct their message. What I'd like to do is instead of using the "tep_output_string_protected" function, I'd like to use the "tep_decode_specialchars" function on the "checkout_confirmation.php" page where it calls the product attribute. Will your fix enable me to do this?

 

Thanks!

Chris B.

Link to comment
Share on other sites

Hi

 

Just installed this great contrib and all seems to be OK, except for the following line that appears at the top of the SEO URLS page in the Configuration panel of the admin:

 

Warning: call_user_func(tep_reset_cache_data_seo_urls): First argument is expected to be a valid callback in /var/www/html/admin/includes/functions/general.php on line 1195

 

Can anyone please explain what this means and if it matters?

Link to comment
Share on other sites

Hi equilla,

This is one of the greatest contributions I've come across, hands down! I had an idea and thought that maybe your contribution would help materialize it. Well, here goes...

 

Using the region tracking function, would it be possible to create geo-targetted data on a page using bits and pieces of your contribution? It seems like your program already has the feature of identifying the region from which visitors are coming from, the question lies in how would i be able to use that logic in real-time on my homepage to manipulate some region-specific content on my homepage? For example what is the conditional statement I'd use to perform an action.

 

For Example:

 

if(visitor is from New York){

Perform new-york specific action;

}

else{

Perform default action;

}

 

 

Thanks,

Vaughn

Link to comment
Share on other sites

I'm using this contribution and it's giving me some really good results however I think I'm having some problems with compatibility with Ultimate SEO http://www.oscommerce.com/community/contributions,2823

 

I don't seem to be logging any clicks on products or categories at all because the URL is of the form

 

http://www.caradiaz.com/jewellery/milamey-m-11.html

 

with no reference at all to index.php or product_info.php.

I see on this support thread a few pages earlier where Mark said:

 

"It certainly shouldn't be a problem with SEO URLs - although the URL is rewritten, as far as Supertracker is concerned the page requested would still be product_info.php?products_id=xxx as so the SEO URLs contribution is totally transparent to it"

 

However I put a small diagnostic into supertracker.php

 

echo $current_page;

 

and it always shows the html URL form as above with no index.php or product_info.php in $current_page hence it is not surprising that supertracker.php is not picking up the clicks on these pages.

 

Is anyone else having this problem or do I need to reconfigure Ultimate SEO?

 

Thanks

Ed

Link to comment
Share on other sites

Please ignore the above post. I have reinstalled the contribution and i am receiving no errors. However the contribution isn't appearing in the 'Reports' section of the admin panel. Nothing seems to have happend. This is a bit of a mystery , can anyone help?

Link to comment
Share on other sites

Make sure you uploaded all files to catalog>admin

 

Or to put it another way, supertracker.php doesn't exist in admin>supertracker.php

Link to comment
Share on other sites

This contrib looks great - I've got it on a highly modified CRE 6.15 site - I can pull up everything fine in admin - but when I try adding

 

//Do the superstats business

require(DIR_WS_CLASSES . 'supertracker.php');

$tracker = new supertracker;

$tracker->update();

 

To the bottom of my catalog/includes/application_top.php

 

- it shuts down my catalog - you get nothing but blank pages.

 

Anybody else have this problem?

 

yikes what a newbie mistake! I hadn't decompressed the GeoIP.dat file

Link to comment
Share on other sites

Good morning.

 

Trying to load this contribution, and I think I've done everything correctly, but when I load my osCommerce page, I now get a stream of errors such as :

 

Warning: fopen(includes/GeoIP.dat): failed to open stream: No such file or directory in mydomain/includes/geoip.inc on line 322

 

Warning: ftell(): supplied argument is not a valid stream resource in

mydomain/includes/geoip.inc on line 276

 

Warning: fseek(): supplied argument is not a valid stream resource in

mydomain/includes/geoip.inc on line 277

 

Warning: fread(): supplied argument is not a valid stream resource in

mydomain/includes/geoip.inc on line 279

 

Warning: fseek(): supplied argument is not a valid stream resource in

mydomain/includes/geoip.inc on line 303

 

Warning: fread(): supplied argument is not a valid stream resource in

mydomain/includes/geoip.inc on line 279

 

ANY CLUES FOR AN IDIOT?

Link to comment
Share on other sites

I'm using this contribution and it's giving me some really good results however I think I'm having some problems with compatibility with Ultimate SEO http://www.oscommerce.com/community/contributions,2823

 

I don't seem to be logging any clicks on products or categories at all because the URL is of the form

 

http://www.caradiaz.com/jewellery/milamey-m-11.html

 

with no reference at all to index.php or product_info.php.

I see on this support thread a few pages earlier where Mark said:

However I put a small diagnostic into supertracker.php

 

echo $current_page;

 

and it always shows the html URL form as above with no index.php or product_info.php in $current_page hence it is not surprising that supertracker.php is not picking up the clicks on these pages.

 

Is anyone else having this problem or do I need to reconfigure Ultimate SEO?

 

Thanks

Ed

 

I have ultimate SEO it seems to work fine, the only place where you can see the actual products pages view is in the products coverage report I think.

 

Mark

 

Well done - great contribution.

 

Regarding the earlyMYSQL versions, pre- version 4.0, the problem is it needs the WHERE and ORDER by is not recognised.

 

I know nothing about MYSQL syntax but the following seems to work.

 

$del_query  = "DELETE from supertracker WHERE tracking_id>0 LIMIT " . $rows_to_delete;

 

It seems to start from the lowest tracking_id this way.

A quick question - when using shared SSL we see two records. The customer entering the non-SSL part carrying the real refferer and then the customer entering the SSL part and the refferer is the non-SSL URL. Anyway these records could be joined, especially after a sale.

 

Danny

 

 

Good fix, worked for me as well! :thumbsup:

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

Looking at installing this(finally! been keeping eye on it for awhile) and had a question:

 

I read a couple places about something in the database filling up and having to delete stuff. Is this a big issue? Can it be done in admin or does it have to be done in phpmyadmin? If it something that has to be constantly monitored?

 

Thanks guys, any info is appreciated.

Link to comment
Share on other sites

Looking at installing this(finally! been keeping eye on it for awhile) and had a question:

 

I read a couple places about something in the database filling up and having to delete stuff. Is this a big issue? Can it be done in admin or does it have to be done in phpmyadmin? If it something that has to be constantly monitored?

 

Thanks guys, any info is appreciated.

 

It's only an issue if you have lots of visitors and your server space is running out.

 

There is an option in this contribution to delete rows (however, it currently doesn't work for me, (as there is an error) and someone else has posted an error in this forum about the row deletion in Supertracker not woking. Mark is aware of this and thinks it might be an older version of SQL, so you may not have the problem. I am currently administering it through phpmyadmin, as this contribution created a new table in the database, and it's fairly easy to see/edit and delete records there.

Link to comment
Share on other sites

I went ahead and installed. Really nice contrib!

 

The dB row delete feature seems to work fine for me.... im running PHP V. 4.3.11 if that matters.

 

A couple 'tacky' little things I was wondering about.......why is there a GO button beside the dropdown selection box, since it automatically goes to whatever you select anyhow? And why does the color of the graph change everytime I select "visitors country stats"? In no way big issues at all.....im basically just curious :P

 

The last idea posted in the developement thread I thought was good, anybody have thoughts on that? Basically about removing bot crawls from the "last ten visitors" section so that you only see real peoples browsing habits.

Link to comment
Share on other sites

I just installed this contribution, but seem to have run into a snag. Right after completing the last new install step, I go to my site, and see this:

 

1364 - Field 'cart_contents' doesn't have a default value

 

INSERT INTO `supertracker` (`ip_address`, `browser_string`, `country_code`, `country_name`, `referrer`,`referrer_query_string`,`landing_page`,`exit_page`,`time_arrived`,`last_click`) VALUES ('192.168.1.1','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 (ax)','', '', 'http://www.domain.com/', '','/catalog/index.php','/catalog/index.php','2005-12-04 00:43:52','2005-12-04 00:43:52')

 

[TEP STOP]

 

:huh:

 

Admin page is working fine.

 

Help is very much appreciated :thumbsup:

Edited by doctorstupid
Link to comment
Share on other sites

I just installed this contribution, but seem to have run into a snag. Right after completing the last new install step, I go to my site, and see this:

 

1364 - Field 'cart_contents' doesn't have a default value

 

INSERT INTO `supertracker` (`ip_address`, `browser_string`, `country_code`, `country_name`, `referrer`,`referrer_query_string`,`landing_page`,`exit_page`,`time_arrived`,`last_click`) VALUES ('192.168.1.1','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 (ax)','', '', 'http://www.domain.com/', '','/catalog/index.php','/catalog/index.php','2005-12-04 00:43:52','2005-12-04 00:43:52')

 

[TEP STOP]

 

:huh:

 

Admin page is working fine.

 

Help is very much appreciated :thumbsup:

 

Hi,

 

I'm just wondering why no one else has reported this problem as there is an obvious issue here. The cart_contents field is set to NOT NULL and has no default value set. As this is not set when a new visitor arrives you get this problem. Perhaps MySQL on your system is set to be less tolerant of such errors than the rest of us, or perhaps MySQL on other systems is taking the default as "empty string".

 

The solution I believe would be to use phpmyadmin change this field to allow NULL values. You may also need to make this change for other fields, such as products_viewed and categories_viewed.

 

If you could report back on this - once we have the definite solution I can adjust the contrib accordingly in the next build.

 

BTW everybody, I've been away for the last couple of weeks which I why I haven't been around on the forums. I note that there are some suggestions, etc, for the next release which look good and I will be looking at these in due course.

 

Regards,

 

 

 

Mark

Link to comment
Share on other sites

Wow, thanks for the fast reply!

 

I'm VERY new to this php and mysql stuff, I do have phpmyadmin installed, but have not used it (a friend handled the install and configuration of php and mysql for me, local server).

 

I hate to ask, but do you think you could dumb it down a shade? I have no clue what I'm doing here. I have fixed a couple issues on my own, but those were somewhat straight-forward. I searched around and found that nobody else has had this problem (that I could find), so it's likely something in my configuration.

 

Running:

PHP4

MySQL5

Apache2

Windows 2000 Adv. Server

Link to comment
Share on other sites

Nevermind, I fooled around in phpmyadmin (never having actually run it before), managed to clumsily stumble my way into the right area, enabled NULL, default value was set to NULL automatically after this, and BEHOLD! IT WORKS!

 

So far no problems, I'm sure I'll be back here bugging you if I find any more issues.

 

Thanks a million for the help, turns out I'm not completely worthless after all :)

Edited by doctorstupid
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...