Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Option Types v2


Zappo

Recommended Posts

After scraping through this topic I found a reference to the includes/classes/shoping_cart.php where the author suggests using a previous version of that file. I took the file from his v2 contribution and the products are now being added to my cart. The files can be found at http://addons.oscommerce.com/info/6818. I hope that helps. If you do a search on the topic for "shopping" you will see a number of posts with a variety of different answers.

 

It would have been nice for the author to provide a quick response since this is a known issue but I guess its beneath him, as apparently is the idea of providing some direction around the install steps, which has been posted as a question many times and the only response I saw from him was an attitude filled response that he has better things to do with his time.

 

It's a shame, this contribution is nice and I will hopefully be able to get it to run in production, and he seems to respond to other questions quickly and with great detail. I guess my question wasn't up to his standards. Good luck with your install.

 

 

 

I am having the same issue. I cannot add a product to the shopping cart if it has options? It just says Cart is Empty. Any help here would be appreciated!

I would have liked a response to this post. I have installed the constribution but now products are not being added to the shopping cart. Has anyone experienced this? I've gone through line by line to check the files that I think would be causing this issue and can not find an issue. Any direction would be helpful.

shopping_cart.php file

 

 

I am having the same issue. I cannot add a product to the shopping cart if it has options? It just says Cart is Empty. Any help here would be appreciated!

I would have liked a response to this post. I have installed the constribution but now products are not being added to the shopping cart. Has anyone experienced this? I've gone through line by line to check the files that I think would be causing this issue and can not find an issue. Any direction would be helpful.

Link to comment
Share on other sites

Hi all,

 

Multimixer was so nice to merge the "includes/classes/shopping_cart.php" file for me so i can use Options Types v 2.1.3.

But when i click on the add to cart button i get a white page , but i can´t find were that button should go to or were i can check if it has the correct address to go to.

i can get into the cart via the " Cart" button at the top of the page but then clicking checkout gives also a blank page.

Can someone point me to the files to check and what to check please.

 

Thanks,

 

Rob

Link to comment
Share on other sites

After scraping through this topic I found a reference to the includes/classes/shoping_cart.php where the author suggests using a previous version of that file. I took the file from his v2 contribution and the products are now being added to my cart. The files can be found at http://addons.oscommerce.com/info/6818. I hope that helps. If you do a search on the topic for "shopping" you will see a number of posts with a variety of different answers.

 

It would have been nice for the author to provide a quick response since this is a known issue but I guess its beneath him, as apparently is the idea of providing some direction around the install steps, which has been posted as a question many times and the only response I saw from him was an attitude filled response that he has better things to do with his time.

 

It's a shame, this contribution is nice and I will hopefully be able to get it to run in production, and he seems to respond to other questions quickly and with great detail. I guess my question wasn't up to his standards. Good luck with your install.

 

Maybe if you would have read the whole topic you would have noticed that the autor isn´t into OsCommerce anymore for a long time now and therefor is not giving any support.

The people that are giving support here do this just to help others and not because of this being their contribution.

So , instead of going bitchy you should say something like THANKS!!

Edited by CrazyCarzCustoms
Link to comment
Share on other sites

Hi all,

 

Multimixer was so nice to merge the "includes/classes/shopping_cart.php" file for me so i can use Options Types v 2.1.3.

But when i click on the add to cart button i get a white page , but i can´t find were that button should go to or were i can check if it has the correct address to go to.

i can get into the cart via the " Cart" button at the top of the page but then clicking checkout gives also a blank page.

Can someone point me to the files to check and what to check please.

 

Thanks,

 

Rob

 

I think this all has to do with the "Cache" funtion as when i disable cash it all seems to work.......

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I have the problem with special characters like "&" "(" ")" "+" that they get lost when I want to edit a product from out of the shoping cart. Customer inputs like "this & that" get lost, infact all the customer inputs get lost as soon as there is one of these special characters.

I guess there is some trick to mask these characters so that the do not interfere with the code.

 

If somebody has found a solution for this issue would be great. Likewise I will share if I figure out something by myself.

Link to comment
Share on other sites

