Jump to content
jpweber

Quantity Price Breaks

Recommended Posts

Now, when installing the "Product Attrib- Option Type Feature" contribution it shows me the following error:

 

Fatal error: Call to undefined method shoppingCart::get_product_id_list() in C:\xampp\htdocs\catalog\includes\classes\PriceFormatterStore.php on line 22

 

this is currently tested on my local server.

 

it is only happening when adding the includes\classes\shopping_cart.php from the OTF contrib.

That function is a standard function in the class shopping_cart:

	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);
}

Somebody must have messed up when he/she modified that class for the OTF contribution.

Share this post


Link to post
Share on other sites
Somebody must have messed up when he/she modified that class for the OTF contribution.

 

That's why is weired: its the same! there is no change to this function... (check before, and now with our code: it is similar)

 

Well, i hate doing it, but here is my code of the modified \class\shopping_cart.php the lead to this error.

 

p.s.

1. Thanks a lot for the fast reply

2. If it not the place to post codes <maybe PM(?)> pls say so... :blush:

Edited by sukarya

Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
That's why is weired: its the same! there is no change to this function... (check before, and now with our code: it is similar)

I downloaded the OTF contribution (last version) and indeed the function is there and not somewhere in a piece of code that had a brace missing or something like that.

 

The PriceFormatterStore is included after the inclusion of the shopping cart (somewhere around line 137)?

// include shopping cart class
 require(DIR_WS_CLASSES . 'shopping_cart.php');

Share this post


Link to post
Share on other sites
I downloaded the OTF contribution (last version) and indeed the function is there and not somewhere in a piece of code that had a brace missing or something like that.

 

The PriceFormatterStore is included after the inclusion of the shopping cart (somewhere around line 137)?

 

If you are talking about the application_top then - yes, the priceformatterStore (+priceformatter) are way around the 275 row...

 

here is the \classes\hopping_cart.php, maybe you can see something...

 

  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'])) {
			// OTF contrib begins
			//tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $option . "', '" . $value . "')");
			$attr_value = $this->contents[$products_id]['attributes_values'][$option];
			$query_raw = "insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')";
			tep_db_query($query_raw);
			// OTF contrib ends
		  }
		}
	  } 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 . "'");
  // BOF QPBPP, price break per per base products_id
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity'], 'base_pid' => (int)$products['products_id']);
// EOF QPBPP, price break per base products_id		
// attributes
	// OTF contrib begins
	//$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $customer_id . "' and products_id = '" . $products['products_id'] . "'");
	$attributes_query_raw = "select products_options_id, " . 
	  "products_options_value_id, products_options_value_text from " . 
	  TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . 
	  (int)$customer_id . "' and products_id = '" . 
	  tep_db_input($products['products_id']) . "'";
	$attributes_query = tep_db_query($attributes_query_raw);		
	// OTF contrib ends

	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	 // OTF contrib begins
	 if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
		$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
	  }	  
	  // OTF contrib ends
	}
  }

  $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;

 global $languages_id;

  $pf = new PriceFormatter;
  $pf->loadProduct($products_id, $languages_id);
  $qty = $pf->adjustQty($qty);
  $base_pid = $pf->get_base_pid();

  $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');
  }
// BOF QPBPP, price break per base products_id

// EOF QPBPP, price break per base products_id
// OTF contrib begins
/*
		 if ($this->in_cart($products_id)) {
		$this->update_quantity($products_id, $qty, $attributes, $base_pid); //added base products_id
	  } else {
		$this->contents[$products_id] = array('qty' => $qty, 'base_pid' => $base_pid); //added base products_id
*/
	  if ($this->in_cart($products_id)) {
		$this->update_quantity($products_id, $qty, $attributes, $base_pid);
	  } else {
		$this->contents[] = array($products_id);
		$this->contents[$products_id] = array('qty' => $qty, 'base_pid' => $base_pid);
// OTF contrib ends


// insert into database
// OTF contrib begins
		//if (tep_session_is_registered('customer_id') && $customer_id>0) 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) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");
		  if (tep_session_is_registered('customer_id') && $customer_id>0) 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) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");
// OTF contrib ends

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
	   // OTF contrib begins
		//$this->contents[$products_id]['attributes'][$option] = $value;
		$attr_value = NULL;
		$blank_value = FALSE;
		if (strstr($option, TEXT_PREFIX)) {
		  if (trim($value) == NULL)
		  {
			$blank_value = TRUE;
		  } else {
			$option = substr($option, strlen(TEXT_PREFIX));
			$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
			$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
			$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		  }
		}

		if (!$blank_value)
		{
		  $this->contents[$products_id]['attributes'][$option] = $value;
// OTF contrib ends
 // insert into database
			// OTF contrib begins
			//if (tep_session_is_registered('customer_id') && $customer_id>0) 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 . "')");
			  if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
			}
			// OTF contrib ends
	  }
	}
  }
  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
// OTF contrib begins
//	  $this->cartID = $this->generate_cart_id();
//	}
	$this->cartID = $this->generate_cart_id();
  }
}
// OTF contrib ends
// update_quantity modified for QPBPP, price break per base products_id
function update_quantity($products_id, $quantity = '', $attributes = '', $base_pid = '') {
  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, 'base_pid' => $base_pid); //added base products_id
// update database

// OTF contrib begins
  //if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
// OTF contrib ends
  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	   // OTF contrib begins
	  //$this->contents[$products_id]['attributes'][$option] = $value;
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value)
	  {
		$this->contents[$products_id]['attributes'][$option] = $value;
	  // OTF contrib ends
// update database

		// OTF contrib begins
		//if (tep_session_is_registered('customer_id') && $customer_id>0) 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 . "'");
		if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); 
		// OTF contrib ends
   }
  }
}

function cleanup() {
  global $customer_id;
// OTF contrib begins
  $products_id = tep_get_uprid($products_id, $attributes);
// OTF contrib ends
  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);
// start Get 1 free
	  // If this product qualifies for free product(s) add in the number of free products
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		$total_items += $free_product['quantity'];
	  }
// end Get 1 free
	}
  }

  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) . "'");
  }

// start Get 1 Free
	  // If this product qualifies for free product(s) remove the free products
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		$pid = (int)$free_product['id'];
		print '<br>Found Product: ' . $pid;
		unset($this->contents[$pid]);
		// 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($pid) . "'");
		  tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($pid) . "'");
		}
	  }
// end Get 1 Free

// 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() {
  global $languages_id;
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;
//	   BOF QPBPP, price break per base products_id
 $base_pid_quantity = array(); // calculates no of items per category in shopping basket
  foreach ($this->contents as $products_id => $contents_array) {
	  if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
	 $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
	  } else {
	 $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
	  }
  } // end foreach
//   EOF QPBPP, price break per base products_id

  $pf = new PriceFormatter;

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


// products price
	 if ($product = $pf->loadProduct($products_id, $languages_id)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $pf->computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid);
	  $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'];
	  } */
//Impulse Item by jfj
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " 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'];
	  }
//Impulse Item by jfj
	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);

// start Get 1 Free
		 // If this product qualifies for free product(s) add in the total weight of free products
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		$this->weight += $free_product['quantity'] * $free_product['weight'];
	  }
// end Get 1 Free
	}

// 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);
		}
	  }
	}
  }
}

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;
}

function get_products() {
  global $languages_id;

  if (!is_array($this->contents)) return false;
  //   BOF QPBPP, price break per base products_id	
  $base_pid_quantity = array();
  foreach ($this->contents as $products_id => $contents_array) {
	  if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
	 $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
	  } else {
	 $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
	  }
  } // end foreach
//   EOF QPBPP, price break per base products_id 
  $pf = new PriceFormatter;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	if ($products = $pf->loadProduct($products_id, $languages_id)) {
	  $qty = $this->contents[$products_id]['qty'];
	$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
	$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

	$products_price = $pf->computePrice($this->contents[$products_id]['qty'], $no_of_other_items_in_cart_with_same_base_pid);
	$products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								//   BOF QPBPP, price break per base products_id
								'base_pid' => $this->contents[$products_id]['base_pid'],
//   EOF QPBPP, price break per base products_id
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],

																	// OTF contrib begins
								//'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
								'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
								// OTF contrib ends

