Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Option Input Field


psynaptic

Recommended Posts

Is there a way to add an attribute to a product so it will display a text input field instead of a dropdown. I have a set of products that have 5 dropdown boxes and I need to add option 6 as an input field.

 

I have tried to install Product Attributes - Option Type Feature but the code is for the osc build pre August 2006.

 

Can anyone give me nudge in the right direction please?

Link to comment
Share on other sites

I have tried to install Product Attributes - Option Type Feature but the code is for the osc build pre August 2006.

Option Type will work on the August 06 build of OSC. It's a pig to install regardless of what version of OSC you're using - but it will work.

Link to comment
Share on other sites

Option Type will work on the August 06 build of OSC. It's a pig to install regardless of what version of OSC you're using - but it will work.

Hi Jason,

 

The code is different in the shopping_cart class. How do I get around it?

Link to comment
Share on other sites

Are you using PD Steve's Manual Install file? That should help you out. You should also use a good find and compare program. If you can't get it working then PM me. I successfully added Option Type to an August 06 snapshot last week so could email you the file.

Link to comment
Share on other sites

Are you using PD Steve's Manual Install file? That should help you out. You should also use a good find and compare program. If you can't get it working then PM me. I successfully added Option Type to an August 06 snapshot last week so could email you the file.

Yes, that's right. The first problem I have come across is where it says:

 

FIND: (around line 88)

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

  if (is_numeric($products_id) && is_numeric($qty)) {
	$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')) {

REPLACE with

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

 

In my shopping_cart class I have:

	  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);
// this is in the august snapshot
  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }
// ends here 
  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')) {

From what I have read in another thread there is more that will conflict in classes/shopping_cart.php. I don't know how critical that code is.

 

I do use a file compare program (beyond compare on xp and filemerge on os x) but not usually on instructions like this. Would you advise it? I'll have to try it and see.

Link to comment
Share on other sites

	  $attributes_pass_check = true;

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

Ok, I'm going to have a guess what this does...

 

First, it sets the variable $attributes_pass_check to true.

 

Then it asks if the variable $attributes is an array, if it is true it resets the variable $attributes to it's first element. After that it loops over the options and values for each attribute and if it finds that any option or value is not numeric it sets $attributes_pass_check to false and ends execution of the loop.

 

So in literal terms does this code check to see if any of the options and values are numbers, and if so leaves $attributes_pass_check to true?

 

What does setting $attributes_pass_check to false actually achieve?

Link to comment
Share on other sites

I've added the following below by footer:

<?php
echo 'attributes_pass_check = ';
if ($attributes_pass_check = true) {
echo 'True';
} else {
echo 'False';
}
?>

This shows that $attributes_pass_check is always True. It never seems to go to False.

 

You can probably tell by now that I'm not a programmer and I'm just winging it. If anyone can contribute to my findings and confirm whether it is safe to remove that code I'd be very grateful.

Link to comment
Share on other sites

Jason has kindly offered to send me a copy of classes/shopping_cart.php and general.php so I'll see if I can work it out from that.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...