Latest News: (loading..)
Zappo

[Contribution] Option Types v2

1,099 posts in this topic

Hi all,

 

Question ; first time that i put a item with options in it doesn´t calculate or show the price , when i put the same item in for a second time it then calculates 2 times the item as it should be.

This only happens when using the options , putting a item in ol´style works fine.

 

Does someone have a idea on were to look or how to resolve this?

 

Thanks,

 

Rob

Share this post


Link to post
Share on other sites

Hmmm , it starts to become less funny now.

I got this error when i try to open a product in admin:

Fatal error: require_once() [function.require]: Failed opening required 'attributeManager/includes/attributeManagerHeader.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/misascom/public_html/atilburg1962/includes/template_top.php on line 71

 

on line 71 it says : smartColumns();//Execute the function when page loadssmartColumns();//Execute the function when page loads

 

Can someone help me please?

 

Thanks,

 

Rob

Share this post


Link to post
Share on other sites

Hi,

This is the code from attributeManagerHeader.inc.php and i can see it starts out as php because the first <?php shows red (?) but the closing ?> is black , so i asume something in between must be wrong , any ideas are greatly apriciated!!

 

Thanks,

 

Rob

 

 

<?php
/*
 $Id: attributeManagerHeader.inc.php,v 1.0 21/02/06 Sam West$
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Released under the GNU General Public License

 Copyright © 2006 Kangaroo Partners
 http://kangaroopartners.com
 osc@[member='KangarooPartners'].com
*/
if('new_product' == $action || 'update_product' == $action) {
$amSessionVar = tep_session_name().'='.tep_session_id();
echo <<<HEADER
<script language="JavaScript" type="text/JavaScript">
var productsId='{$_GET['pID']}';
var pageAction='{$_GET['action']}';
var sessionId='{$amSessionVar}';
</script>
<script language="JavaScript" type="text/JavaScript" src="attributeManager/javascript/requester.js"></script>
<script language="JavaScript" type="text/JavaScript" src="attributeManager/javascript/alertBoxes.js"></script>
<script language="JavaScript" type="text/JavaScript" src="attributeManager/javascript/attributeManager.js"></script>
<link rel="stylesheet" type="text/css" href="attributeManager/css/attributeManager.css" />
HEADER;
}
?>
<script language="JavaScript" type="text/javascript">
function goOnLoad() {
<?php if('new_product' == $action || 'update_product' == $action) echo 'attributeManagerInit();'; ?>
SetFocus();
}
</script>

Share this post


Link to post
Share on other sites

Ha , found it!! in the install package the AttributeManager was inside a other folder called AttributeManager addon , so it was in one level too deep , very confuseling!!

Share this post


Link to post
Share on other sites

Hi all,

 

Question ; first time that i put a item with options in it doesn´t calculate or show the price , when i put the same item in for a second time it then calculates 2 times the item as it should be.

This only happens when using the options , putting a item in ol´style works fine.

 

Does someone have a idea on were to look or how to resolve this?

 

Thanks,

 

Rob

 

Anyone?

Share this post


Link to post
Share on other sites

Hi , I am trying to merge the old 231 file by zappo from 18-10-2009 in the current file as instructed by Multimixer but i am lost here.

Can someone help me as i don´t have a clue on what to do , please..

 

Thanks, Rob

 

Current:

$attributes_pass_check = true;
  if (is_array($attributes) && !empty($attributes)) {
    reset($attributes);
    while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
	    $attributes_pass_check = false;
	    break;
	  } else {
	    $check_query = tep_db_query("select products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "' limit 1");
	    if (tep_db_num_rows($check_query) < 1) {
		  $attributes_pass_check = false;
		  break;
	    }
	  }
    }
  } elseif (tep_has_product_attributes($products_id)) {
    $attributes_pass_check = false;
  }

 

 

Old:

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

Share this post


Link to post
Share on other sites