// start Get 1 free
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		// Add the free product to the shopping cart (Customer cannot alter this)
		$products_array[] = array('id' => $free_product['id'],
								  'name' => $free_product['name'],
								  'model' => $free_product['model'],
								  'image' => $free_product['image'],
								  'price' => 0,
								  'quantity' => $free_product['quantity'],
								  'weight' => $free_product['weight'],
								  'final_price' => 0,
								  'tax_class_id' => $products['products_tax_class_id'],
								  'attributes' => ''
								 );
	  } //if (is_array
// end Get 1 free									
	}
  }

  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() {
  // start indvship
  global $shipping_modules; 
  // end indvship
  $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'];
  }
}
// start Get 1 Free
function get1free ($products_id) {
  global $languages_id;
  $get_1_free_query = tep_db_query("select products_free_id,
										   products_free_quantity,
										   products_qualify_quantity,
										   products_multiple,
										   get_1_free_expires_date
									from " . TABLE_GET_1_FREE . "
									where products_id = '" . (int)$products_id . "'
									  and status = '1'"
								  );
  if (tep_db_num_rows($get_1_free_query) > 0) {
	$get_1_free = tep_db_fetch_array($get_1_free_query);
	//Check that the offer has not expired
	//if ($get_1_free['get_1_free_expires_date'] <= date('Y-m-d H:i:s')) {
	//BUG FIX
	if (($get_1_free['get_1_free_expires_date'] <= date('Y-m-d H:i:s'))&&($get_1_free['get_1_free_expires_date']!='0000-00-00 00:00:00')) {
	  //offer has expired, so update the database and return false
	  tep_db_query("update " . TABLE_GET_1_FREE . "
					set status = '0',
						date_status_change = now()
					where products_id = '" . (int)$prid . "'"
				  );
	  return false;
	} else {
	  // Offer is valid, so check if the quantity qualifies
	  $products_quantity = $this->contents[$products_id]['qty'];
	  if ($products_quantity >= $get_1_free['products_qualify_quantity']) {
		// Qualifies, so get the quantity of free products
		$free_quantity = 1;
		if ($get_1_free['products_multiple'] > 1) {
		  $free_quantity = floor ($products_quantity / $get_1_free['products_qualify_quantity']);
		  if ($free_quantity > $get_1_free['products_multiple']) {
			$free_quantity = $get_1_free['products_multiple'];
		  }
		}
		// Get the info on the free product
		$products_free_query = tep_db_query("select pd.products_name,
													p.products_model,
													p.products_image,
													p.products_weight
											 from " . TABLE_PRODUCTS . " p,
												  " . TABLE_PRODUCTS_DESCRIPTION . " pd
											 where p.products_id = '" . (int)$get_1_free['products_free_id'] . "'
											   and pd.products_id = p.products_id
											   and pd.language_id = '" . (int)$languages_id . "'"
										   );
		$products_free = tep_db_fetch_array($products_free_query);
		// Return an array of free product values
		$output = array ( 'id' => $get_1_free['products_free_id'],
						  'quantity' => $free_quantity,
						  'name' => $products_free['products_name'],
						  'model' => $products_free['products_model'],
						  'image' => $products_free['products_image'],
						  'weight' => $products_free['products_weight']
						);
		return $output;
	  } //if ($products_quantity
	} //else
  }//if (tep_db_num_rows
  // offer was not valid (disabled or expired)
  return false;
}//function
// end Get 1 Free


 }
?>


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
If you are talking about the application_top then - yes, the priceformatterStore (+priceformatter) are way around the 275 row...

 

here is the \classes\shopping_cart.php, maybe you can see something...

After some searching where my text editor is helpful in finding the complementary brace (for example the one that starts after function blabla() {) I found you added one at the end of the function function add_cart:

        $this->cartID = $this->generate_cart_id();
      }
//    } one brace too many here
// OTF contrib ends
    // update_quantity modified for QPBPP, price break per base products_id
    function update_quantity($products_id, $quantity = '', $attributes = '', $base_pid = '') {

and was missing one at the end of the function update_quantity (around line 227):

            // OTF contrib ends
       }
      }
    }
 } // missing ending brace here

    function cleanup() {

Share this post


Link to post
Share on other sites
After some searching where my text editor is helpful in finding the complementary brace (for example the one that starts after

 

 

Well, you have done it again :thumbsup: :thumbsup: (two thumbs up) Thanks a LOT !!!

 

may i ask what is the editor that you are using?


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
may i ask what is the editor that you are using?

I'm on a Mac so I use the Mac specific one TextWrangler but I also use JEdit which is for several platforms and FOSS (TextWrangler is "only" free). Both editors have that option (clicking your cursor next to a brace and see the complimentary one). I guess more editors will have that but for a long time I never knew TextWrangler (little sister from BBEdit which I use at work) had it too.

Share this post


Link to post
Share on other sites
little sister from BBEdit which I use at work) had it too.

 

Best to the sister, and best to you.

 

Sharon.


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
Best to the sister, and best to you.

 

Sharon.

 

JanZ,

 

As much as I feel :blush: asking your help again, it seems that there is an issue between QPBPP and Option Type Feature contribs:

 

When using the textarea/textfield i get the following error, that looks like it's from PriceFormatterStore.php

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1) and pd.language_id = '1'' at line 1

 

select pd.products_name, p.products_model, p.products_image, p.products_id, p.manufacturers_id, p.products_price, p.products_weight, p.products_quantity, p.products_price1, p.products_price2, p.products_price3,p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price from products p left join specials s on p.products_id = s.products_id, products_description pd where p.products_status = '1' and pd.products_id = p.products_id and p.products_id in (1, 1, 1, 1,, 1) and pd.language_id = '1'

 

TMHO, it has something to do with p.products_id in (1, 1, 1, 1,, 1). Can you direct me where/how to proceed to fix it, or maybe it has nothing to do with QPBPP, and only with the the Option type...

 

Thanks (yet again...)

Sharon.


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
When using the textarea/textfield i get the following error, that looks like it's from PriceFormatterStore.php

TMHO, it has something to do with p.products_id in (1, 1, 1, 1,, 1). Can you direct me where/how to proceed to fix it, or maybe it has nothing to do with QPBPP, and only with the the Option type...

It might have something to do with Option type changing the function tep_get_prid that was changed some time ago back to the old function. Not sure. However, try changing (starts around line 31 in PriceFormatterStore.php):

 

		  $valid_value = tep_get_prid($value);
	  if (tep_not_null($valid_value)) {
				  $product_id_list_array[] = $valid_value;
	  }
			}
			unset($product_id_list);
			$product_id_list = implode(",", $product_id_list_array);

To:

		  $valid_value = tep_get_prid($value);
	  if ((int)$valid_value != 0) {
				  $product_id_list_array[] = $valid_value;
	  }
			}
			unset($product_id_list);
			$product_id_list_array = array_unique($product_id_list_array);
			$product_id_list = implode(",", $product_id_list_array);

Share this post


Link to post
Share on other sites
It might have something to do with Option type changing the function tep_get_prid that was changed some time ago back to the old function. Not sure. However, try changing (starts around line 31 in PriceFormatterStore.php):

 

Thanks.

I actually got into the code in the PriceFormatterStore as in order to change it as you said - then i saw that it was the old version (12/2006) rather than the new one (01/2007). changed it to the new one - and it was fixed.

 

However, and as much as i spent hours (loooooong hours) before asking here again, it seems that the cost of the TEXT attribute in the OTF is not adding up in the shopping cart. I have reeeeeeeeeally looked and drilled down but nada...

 