While adding text to PHP files, I found apostrophes (') needs to be written with backslash (\') so as to not interfere with PHP's syntax. However, that is not likely to help you as the customer's input should be modified.

 

There are other input fields in default osCommerce that does not face such problems (product description field in admin, for example), so I think the addon's implementation is wrong. I do not understand PHP beyond following instructions to edit and install addons, so I cannot help.

Link to comment
Share on other sites

I do not think that there is something wrong with the implementation as it works just fine with all entries except spezial characters like & () + and the german "umlaute" äöü...

there are several files involved with Option Type ... I think the problem might be in the module option_types.php loaded in the product_info.php where it loads the value from the shopping_cart.php class:

 

case OPTIONS_TYPE_TEXT:
  $tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $ProdOpt_ID . ']" id="id[' . TEXT_PREFIX . $ProdOpt_ID . ']" size="' . $ProdOpt_Length .'" maxlength="' . $ProdOpt_Length . '"
						 value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$ProdOpt_ID] .'"';

 

but I have difficulties to figure out where to go on in the shopping_cart.php class to figure out what is being done with this:

$cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$ProdOpt_ID]

 

I can post more from my files if needed.

But I also remember I read that some others had the same problem with loosing the customer inputs from going back from the shopping cart to the product info page in order to edit the product options.

Edited by FridayNight
Link to comment
Share on other sites

URLs from the shopping_cart.php:

 

Example with value "AO" with normal "O" which works:

product_info.php?products_id=488{txt_26}sample1{txt_21}AO

 

Example with value "AÖ" with special character "Ö" which does not work:

product_info.php?products_id=488{txt_26}sample2{txt_21}AÖ

 

The url is correct, the database entry in customers_basket and customers_basket_attributes too. Just when hitting the product_info.php with a special character it is not able to read the values from neither the URL(GET) nor the database...

Edited by FridayNight
Link to comment
Share on other sites

The product link from the shopping_cart.php is created like this:

 

'	<td class="productListing-data" align="left"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . urlencode($products[$i]['id'])) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class="imgframe"') . '</a></td>'

 

however when I echo the GET Variable passed from here on the product_info.php the special character "Ö" is lost:

 

Example from above:

488{txt_26}sample2{txt_21}A

 

Any idea why this happen? Is there maybe some security trigger I am not aware of which strips down the special character from the GET variable?

 

Would be great if one of you could check if the problem with text input fields and special characters and the going back (edit the product) from the shopping cart to the product_info is a bug not just for me.

Edited by FridayNight
Link to comment
Share on other sites

Hi all,

 

Multimixer was so nice to merge the "includes/classes/shopping_cart.php" file for me so i can use Options Types v 2.1.3.

 

Hello Everybody

 

I'm also trying to getting this add-on working on OSC 2.3.1.

Following the instructions I found out that in shopping_cart.php the quantity has been commented (as well as the remove link).

Can you please post the merged file or a link to it?

 

Many thanks

Link to comment
Share on other sites

Hi all,

 

I wanted to start to put some product in but i get this message,

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values (null, '522', '1', '5', '63.35', '+', '0')

 

[TEP STOP]

 

Does someone know what this means or were it comes from?

 

Gr, Rob

Link to comment
Share on other sites

To Davidedp

 

This is my "includes/classes/shopping_cart.php"

 

 

I hope this helps.

 

Gr. Rob

 

<?php
/*
 $Id: shopping_cart.php 1739 2007-12-20 00:52:16Z hpdl $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
*/
 class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;
function shoppingCart() {
  $this->reset();
}
function restore_contents() {
  global $customer_id;
  if (!tep_session_is_registered('customer_id')) return false;
// insert current cart contents in database
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $qty = $this->contents[$products_id]['qty'];
	  $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  if (!tep_db_num_rows($product_query)) {
		tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')");
		if (isset($this->contents[$products_id]['attributes'])) {
//BOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir
		  $uploads_query = tep_db_query("select files_uploaded_name from " . TABLE_FILES_UPLOADED . " where sesskey = '" . tep_session_id() . "'");
		  while ($uploads_array = tep_db_fetch_array($uploads_query)) {
			if (file_exists(TMP_DIR . $uploads_array['files_uploaded_name'])) { // Customer upload found in TMP dir --> Copy to Upload Dir
			  @rename(TMP_DIR . $uploads_array['files_uploaded_name'], UPL_DIR . $uploads_array['files_uploaded_name']);
			  // Set Customer_ID for the files that are found
			  tep_db_query("update " . TABLE_FILES_UPLOADED . " set customers_id = '" . (int)$customer_id . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . $uploads_array['files_uploaded_name'] . "'");
			}
		  }
		  reset($this->contents[$products_id]['attributes']);
		  while (list($option, $value) = each($this->contents[$products_id]['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) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
//EOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir
		  }
		}
	  } else {
		tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($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
//BOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes.
	$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'];
	  // - Zappo - Option Types v2 - If attribute is Text, set additional information
	  if ($attributes['products_options_value_id'] == OPTIONS_VALUE_TEXT_ID) {
		$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
	  }
//EOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes.
	}
  }
  $this->cleanup();
}
function reset($reset_database = false) {
  global $customer_id;
  $this->contents = array();
  $this->total = 0;
  $this->weight = 0;
  $this->content_type = false;
  if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
  }
  unset($this->cartID);
  if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}
function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;
  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);
  if (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$qty > MAX_QTY_IN_CART)) {
	$qty = MAX_QTY_IN_CART;
  }
  $attributes_pass_check = true;
//BOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric!
/*	  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  } */
//EOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric!
  if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {
	$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	$check_product = tep_db_fetch_array($check_product_query);
	if (($check_product !== false) && ($check_product['products_status'] == '1')) {
	  if ($notify == true) {
		$new_products_id_in_cart = $products_id;
		tep_session_register('new_products_id_in_cart');
	  }
	  if ($this->in_cart($products_id_string)) {
		$this->update_quantity($products_id_string, $qty, $attributes);
	  } else {
		$this->contents[$products_id_string] = array('qty' => (int)$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)) {
//BOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly...
			$attr_value = NULL;
			$blank_value = FALSE;
			if (strstr($option, TEXT_PREFIX)) {  //Check for Text and Upload Options
			  if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?)
				$blank_value = TRUE;
			  } else {							   //Value is valid and contains data --> Add Text Option value
				$option = str_replace(TEXT_PREFIX,'',$option);
				$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
				$value = OPTIONS_VALUE_TEXT_ID;
				$this->contents[$products_id_string]['attributes_values'][$option] = $attr_value;
			  }
			}
			if (!$blank_value) {  // If the Value is valid and Contains Data, add the option to the Cart....
			  $this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			  // - Zappo - Option Types v2 - Added products_options_value_text For saving Text and Upload Option Values
			  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) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
			}
//EOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly...
		  }
		}
	  }
	  $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);
  if (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$quantity > MAX_QTY_IN_CART)) {
	$quantity = MAX_QTY_IN_CART;
  }
  $attributes_pass_check = true;
//BOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric!
/*	  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  } */
//EOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric!
  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' => (int)$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 - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly...
		$attr_value = NULL;
	 $blank_value = FALSE;
		if (strstr($option, TEXT_PREFIX)) {  //Check for Text and Upload Options
		  if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?)
			$blank_value = TRUE;
		  } else {							   //Value is valid and contains data --> Prepare for database
			$option = str_replace(TEXT_PREFIX,'',$option);
			$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
			$value = 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) . "' and products_options_id = '" . (int)$option . "'");
		}
//EOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly...
	  }
	}
  }
}
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 - Zappo - Option Types v2 - ONE LINE - Add call to tep_get_uprid to correctly format product ids containing quotes
  $products_id = tep_get_uprid($products_id, $attributes);
  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() {
  global $currencies;
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];
// products price
	$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	if ($product = tep_db_fetch_array($product_query)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $product['products_price'];
	  $products_weight = $product['products_weight'];
	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
	  $this->total += $currencies->calculate_price($products_price, $products_tax, $qty);
	  $this->weight += ($qty * $products_weight);
	}
// 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 += $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty);
		} else {
		  $this->total -= $currencies->calculate_price($attribute_price['options_values_price'], $products_tax, $qty);
		}
	  }
	}
  }
}
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;
  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
	if ($products = tep_db_fetch_array($products_query)) {
	  $prid = $products['products_id'];
	  $products_price = $products['products_price'];
	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
//BOF - Zappo - Option Types v2 - ONE LINE - Include attribute value_text. This is needed for text attributes.
								'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''),
								'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'],
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
	}
  }
  return $products_array;
}
function show_total() {
  $this->calculate();
  return $this->total;
}
function show_weight() {
  $this->calculate();
  return $this->weight;
}
function generate_cart_id($length = 5) {
  return tep_create_random_value($length, 'digits');
}
function get_content_type() {
  $this->content_type = false;
  if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  if (isset($this->contents[$products_id]['attributes'])) {
		reset($this->contents[$products_id]['attributes']);
		while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
		  $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);
		  if ($virtual_check['total'] > 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';
				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';
				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
	  } else {
		switch ($this->content_type) {
		  case 'virtual':
			$this->content_type = 'mixed';
			return $this->content_type;
			break;
		  default:
			$this->content_type = 'physical';
			break;
		}
	  }
	}
  } else {
	$this->content_type = 'physical';
  }
  return $this->content_type;
}
function unserialize($broken) {
  for(reset($broken);$kv=each($broken);) {
	$key=$kv['key'];
	if (gettype($this->$key)!="user function")
	$this->$key=$kv['value'];
  }
}
 }