Here you go

  // BOF Option types v2 Because of Text and Upload options, $option AND $value don't have to be numeric!
  /*
  if (is_array($attributes) && !empty($attributes)) {
    reset($attributes);
    while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
	    $attributes_pass_check = false;
	    break;
	  } else {
	    $check_query = tep_db_query("select products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "' limit 1");
	    if (tep_db_num_rows($check_query) < 1) {
		  $attributes_pass_check = false;
		  break;
	    }
	  }
    } // end while
  } elseif (tep_has_product_attributes($products_id)) {
    $attributes_pass_check = false;
  }
  */
  // EOF 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');
	  }

Share this post


Link to post
Share on other sites

Thanks George,

 

ok ,going to give it a try , but this is all way above my head so it probably will explode ;-)

 

Rob

 

 

Hahahaaa , yep , it did!!

Edited by CrazyCarzCustoms

Share this post


Link to post
Share on other sites

Hi George , i think i went the wrong way around with this as i tried to merge the old in the new file while the instructions said ; use old file and merge parts of the new file in it................am i right???

 

 

Gr, Rob

Share this post


Link to post
Share on other sites

@@rknabe - You are right. I had the same problem, I think DunWeb missed a few things. I had to download v2 of option types and look at their versions to compare.

 

In the includes/classes/shopping_cart.php make the following changes:

 

Comment out lines 103-109:

/*		reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  } else {
		$check_query = tep_db_query("select products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "' limit 1");
		if (tep_db_num_rows($check_query) < 1) {
		  $attributes_pass_check = false;
		  break;
		}
	  }
	}
  } elseif (tep_has_product_attributes($products_id)) {
	$attributes_pass_check = false;
  }
*/

 

Find lines 131-133:

$this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");

 

Replace with:


//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...

 

Comment out line 175-184:

/*	  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }
*/

 

Find around lines 193-195:

$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 . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");

 

Replace it with:

//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...

 

Find around line 356:

global $customer_id;

Add below it:

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

 

Find around line 378:

'image' => $products['products_image'],

Add below it:

'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''),

 

 

Hope that helps. Share if you find something else that needs modifying! whistling.gif)

 

 

Hmmm , i did all this and now i have this popping up : Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/xxxxxxxxx/public_html/includes/classes/shopping_cart.php on line 476

 

And i have a ?> there and nothing else!

 

Does somebody have a idea?

 

Gr, Rob

Share this post


Link to post
Share on other sites

Hi George

 

First a BIG thank you sooo much for your help!!!.

 

I have it now implemented in my site but when i go to check-out i get a blank page , and if i go straight into the shopping cart i get this:

What's In My Cart?
Produto(s)
1054 - Unknown column 'options_price_calc' in 'field list'
SELECT products_attributes_id, options_values_price, price_prefix, options_price_calc FROM products_attributes WHERE products_id = '519' AND ((options_id = '1' AND options_values_id = '2'))

 

 

I´m afraid that i have to ask for your help with this too :-(

 

Regards,

 

Rob

Share this post


Link to post
Share on other sites

Hi George,

 

I have been looking in php.MyAdmin and i noticed that i do not have a column "options_price_calc" in the " products_attributes" group so that will be the culprit then....right?

 

Si i did this in phpMyadmin but that did not do the trick :-(

 

 

ALTER TABLE products_attributes

ADD products_price_calc type INT( 2 ) NOT NULL

 

so that clearly needed to be something different..................

Edited by CrazyCarzCustoms

Share this post


Link to post
Share on other sites

Little typing mistake ,

 

I added ADD options_price_calc type INT( 2 ) NOT NULL

 

It now goes to "whats in my cart" if i hit the button but it shows the product without the price but that can be because of it is not able to add the price yet due to a faulty thing i have put in the server............, but i still get a white screen when i want to add something to the cart.

Edited by CrazyCarzCustoms

Share this post


Link to post
Share on other sites

ok , just to keep you posted,

 

I took out the previous thingy and now i have put in:

 

 

# Add Attributes Sort Order to the basket attributes table

ALTER TABLE products_attributes

ADD options_price_calc INT( 2 ) DEFAULT '1' NOT NULL;

 

Wich did not do the trick either ............So anyone have a idea about what to put there? , this is way above my head for sure.

 

Gr. Rob

Share this post


Link to post
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.

 

 

 

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.......

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Another thought is that there could be an encoding Problem the database (utf8) stores the character "Ö" for example as "Ö"...

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