have any ideas?


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
it seems that the cost of the TEXT attribute in the OTF is not adding up in the shopping cart. I have reeeeeeeeeally looked and drilled down but nada...

 

have any ideas?

I looked at OTF because I anticipated problems with the hide_attribute functions in 4.2.0 and OTF and wasn't thrilled with the code (especially when a few small changes were made to osC). I never finished it, stopped at the last hurdle (on product_info.php) but did manage to fix a few things here and there. OTF for example stores empty text as an attribute... rather silly.

 

But I can't recall that I had problems with the text cost not adding up.

 

This is what I had almost a year ago (was that before RC1?):

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $
adapted for Separate Pricing Per Customer v4.2 2007/01/01
Option Type Feature 2007/01/01

 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);
// BOF SPPC attribute hide/invalid check: loop through the shopping cart and check the attributes if they
// are hidden for the now logged-in customer
  $this->cg_id = $this->get_customer_group_id();
	while (list($products_id, ) = each($this->contents)) {
				// only check attributes if they are set for the product in the cart
			   if (isset($this->contents[$products_id]['attributes'])) {
			$check_attributes_query = tep_db_query("select options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . tep_get_prid($products_id) . "'");
			while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) {
				$check_attributes[] = $_check_attributes;
			} // end while ($_check_attributes = tep_db_fetch_array($check_attributes_query))
			$no_of_check_attributes = count($check_attributes);
			$change_products_id = '0';

			foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) {
				$valid_option = '0';
				for ($x = 0; $x < $no_of_check_attributes; $x++) {
					if ($attr_option == $check_attributes[$x]['options_id'] && $attr_option_value == $check_attributes[$x]['options_values_id']) {
						$valid_option = '1';
						if ($check_attributes[$x]['hide_attr_status'] == '1') {
						// delete hidden attributes from array attributes, change products_id accordingly later
						$change_products_id = '1';
						unset($this->contents[$products_id]['attributes'][$attr_option]);
						}
					} // end if ($attr_option == $check_attributes[$x]['options_id']....
				} // end for ($x = 0; $x < $no_of_check_attributes; $x++)
				// added a check for TEXT options (Option Type Feature), which are not listed in the table
				// products_attributes so are not "valid options" in this code
				if ($valid_option == '0' && !strstr($attr_option, TEXT_PREFIX)) {
					// after having gone through the options for this product and not having found a matching one
					// we can conclude that apparently this is not a valid option for this product so remove it
					unset($this->contents[$products_id]['attributes'][$attr_option]);
					// change products_id accordingly later
					$change_products_id = '1';
				}
			} // end foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value)

	  if ($change_products_id == '1') {
		   $original_products_id = $products_id;
		   $products_id = tep_get_prid($original_products_id);
					 // modified for Option Type Feature v 1.7.2
					 foreach ($this->contents[$original_products_id]['attributes'] as $attr_option => $attr_option_value) {
						 if ($attr_option_value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
							 $params[$attr_option] =  $this->contents[$original_products_id]['attributes_values'][$attr_option];
						 } else {
							 $params[$attr_option] = $this->contents[$original_products_id]['attributes'][$attr_option];
					   }
					 } // end foreach ($this->contents[$original_products_id]['attributes'] etc.
					 $products_id = tep_get_uprid($products_id, $params);
					 // add the product without the hidden attributes to the cart
		   $this->contents[$products_id] = $this->contents[$original_products_id];
				 // delete the originally added product with the hidden attributes
		   unset($this->contents[$original_products_id]);
		}
			  } // end if (isset($this->contents[$products_id]['attributes']))
			} // end while (list($products_id, ) = each($this->contents)) 
   reset($this->contents); // reset the array otherwise the cart will be emptied
// EOF SPPC attribute hide/invalid check
	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'])) {
			//clr 031714 udate query to include attribute value. This is needed for text attributes.
			$attr_value = $this->contents[$products_id]['attributes_values'][$option];
			tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_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
	//CLR 020606 update query to pull attribute value_text. This is needed for text attributes.
			$attributes_query_text[] = "select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'";
	$attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text 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'];
	  //CLR 020606 if text attribute, then set additional information
	  if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
		$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
	  }
	}
  }
  $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;
// BOF Separate Pricing Per Customer 
  $this->cg_id = $this->get_customer_group_id();
// EOF Separate Pricing Per Customer
  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
			$change_products_id = 0;
	while (list($option, $value) = each($attributes)) {
				// Option Type Feature 1.7.2: let text attributes pass
				if (strstr($option, TEXT_PREFIX)) { 
					if (trim($value) == NULL) {
						// remove empty text attributes
						unset($attributes[$option]);
						$change_products_id = 1;
					}
				continue; 
				} // end if (strstr($option, TEXT_PREFIX))
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }
		// remove empty text attributes from products_id

  if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {
// BOF SPPC attribute hide check, original query expanded to include attributes
			$check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'");
			while ($_check_product = tep_db_fetch_array($check_product_query)) {
				$check_product[] = $_check_product;
			} // end while ($_check_product = tep_db_fetch_array($check_product_query))
			$no_of_check_product = count($check_product);

 if (is_array($attributes)) {
			foreach($attributes as $attr_option => $attr_option_value) {
				$valid_option = '0';
				for ($x = 0; $x < $no_of_check_product; $x++) {
					if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) {
						$valid_option = '1';
						if ($check_product[$x]['hide_attr_status'] == '1') {
						// delete hidden attributes from array attributes
						unset($attributes[$attr_option]);
						}
					} // end if ($attr_option == $check_product[$x]['options_id']....
				} // end for ($x = 0; $x < $no_of_check_product; $x++)
				// added a check for TEXT options (Option Type Feature), which are not listed in the table
				// products_attributes so are not "valid options" in this code
				if ($valid_option == '0'  && !strstr($attr_option, TEXT_PREFIX)) {
					// after having gone through the options for this product and not having found a matching one
					// we can conclude that apparently this is not a valid option for this product so remove it
					unset($attributes[$attr_option]);
				}
			} // end foreach($attributes as $attr_option => $attr_option_value)
} // end if (is_array($attributes))
// now attributes have been checked, empty, hidden and invalid ones deleted make the $products_id_string again
			$products_id_string = tep_get_uprid($products_id, $attributes);

	if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) {
// EOF SPPC attribute hide check
	  if ($notify == true) {
		$new_products_id_in_cart = $products_id_string;
		tep_session_register('new_products_id_in_cart');
	  }

	  if ($this->in_cart($products_id_string)) {
		$this->update_quantity($products_id, $qty, $attributes);
	  } else {
					// BOF Option Type Feature, old osC
					// $this->contents[] = array($products_id);
					// EOF Option Type Feature
		$this->contents[$products_id_string] = 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_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");

		if (is_array($attributes)) {
		  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		//CLR 020606 check if input was from text box.  If so, store additional attribute information
		//CLR 020708 check if text input is blank, if so do not add to attribute lists
		//CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
		  $attr_value = NULL;
		  $blank_value = FALSE;
		  if (strstr($option, TEXT_PREFIX)) {
			if (trim($value) == NULL)
			  {
				$blank_value = TRUE;
			 } else {
				$option = substr($option, strlen(TEXT_PREFIX));
				$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
				$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
				$this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
			  }
			}

			if (!$blank_value)
			{
		  $this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.
			//CLR 030228 add tep_db_input() processing
			  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, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_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;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
				// Option Type Feature 1.7.2: let text attributes pass
				if (strstr($option, TEXT_PREFIX)) { continue; }
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }

  if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) {

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

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
				// BOF Option Type Feature, reversing of products_id and $products_id_string as in the original
				// contribution (version 1.7.2 at least) is not added here
	  //CLR 020606 check if input was from text box.  If so, store additional attribute information
	  //CLR 030108 check if text input is blank, if so do not update attribute lists
	  //CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value) {
		$this->contents[$products_id_string]['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 . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");
				  } // end if (!$blank_value) EOF Option Type Feature
	  }
	}
  }
}

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;

  //BOF Option Type Feature CLR 030228 add call tep_get_uprid to correctly format product ids containing quotes
  $products_id = tep_get_uprid($products_id, $attributes);
		// EOF Option Type Feature

  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'];