?>

Edited by CrazyCarzCustoms
Link to comment
Share on other sites

OK , as far as i can tell it seems that it does not see or insert the "products_atribute_id".

 

So were does that come from then?

 

Does somebody have a idea please as i realy need to get this working soon!

 

Gr, Rob

Link to comment
Share on other sites

To Davidedp

 

This is my "includes/classes/shopping_cart.php"

 

 

I hope this helps.

 

Gr. Rob

 

Many thanks for the quick reply, I'll have a look at it. Do you have quantity and "remove link" in the cart? The current problem I have, is in my opinion in "/shopping_cart.php" ....

Link to comment
Share on other sites

Hi again,

 

I have been experimenting a bit and i found that i can put the options in on the database , wich will then display nicely in the website.

It then also shows the product in the options-page in the admin.

 

So the problem must be between the input page and the server...........am i right??

 

Any help would be greatly apriciated as i need to put 2000 items with options in and it will be a hell doing that via tha database :-(

 

Gr, Rob

Link to comment
Share on other sites

Hello Everybody

 

after reading all the post, I still have to understand the following:

- I have OSC 2.3.1, I used http://addons.oscommerce.com/info/8193 and done all the steps of the instructions.

- Since I only have German language installed (but not only because of that), I have some issues in admin and also in catalog (cannot really use the option types).

- It seems that to solve all the issues I have to get from http://addons.oscommerce.com/info/6818 the last update of Zappo in history and compare it with the ones I used.

Am I right?

Is someone using Option Type with OSC 2.3.1?

If so does he/she has the price and remove link in the cart?

(I solved this issue myself, but I'm not sure about side effects).

Edited by davidedp
Link to comment
Share on other sites

OK , maybe this will get something going;

 

If i look at the error it says : null, '523', '1', '2', '9.7', '+', '0'

 

So this means that it does not see or generate the products_attribute_id i think, but looking in the admin section it gives a number for that place , it just does not go to the db , can someone point me in the right direction as why or were please?

 

Gr, Rob

Link to comment
Share on other sites

Ok, in order to solve the major problems in Admin I did the following:

- Removed all the old options and option values

- Installed Attribute Manager from the last update of Zappo of http://addons.oscommerce.com/info/6818

- Now I can define the option of type text in the old "Product Option" and use it in the new Attribute Manager!!!

I'm already very happy with it.

 

The urgent issue i have now is the following:

if I order the product that has an input field, this will be added to the cart (great).

But if now I make the check out (not logged yet), as soon as I log in I get:

 

1146 - Table 'oscommerce_2.TABLE_FILES_UPLOADED' doesn't exist

 

select files_uploaded_name from TABLE_FILES_UPLOADED where sesskey = '29fc5958ade4210d31cc94701c7852be'

 

[TEP STOP]

 

But if I first log-in and then do the process then it's ok!

Edited by davidedp
Link to comment
Share on other sites

Ok, that was easy, in the new instruction it was missing the following:

 

In 2. admin/include/database_tables.php we should add:

define('TABLE_FILES_UPLOADED', 'files_uploaded'); //BOF - Zappo - Option Types v2 - ONE LINE - File Uploading

 

Then it works!

Now the next problem is that I added the remove link and quantity field in the cart.

It work until we do not enter some text with special chars (like ? or ä. ö etc...).

The reason is that the link is build using also the text entered, i.e.:

let say we entered "Does it work?" as text in the option input field, the link will be:

<a href="http://shop.com/shopping_cart.php/products_id/45{1}4{txt_2}does it work//action/remove_product">remove</a>

Link to comment
Share on other sites

I solved the link problem with a workaround in javascript, instead of calling the link, I set the quantity field to 0 and submit.

The issue could be that in tep_href_link the "?" is replaced by "/":

 

 

if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {

$link = str_replace('?', '/', $link);

$link = str_replace('&', '/', $link);

$link = str_replace('=', '/', $link);

} else {

$link = str_replace('&', '&', $link);

}

 

or is it just an issue with the charset (UTF-8 vs charset=iso-8859-1)?.... anyway...

Link to comment
Share on other sites

Join the conversation

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

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

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...