// BOF Separate Pricing Per Customer
// global variable (session) $sppc_customer_group_id -> class variable cg_id
  $this->cg_id = $this->get_customer_group_id();
// EOF Separate Pricing Per Customer

// 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'];

// BOF Separate Pricing Per Customer
/*		 $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'];
	  } */
  $specials_price = tep_get_products_special_price((int)$prid);
  if (tep_not_null($specials_price)) {
 $products_price = $specials_price;
  } elseif ($this->cg_id != 0){
	$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id =  '" . $this->cg_id . "'");
	if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
	$products_price = $customer_group_price['customers_group_price'];
	}
	  }
// EOF Separate Pricing Per Customer

	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);
	}

// attributes price
// BOF SPPC attributes mod
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
   $where = " AND ((";
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	 $where .= "options_id = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR (";
   }
   $where=substr($where, 0, -5) . ')';

   $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");

   if (tep_db_num_rows($attribute_price_query)) { 
	   $list_of_prdcts_attributes_id = '';
			 // empty array $attribute_price
			 $attribute_price = array();
	   while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { 
	   $attribute_price[] =  $attributes_price_array;
	   $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].",";
		}
	   if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { 
	 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'");
 while ($pag_array = tep_db_fetch_array($pag_query)) {
	 $cg_attr_prices[] = $pag_array;
 }

 // substitute options_values_price and prefix for those for the customer group (if available)
 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
	for ($n = 0; $n < count($attribute_price); $n++) {
	 for ($i = 0; $i < count($cg_attr_prices); $i++) {
		 if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) {
			$attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
			$attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
		 }
	 } // end for ($i = 0; $i < count($cg_att_prices); $i++)
	  }
	} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
  } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
// now loop through array $attribute_price to add up/substract attribute prices

  for ($n = 0; $n < count($attribute_price); $n++) {
		if ($attribute_price[$n]['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price[$n]['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price[$n]['options_values_price'], $products_tax);
	}
  } // end for ($n = 0; $n < count($attribute_price); $n++)
	  } // end if (tep_db_num_rows($attribute_price_query))
	} // end if (isset($this->contents[$products_id]['attributes'])) 
  }
}
// EOF SPPC attributes mod

// function attributes_price changed partially according to FalseDawn's post
// http://forums.oscommerce.com/index.php?showtopic=139587
// changed completely for Separate Pricing Per Customer, attributes mod
function attributes_price($products_id) {
// global variable (session) $sppc_customer_group_id -> class variable cg_id
$this->cg_id = $this->get_customer_group_id();

  if (isset($this->contents[$products_id]['attributes'])) {
	reset($this->contents[$products_id]['attributes']);
   $where = " AND ((";
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	 $where .= "options_id = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR (";
   }
   $where=substr($where, 0, -5) . ')';

   $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");

  if (tep_db_num_rows($attribute_price_query)) {
	   $list_of_prdcts_attributes_id = '';
	   while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { 
	   $attribute_price[] =  $attributes_price_array;
	   $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].",";
	  }

	   if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { 
	 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'");
 while ($pag_array = tep_db_fetch_array($pag_query)) {
	 $cg_attr_prices[] = $pag_array;
 }

 // substitute options_values_price and prefix for those for the customer group (if available)
 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
	for ($n = 0; $n < count($attribute_price); $n++) {
	 for ($i = 0; $i < count($cg_attr_prices); $i++) {
		 if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) {
			$attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
			$attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
	}
	 } // end for ($i = 0; $i < count($cg_att_prices); $i++)
  }
	} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
  } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
// now loop through array $attribute_price to add up/substract attribute prices

  for ($n = 0; $n < count($attribute_price); $n++) {
		if ($attribute_price[$n]['price_prefix'] == '+') {
		  $attributes_price += $attribute_price[$n]['options_values_price'];
		} else {
		  $attributes_price -= $attribute_price[$n]['options_values_price'];
		}
  } // end for ($n = 0; $n < count($attribute_price); $n++)
  return $attributes_price;
   } else { // end if (tep_db_num_rows($attribute_price_query))
	 return 0;
   } 
 }  else { // end if (isset($this->contents[$products_id]['attributes']))
   return 0;
}
  } // end of function attributes_price, modified for SPPC with attributes

function get_products() {
  global $languages_id;
// BOF Separate Pricing Per Customer
// global variable (session) $sppc_customer_group_id -> class variable cg_id
 $this->cg_id = $this->get_customer_group_id();
// EOF Separate Pricing Per Customer

  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'];

// BOF Separate Pricing Per Customer
/*		  $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'];
	  } */
  $specials_price = tep_get_products_special_price($prid);
 if (tep_not_null($specials_price)) {
 $products_price = $specials_price;
  } elseif ($this->cg_id != 0){
	$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id =  '" . $this->cg_id . "'");
	if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
	$products_price = $customer_group_price['customers_group_price'];
	}
 }
// EOF Separate Pricing Per Customer

	  $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'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],
// BOF Option Type Feature next line original
						//	  'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
													'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''), 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
// EOF Option Type Feature
	}
  }

  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'];
  }
}

// added for Separate Pricing Per Customer, returns customer_group_id
	function get_customer_group_id() {
  if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
	$_cg_id = $_SESSION['sppc_customer_group_id'];
  } else {
	 $_cg_id = 0;
  }
		return $_cg_id;
	}
 }
?>

Share this post


Link to post
Share on other sites
I looked at OTF because I anticipated problems with the hide_attribute functions in 4.2.0 and OTF and wasn't thrilled with the code (especially when a few small changes were made to osC). I never finished it, stopped at the last hurdle (on product_info.php) but did manage to fix a few things here and there. OTF for example stores empty text as an attribute... rather silly.

 

But I can't recall that I had problems with the text cost not adding up.

 

This is what I had almost a year ago (was that before RC1?):

 

ok. ill compare the tow files and hope for meaningful results...

 

I appreciate your efforts, for me and for the rest of this fine community.

 

Sharon.


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
ok. ill compare the tow files and hope for meaningful results...

 

I appreciate your efforts, for me and for the rest of this fine community.

 

Sharon.

 

Sat for hours and hours, looked and compared versions and file, but nothing. The text attribute value is not being added to the shopping cart.

 

Here is my \class\shopping_cart.php. My next step will be to post it as a new post...

 

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $
adapted for QPBPP, per "base products_id" 2007/01/05

*/

 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'])) {
			// OTF contrib begins
			//tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $option . "', '" . $value . "')");
			$attr_value = $this->contents[$products_id]['attributes_values'][$option];
			$query_raw = "insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')";
			tep_db_query($query_raw);
			// OTF contrib ends
		  }
		}
	  } 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 . "'");
  // BOF QPBPP, price break per per base products_id
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity'], 'base_pid' => (int)$products['products_id']);
// EOF QPBPP, price break per base products_id		
// attributes
	// OTF contrib begins
	//$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $customer_id . "' and products_id = '" . $products['products_id'] . "'");
	$attributes_query_raw = "select products_options_id, " . 
	  "products_options_value_id, products_options_value_text from " . 
	  TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . 
	  (int)$customer_id . "' and products_id = '" . 
	  tep_db_input($products['products_id']) . "'";
	$attributes_query = tep_db_query($attributes_query_raw);		
	// OTF contrib ends

	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	 // OTF contrib begins
	 if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
		$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
	  }	  
	  // OTF contrib ends
	}
  }

  $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;

 global $languages_id;

  $pf = new PriceFormatter;
  $pf->loadProduct($products_id, $languages_id);
  $qty = $pf->adjustQty($qty);
  $base_pid = $pf->get_base_pid();

  $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');
  }
// BOF QPBPP, price break per base products_id

// EOF QPBPP, price break per base products_id
// OTF contrib begins
/*
		 if ($this->in_cart($products_id)) {
		$this->update_quantity($products_id, $qty, $attributes, $base_pid); //added base products_id
	  } else {
		$this->contents[$products_id] = array('qty' => $qty, 'base_pid' => $base_pid); //added base products_id
*/
	  if ($this->in_cart($products_id)) {
		$this->update_quantity($products_id, $qty, $attributes, $base_pid);
	  } else {
		$this->contents[] = array($products_id);
		$this->contents[$products_id] = array('qty' => $qty, 'base_pid' => $base_pid);
// OTF contrib ends


// insert into database
// OTF contrib begins
		//if (tep_session_is_registered('customer_id') && $customer_id>0) 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) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");
		  if (tep_session_is_registered('customer_id') && $customer_id>0) 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) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");
// OTF contrib ends

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
	   // OTF contrib begins
		//$this->contents[$products_id]['attributes'][$option] = $value;
		$attr_value = NULL;
		$blank_value = FALSE;
		if (strstr($option, TEXT_PREFIX)) {
		  if (trim($value) == NULL)
		  {
			$blank_value = TRUE;
		  } else {
			$option = substr($option, strlen(TEXT_PREFIX));
			$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
			$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
			$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		  }
		}

		if (!$blank_value)
		{
		  $this->contents[$products_id]['attributes'][$option] = $value;
// OTF contrib ends
 // insert into database
			// OTF contrib begins
			//if (tep_session_is_registered('customer_id') && $customer_id>0) 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 . "')");
			  if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
			}
			// OTF contrib ends
	  }
	}
  }
  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
// OTF contrib begins
//	  $this->cartID = $this->generate_cart_id();
//	}
	$this->cartID = $this->generate_cart_id();
  }
//}
// OTF contrib ends
// update_quantity modified for QPBPP, price break per base products_id
function update_quantity($products_id, $quantity = '', $attributes = '', $base_pid = '') {
  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, 'base_pid' => $base_pid); //added base products_id
// update database

// OTF contrib begins
  //if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
// OTF contrib ends
  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	   // OTF contrib begins
	  //$this->contents[$products_id]['attributes'][$option] = $value;
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value)
	  {
		$this->contents[$products_id]['attributes'][$option] = $value;
	  // OTF contrib ends
// update database

		// OTF contrib begins
		//if (tep_session_is_registered('customer_id') && $customer_id>0) 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 . "'");
		if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); 
		// OTF contrib ends
   }
  }
}
}
function cleanup() {
  global $customer_id;
// OTF contrib begins
  $products_id = tep_get_uprid($products_id, $attributes);
// OTF contrib ends
  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);
// start Get 1 free
	  // If this product qualifies for free product(s) add in the number of free products
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		$total_items += $free_product['quantity'];
	  }
// end Get 1 free
	}
  }

  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) . "'");
  }

// start Get 1 Free
	  // If this product qualifies for free product(s) remove the free products
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		$pid = (int)$free_product['id'];
		print '<br>Found Product: ' . $pid;
		unset($this->contents[$pid]);
		// 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($pid) . "'");
		  tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($pid) . "'");
		}
	  }
// end Get 1 Free

// 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() {
  global $languages_id;
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;
//	   BOF QPBPP, price break per base products_id
 $base_pid_quantity = array(); // calculates no of items per category in shopping basket
  foreach ($this->contents as $products_id => $contents_array) {
	  if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
	 $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
	  } else {
	 $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
	  }
  } // end foreach
//   EOF QPBPP, price break per base products_id

  $pf = new PriceFormatter;

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


// products price
	 if ($product = $pf->loadProduct($products_id, $languages_id)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $pf->computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid);
	  $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'];
	  } */
//Impulse Item by jfj
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " 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'];
	  }
//Impulse Item by jfj
	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);

// start Get 1 Free
		 // If this product qualifies for free product(s) add in the total weight of free products
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		$this->weight += $free_product['quantity'] * $free_product['weight'];
	  }
// end Get 1 Free
	}

// 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);
		}
	  }
	}
  }
}

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;
}

function get_products() {
  global $languages_id;

  if (!is_array($this->contents)) return false;
  //   BOF QPBPP, price break per base products_id	
  $base_pid_quantity = array();
  foreach ($this->contents as $products_id => $contents_array) {
	  if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
	 $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
	  } else {
	 $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
	  }
  } // end foreach
//   EOF QPBPP, price break per base products_id 
  $pf = new PriceFormatter;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	if ($products = $pf->loadProduct($products_id, $languages_id)) {
	  $qty = $this->contents[$products_id]['qty'];
	$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
	$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

	$products_price = $pf->computePrice($this->contents[$products_id]['qty'], $no_of_other_items_in_cart_with_same_base_pid);
	$products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								//   BOF QPBPP, price break per base products_id
								'base_pid' => $this->contents[$products_id]['base_pid'],
//   EOF QPBPP, price break per base products_id
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],

																	// OTF contrib begins
								//'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
								'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
								// OTF contrib ends

// start Get 1 free
	  if (is_array ($free_product = $this->get1free ($products_id))) {
		// Add the free product to the shopping cart (Customer cannot alter this)
		$products_array[] = array('id' => $free_product['id'],
								  'name' => $free_product['name'],
								  'model' => $free_product['model'],
								  'image' => $free_product['image'],
								  'price' => 0,
								  'quantity' => $free_product['quantity'],
								  'weight' => $free_product['weight'],
								  'final_price' => 0,
								  'tax_class_id' => $products['products_tax_class_id'],
								  'attributes' => ''
								 );
	  } //if (is_array
// end Get 1 free									
	}
  }

  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() {
  // start indvship
  global $shipping_modules; 
  // end indvship
  $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'];
  }
}
// start Get 1 Free
function get1free ($products_id) {
  global $languages_id;
  $get_1_free_query = tep_db_query("select products_free_id,
										   products_free_quantity,
										   products_qualify_quantity,
										   products_multiple,
										   get_1_free_expires_date
									from " . TABLE_GET_1_FREE . "
									where products_id = '" . (int)$products_id . "'
									  and status = '1'"
								  );
  if (tep_db_num_rows($get_1_free_query) > 0) {
	$get_1_free = tep_db_fetch_array($get_1_free_query);
	//Check that the offer has not expired
	//if ($get_1_free['get_1_free_expires_date'] <= date('Y-m-d H:i:s')) {
	//BUG FIX
	if (($get_1_free['get_1_free_expires_date'] <= date('Y-m-d H:i:s'))&&($get_1_free['get_1_free_expires_date']!='0000-00-00 00:00:00')) {
	  //offer has expired, so update the database and return false
	  tep_db_query("update " . TABLE_GET_1_FREE . "
					set status = '0',
						date_status_change = now()
					where products_id = '" . (int)$prid . "'"
				  );
	  return false;
	} else {
	  // Offer is valid, so check if the quantity qualifies
	  $products_quantity = $this->contents[$products_id]['qty'];
	  if ($products_quantity >= $get_1_free['products_qualify_quantity']) {
		// Qualifies, so get the quantity of free products
		$free_quantity = 1;
		if ($get_1_free['products_multiple'] > 1) {
		  $free_quantity = floor ($products_quantity / $get_1_free['products_qualify_quantity']);
		  if ($free_quantity > $get_1_free['products_multiple']) {
			$free_quantity = $get_1_free['products_multiple'];
		  }
		}
		// Get the info on the free product
		$products_free_query = tep_db_query("select pd.products_name,
													p.products_model,
													p.products_image,
													p.products_weight
											 from " . TABLE_PRODUCTS . " p,
												  " . TABLE_PRODUCTS_DESCRIPTION . " pd
											 where p.products_id = '" . (int)$get_1_free['products_free_id'] . "'
											   and pd.products_id = p.products_id
											   and pd.language_id = '" . (int)$languages_id . "'"
										   );
		$products_free = tep_db_fetch_array($products_free_query);
		// Return an array of free product values
		$output = array ( 'id' => $get_1_free['products_free_id'],
						  'quantity' => $free_quantity,
						  'name' => $products_free['products_name'],
						  'model' => $products_free['products_model'],
						  'image' => $products_free['products_image'],
						  'weight' => $products_free['products_weight']
						);
		return $output;
	  } //if ($products_quantity
	} //else
  }//if (tep_db_num_rows
  // offer was not valid (disabled or expired)
  return false;
}//function
// end Get 1 Free


 }
?>


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites

please, anyone?


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
please, anyone?

The add_cart function seems like it should be working for text attributes. Are you sure the problem is there and not in application_top?

Share this post


Link to post
Share on other sites
Are you sure the problem is there and not in application_top?

 

I have modified the application top according to the "Broken quantity update after OTF" and" Quantity multiplier v.1.0 - final - attachement ones more" - both by dracono.

 

below is my application top {after going through the installation several times... :( }

Can you see something the might mess the text up?

// start the timer for the page parse time log
 define('PAGE_PARSE_START_TIME', microtime());

 //Query Check
 $debug = array();

// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);

// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
 if (function_exists('ini_get')) {
ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
 }

// Set the local configuration parameters - mainly for developers
 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// include server parameters
 require('includes/configure.php');

 if (strlen(DB_SERVER) < 1) {
if (is_dir('install')) {
  header('Location: install/index.php');
}
 }

// define the project version
 define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

// set the type of request (secure or not)
$request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';
 //$request_type = (getenv('HTTPS') == '1') ? 'SSL' : 'NONSSL';
 //$request_type = ($_SERVER['SERVER_PORT']==443) ? 'SSL' : 'NONSSL';
 //$request_type = (eregi ($HTTP_HOST, HTTPS_SERVER)) ? 'SSL' : 'NONSSL';// shared ssl 1and1
 //$request_type = (getenv('HTTP_X_FORWARDED_BY') == 'ssl.perfora.net') ? 'SSL' : 'NONSSL';

// set php_self in the local scope
 if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];

 if ($request_type == 'NONSSL') {
define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG);
 } else {
define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG);
 }

// include the list of project filenames
 require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
 require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout
 define('BOX_WIDTH', 150); // how wide the boxes should be in pixels (default: 125)

// include the database functions
 require(DIR_WS_FUNCTIONS . 'database.php');

// start indvship 
  /*function tep_get_configuration_key_value($lookup) {
$configuration_query_raw= tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='" . $lookup . "'");
$configuration_query= tep_db_fetch_array($configuration_query_raw);
$lookup_value= $configuration_query['configuration_value'];
return $lookup_value;
 }*/
// end indvship

// make a connection to the database... now
 tep_db_connect() or die('Unable to connect to database server!');

// set the application parameters
 $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
 while ($configuration = tep_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
 }

// if gzip_compression is enabled, start to buffer the output
 if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {
if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
  if (PHP_VERSION >= '4.0.4') {
	ob_start('ob_gzhandler');
  } else {
	include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
	ob_start();
	ob_implicit_flush();
  }
} else {
  ini_set('zlib.output_compression_level', GZIP_LEVEL);
}
 }

// set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
 if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
if (strlen(getenv('PATH_INFO')) > 1) {
  $GET_array = array();
  $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
  $vars = explode('/', substr(getenv('PATH_INFO'), 1));
  for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
	if (strpos($vars[$i], '[]')) {
	  $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
	} else {
	  $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
	}
	$i++;
  }

  if (sizeof($GET_array) > 0) {
	while (list($key, $value) = each($GET_array)) {
	  $HTTP_GET_VARS[$key] = $value;
	}
  }
}
 }

// define general functions used application-wide
 require(DIR_WS_FUNCTIONS . 'general.php');
 require(DIR_WS_FUNCTIONS . 'html_output.php');

// set the cookie domain
 $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
 $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);

// include cache functions if enabled
 if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');

// include shopping cart class
 require(DIR_WS_CLASSES . 'shopping_cart.php');

// include navigation history class
 require(DIR_WS_CLASSES . 'navigation_history.php');

// some code to solve compatibility issues
 require(DIR_WS_FUNCTIONS . 'compatibility.php');

// check if sessions are supported, otherwise use the php3 compatible session class
 if (!function_exists('session_start')) {
define('PHP_SESSION_NAME', 'Judaica');//Judaica Replaced osCsid
define('PHP_SESSION_PATH', $cookie_path);
define('PHP_SESSION_DOMAIN', $cookie_domain);
define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

include(DIR_WS_CLASSES . 'sessions.php');
 }

// define how the session functions will be used
 require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path
 tep_session_name('organic');//organic Replaced osCsid
 tep_session_save_path(SESSION_WRITE_DIRECTORY);

// set the session cookie parameters
  if (function_exists('session_set_cookie_params')) {
session_set_cookie_params(0, $cookie_path, $cookie_domain);
 } elseif (function_exists('ini_set')) {
ini_set('session.cookie_lifetime', '0');
ini_set('session.cookie_path', $cookie_path);
ini_set('session.cookie_domain', $cookie_domain);
 }

// set the session ID if it exists
  if (isset($HTTP_POST_VARS[tep_session_name()])) {
 tep_session_id($HTTP_POST_VARS[tep_session_name()]);
  } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) {
 tep_session_id($HTTP_GET_VARS[tep_session_name()]);
  }

// start the session
 $session_started = false;
 if (SESSION_FORCE_COOKIE_USE == 'True') {
tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
  tep_session_start();
  $session_started = true;
}
 } elseif (SESSION_BLOCK_SPIDERS == 'True') {
$user_agent = strtolower(getenv('HTTP_USER_AGENT'));
$spider_flag = false;

if (tep_not_null($user_agent)) {
  $spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

  for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
	if (tep_not_null($spiders[$i])) {
	  if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
		$spider_flag = true;
		break;
	  }
	}
  }
}

if ($spider_flag == false) {
  tep_session_start();
  $session_started = true;
}
 } else {
tep_session_start();
$session_started = true;
 }

// set SID once, even if empty
 $SID = (defined('SID') ? SID : '');

// verify the ssl_session_id if the feature is enabled
 if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) {
$ssl_session_id = getenv('SSL_SESSION_ID');
if (!tep_session_is_registered('SSL_SESSION_ID')) {
  $SESSION_SSL_ID = $ssl_session_id;
  tep_session_register('SESSION_SSL_ID');
}

if ($SESSION_SSL_ID != $ssl_session_id) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
}
 }

// verify the browser user agent if the feature is enabled
 if (SESSION_CHECK_USER_AGENT == 'True') {
$http_user_agent = getenv('HTTP_USER_AGENT');
if (!tep_session_is_registered('SESSION_USER_AGENT')) {
  $SESSION_USER_AGENT = $http_user_agent;
  tep_session_register('SESSION_USER_AGENT');
}

if ($SESSION_USER_AGENT != $http_user_agent) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_LOGIN));
}
 }

// verify the IP address if the feature is enabled
 if (SESSION_CHECK_IP_ADDRESS == 'True') {
$ip_address = tep_get_ip_address();
if (!tep_session_is_registered('SESSION_IP_ADDRESS')) {
  $SESSION_IP_ADDRESS = $ip_address;
  tep_session_register('SESSION_IP_ADDRESS');
}

if ($SESSION_IP_ADDRESS != $ip_address) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_LOGIN));
}
 }

// create the shopping cart & fix the cart if necesary
 if (tep_session_is_registered('cart') && is_object($cart)) {
if (PHP_VERSION < 4) {
  $broken_cart = $cart;
  $cart = new shoppingCart;
  $cart->unserialize($broken_cart);
}
 } else {
tep_session_register('cart');
$cart = new shoppingCart;
 }

 // include CountProductsStore object
 require(DIR_WS_CLASSES . 'CountProductsStore.php');
 $countproducts = new CountProductsStore();

// include currencies class and create an instance
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

// QuantityPriceBreaker
// include the price formatter classes for the price breaks contribution
 require(DIR_WS_CLASSES . 'PriceFormatter.php');
 $pf = new PriceFormatter;
 require(DIR_WS_CLASSES . 'PriceFormatterStore.php');
 $pfs = new PriceFormatterStore;
// include the mail classes
 require(DIR_WS_CLASSES . 'mime.php');
 require(DIR_WS_CLASSES . 'email.php');

// set the language
 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
if (!tep_session_is_registered('language')) {
  tep_session_register('language');
  tep_session_register('languages_id');
}

include(DIR_WS_CLASSES . 'language.php');
$lng = new language();

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
  $lng->set_language($HTTP_GET_VARS['language']);
} else {
  $lng->get_browser_language();
}

$language = $lng->language['directory'];
$languages_id = $lng->language['id'];
 }

// include the language translations
 require(DIR_WS_LANGUAGES . $language . '.php');

// Ultimate SEO URLs v2.1
if (SEO_ENABLED == 'true' or (SEO_ENABLED != 'true' and SEO_ENABLED != 'false')) {
include_once(DIR_WS_CLASSES . 'seo.class.php');
if ( !is_object($seo_urls) )
{
  $seo_urls = new SEO_URL($languages_id);
}
 }
// currency
 if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
if (!tep_session_is_registered('currency')) tep_session_register('currency');

if (isset($HTTP_GET_VARS['currency'])) {
  if (!$currency = tep_currency_exists($HTTP_GET_VARS['currency'])) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
} else {
  $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}
 }

// navigation history
 if (tep_session_is_registered('navigation')) {
if (PHP_VERSION < 4) {
  $broken_navigation = $navigation;
  $navigation = new navigationHistory;
  $navigation->unserialize($broken_navigation);
}
 } else {
tep_session_register('navigation');
$navigation = new navigationHistory;
 }
 $navigation->add_current_page();
//BEGIN allprods modification  
 if (ALL_PRODUCTS=='false' and strstr($PHP_SELF,ALL_PRODUCTS_FILENAME)) {
  tep_redirect(tep_href_link(FILENAME_DEFAULT));
 }
//END allprods modification

require(DIR_WS_FUNCTIONS . 'buy_two_func.php');

// Shopping cart actions
 if (isset($HTTP_GET_VARS['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
if ($session_started == false) {
  tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
}

if (DISPLAY_CART == 'true') {
  $goto =  FILENAME_SHOPPING_CART;
  $parameters = array('action', 'cPath', 'products_id', 'pid');
} else {
  $goto = basename($PHP_SELF);
  if ($HTTP_GET_VARS['action'] == 'buy_now') {
	$parameters = array('action', 'pid', 'products_id');
  } else {
	$parameters = array('action', 'pid');
  }
}
switch ($HTTP_GET_VARS['action']) {
  // customer wants to update the product quantity in their shopping cart
  case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
							if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {
							  $cart->remove($HTTP_POST_VARS['products_id'][$i]);
							} else {
							  if (PHP_VERSION < 4) {
								// if PHP3, make correction for lack of multidimensional array.
								reset($HTTP_POST_VARS);
								while (list($key, $value) = each($HTTP_POST_VARS)) {
								  if (is_array($value)) {
									while (list($key2, $value2) = each($value)) {
									  if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
										$id2[$var[1]][$var[2]] = $value2;
									  }
									}
								  }
								}
								$attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';
							  } else {
								//$attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
								 $attributes =($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i].'+++'.$i]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i].'+++'.$i] : '';
							  }
							  $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
/*  // customer adds a product from the products page
  case 'add_product' :	if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
							//OLD$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
							//new: QuantityPriceBreaker
							$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break; 
*/


						  //// bof: Added 2gether (contribution 3929)
	 case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
if (tep_get_products_stock($HTTP_POST_VARS['products_id']) > 0) $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
}
if (isset($HTTP_POST_VARS['buy_tinn_add']) && is_numeric($HTTP_POST_VARS['buy_tinn_add'])) {
if (tep_get_products_stock($HTTP_POST_VARS['buy_tinn_add']) > 0) {
$cart->add_cart($HTTP_POST_VARS['buy_tinn_add'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['buy_tinn_add'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
							////  eof: Added 2gether (contribution 3929)



  // performed by the 'buy now' button in product listings and review page
  case 'buy_now' :		if (isset($HTTP_GET_VARS['products_id'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  case 'notify' :		 if (tep_session_is_registered('customer_id')) {
							if (isset($HTTP_GET_VARS['products_id'])) {
							  $notify = $HTTP_GET_VARS['products_id'];
							} elseif (isset($HTTP_GET_VARS['notify'])) {
							  $notify = $HTTP_GET_VARS['notify'];
							} elseif (isset($HTTP_POST_VARS['notify'])) {
							  $notify = $HTTP_POST_VARS['notify'];
							} else {
							  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
							}
							if (!is_array($notify)) $notify = array($notify);
							for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
							  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
							  $check = tep_db_fetch_array($check_query);
							  if ($check['count'] < 1) {
								tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
							  }
							}
							tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
						  } else {
							$navigation->set_snapshot();
							tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
						  }
						  break;
  case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
							$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
							$check = tep_db_fetch_array($check_query);
							if ($check['count'] > 0) {
							  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
							}
							tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
						  } else {
							$navigation->set_snapshot();
							tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
						  }
						  break;
  case 'cust_order' :	 if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
 case 'auroranien' :		  

						if (isset($HTTP_GET_VARS['products_id'])) {
							if (BUY_TWO_DISCOUNT_BUNDLE == 'normal') {
							if ($HTTP_GET_VARS['buy_tinn_add']) {
							$cart->add_cart($HTTP_GET_VARS['buy_tinn_add'],  $cart->get_quantity($HTTP_GET_VARS['buy_tinn_add']) +1);
								}
								if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
								tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .$HTTP_GET_VARS['products_id']));
								 } else {
								$cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id']) +1);
									}
								} elseif (BUY_TWO_DISCOUNT_BUNDLE =='discount') {
									$bundle_products_id = tep_set_bundle($HTTP_GET_VARS['products_id'],$HTTP_GET_VARS['buy_tinn_add'],BUY_TWO_BUNDLE_DISCOUNT_RATE_A,BUY_TWO_BUNDLE_DISCOUNT_RATE_B);
									$cart->add_cart($bundle_products_id, $cart->get_quantity($bundle_products_id) +1);
										}
											}
										tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
									break;
}
 }

// include the who's online functions
 require(DIR_WS_FUNCTIONS . 'whos_online.php');
 tep_update_whos_online();

// include the password crypto functions
 require(DIR_WS_FUNCTIONS . 'password_funcs.php');

// include the text encrypt/decrypt functions
  require(DIR_WS_FUNCTIONS . 'en_de_crypt.php');

// include validation functions (right now only email address)
 require(DIR_WS_FUNCTIONS . 'validations.php');

// split-page-results
 require(DIR_WS_CLASSES . 'split_page_results.php');

// infobox
 require(DIR_WS_CLASSES . 'boxes.php');

// auto activate and expire banners
/*
require(DIR_WS_FUNCTIONS . 'banner.php');
tep_activate_banners();
tep_expire_banners();
*/
// auto expire special products
 require(DIR_WS_FUNCTIONS . 'specials.php');
 tep_expire_specials();

// auto expire featured products
require(DIR_WS_FUNCTIONS . 'featured.php');
tep_expire_featured();

// calculate category path
 if (isset($HTTP_GET_VARS['cPath'])) {
$cPath = $HTTP_GET_VARS['cPath'];
 } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
$cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
 } else {
$cPath = '';
 }

 if (tep_not_null($cPath)) {
$cPath_array = tep_parse_category_path($cPath);
$cPath = implode('_', $cPath_array);
$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
 } else {
$current_category_id = 0;
 }

// include the breadcrumb class and start the breadcrumb trail
 require(DIR_WS_CLASSES . 'breadcrumb.php');
 $breadcrumb = new breadcrumb;

 //$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
 if (isset($cPath_array)) {
for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
  $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
  if (tep_db_num_rows($categories_query) > 0) {
	$categories = tep_db_fetch_array($categories_query);
	$breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
  } else {
	break;
  }
}
 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
$manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
if (tep_db_num_rows($manufacturers_query)) {
  $manufacturers = tep_db_fetch_array($manufacturers_query);
  $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
}
 }

// add the products name to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
$name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($name_query)) {
$name = tep_db_fetch_array($name_query);
$breadcrumb->add($name['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
}

/*
// add the products model to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($model_query)) {
  $model = tep_db_fetch_array($model_query);
  $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
 }
*/
// START Articles Manager [1709]
// include the articles functions
 require(DIR_WS_FUNCTIONS . 'articles.php');
 require(DIR_WS_FUNCTIONS . 'article_header_tags.php'); 

// calculate topic path
 if (isset($HTTP_GET_VARS['tPath'])) {
$tPath = $HTTP_GET_VARS['tPath'];
 } elseif (isset($HTTP_GET_VARS['articles_id']) && !isset($HTTP_GET_VARS['authors_id'])) {
$tPath = tep_get_article_path($HTTP_GET_VARS['articles_id']);
 } else {
$tPath = '';
 }

 if (tep_not_null($tPath)) {
$tPath_array = tep_parse_topic_path($tPath);
$tPath = implode('_', $tPath_array);
$current_topic_id = $tPath_array[(sizeof($tPath_array)-1)];
 } else {
$current_topic_id = 0;
 }

// add topic names or the author name to the breadcrumb trail
 if (isset($tPath_array)) {
for ($i=0, $n=sizeof($tPath_array); $i<$n; $i++) {
  $topics_query = tep_db_query("select topics_name from " . TABLE_TOPICS_DESCRIPTION . " where topics_id = '" . (int)$tPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
  if (tep_db_num_rows($topics_query) > 0) {
	$topics = tep_db_fetch_array($topics_query);
	$breadcrumb->add($topics['topics_name'], tep_href_link(FILENAME_ARTICLES, 'tPath=' . implode('_', array_slice($tPath_array, 0, ($i+1)))));
  } else {
	break;
  }
}
 } elseif (isset($HTTP_GET_VARS['authors_id'])) {
$authors_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . (int)$HTTP_GET_VARS['authors_id'] . "'");
if (tep_db_num_rows($authors_query)) {
  $authors = tep_db_fetch_array($authors_query);
  $breadcrumb->add('Articles by ' . $authors['authors_name'], tep_href_link(FILENAME_ARTICLES, 'authors_id=' . $HTTP_GET_VARS['authors_id']));
}
 }

// add the articles name to the breadcrumb trail
 if (isset($HTTP_GET_VARS['articles_id'])) {
$article_query = tep_db_query("select articles_name from " . TABLE_ARTICLES_DESCRIPTION . " where articles_id = '" . (int)$HTTP_GET_VARS['articles_id'] . "'");
if (tep_db_num_rows($article_query)) {
  $article = tep_db_fetch_array($article_query);
  if (isset($HTTP_GET_VARS['authors_id'])) {
	$breadcrumb->add($article['articles_name'], tep_href_link(FILENAME_ARTICLE_INFO, 'authors_id=' . $HTTP_GET_VARS['authors_id'] . '&articles_id=' . $HTTP_GET_VARS['articles_id']));
  } else {
	$breadcrumb->add($article['articles_name'], tep_href_link(FILENAME_ARTICLE_INFO, 'tPath=' . $tPath . '&articles_id=' . $HTTP_GET_VARS['articles_id']));
  }
}
 }

//ALSO, if you DO NOT have Header Tags Installed, add the following (else don't!)
// add only if Header Tags not already installed
 //require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');
// END Articles Manager [1709]

// initialize the message stack for output messages
 require(DIR_WS_CLASSES . 'message_stack.php');
 $messageStack = new messageStack;

// set which precautions should be checked
 define('WARN_INSTALL_EXISTENCE', 'true');
 define('WARN_CONFIG_WRITEABLE', 'true');
 define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
 define('WARN_SESSION_AUTO_START', 'true');
 define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');


// Module: InfoPages
 require(DIR_WS_MODULES . 'infopages.php');

// Module: InfoPages
 define('FILENAME_INFOPAGES', 'infopages.php');

// BOF: Header Tags Controller v2.6.0
 require(DIR_WS_FUNCTIONS . 'header_tags.php');
// Clean out HTML comments from ALT tags etc.
 require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');
// EOF: Added: Header Tags Controller v2.6.0

// tax class
require('includes/classes/tax.php');
$osC_Tax = new osC_Tax;

/*--------------------------------------------------------*\
#	Page cache contribution - by Chemo
#	Define the pages to be cached in the $cache_pages array
\*--------------------------------------------------------*/
$cache_pages = array('index.php', 'product_info.php');
if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true') {
# Start the output buffer for the shopping cart
ob_start();
require(DIR_WS_BOXES . 'shopping_cart.php');
$cart_cache = ob_get_clean();
# End the output buffer for cart and save as $cart_cache string

# Loop through the $cache_pages array and start caching if found
foreach ($cache_pages as $index => $page){
	if ( strpos($_SERVER['PHP_SELF'], $page) ){
		include_once(DIR_WS_CLASSES . 'page_cache.php');
		$page_cache = new page_cache($cart_cache);
		# The cache timelife is set globally 
		# in the admin control panel settings
		# Example below overrides the setting to 60 minutes
		# Leave blank to use default setting
		# $page_cache->cache_this_page(60);
		$page_cache->cache_this_page();
	} # End if
} # End foreach
} # End if


// PWA BOF
 if (tep_session_is_registered('customer_id') && $customer_id == 0 && substr(basename($PHP_SELF),0,7)=='account') tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
// PWA EOF

// Include OSC-AFFILIATE
 require(DIR_WS_INCLUDES . 'affiliate_application_top.php');

// Include skins
 require(DIR_WS_INCLUDES . 'skins/skins_application_top.php');
?>


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
Can this be used with SPPC?

 

I personaly didnt install the SPPC but i went to look for both contribs installed and found that some did install both successfully.

(i made THIS search)


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites
The text attribute value is not being added to the shopping cart.

Sorry, but there is a lot going on with all these different contributions but I can't see an obvious place where something goes wrong. You will need to debug this and stop the code and print out the variables it gets. For example echo'ing the $_POST variables somewhere to see if the id and values of the OTF stuff is included and then go further to see in which function/page the problem lies. If application_top sends the correct things to the add_cart function in shopping_cart.php it maybe that the function calculate is not working correctly etcetera.

 

Not what you would have liked to hear I guess.

Share this post


Link to post
Share on other sites
Sorry, but there is a lot going on with all these different contributions but I can't see an obvious place where something goes wrong. You will need to debug this and stop the code and print out the variables it gets. For example echo'ing the $_POST variables somewhere to see if the id and values of the OTF stuff is included and then go further to see in which function/page the problem lies. If application_top sends the correct things to the add_cart function in shopping_cart.php it maybe that the function calculate is not working correctly etcetera.

 

Not what you would have liked to hear I guess.

 

 

no, not so much... :( i spent many many (many...) hours on this contrib, ill guess ill give it just one more day.

 

Thanks a lot for all your help.

 

Sharon


Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Share this post


Link to post
Share on other sites

Does anyone have a store I can see this up and running.

I installed this and do not like where the price break out is and I want to be sure I did not make any mistakes.

 

 

You can send me a PM with the site.

 

Thans

Share this post


Link to post
Share on other sites
Does anyone have a store I can see this up and running.

I installed this and do not like where the price break out is and I want to be sure I did not make any mistakes.

You can send me a PM with the site.

 

Thans

 

 

That many?!?!?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×