Jump to content
Zappo

[Contribution] Option Types v2

Recommended Posts

Hi Tobias

 

would take a look at includes/classes/shopping_cart.php read the forums I used the original shopping_cart.php from rc2 could not get it to work with update to 2.31/2 have not had time to find out why but the old shopping_cart.php works fine not many changes there!

 

John


To improve is to change; to be perfect is to change often.

 

Share this post


Link to post
Share on other sites

Ive read throught most of the forum and did several searches but cant find the answer to my problem. Does anyone know how to make the Dynamic Force Attribute work with this option ype mod. Or is there another mod out there that will force an attribute selection?

 

Thank You !

Share this post


Link to post
Share on other sites

I have a heavily modded OSCommerce site and I am looking to add something like this, however I use Attribute Sets and as I am trying to install this add-on, I see that the Attribute Sets add-on mixes code.

 

This seems like it will be extremely difficult, however I am wondering if anyone has incorporated this add-on while also using Attribute Sets Plus, and/or if there are any suggestions.

Share this post


Link to post
Share on other sites

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.

 

I've managed to get this mostly working except right now my shopping cart is not getting populated at all. I can view the product, I get the correct options including the text input field, but when I click add to cart I am sent to an empty shopping cart. Any ideas or thoughts? If this is too vague of an issue, then please elaborate on the appropriate installation procedures. You download includes two main directories, and two different instruction files (txt and html). I initially followed the txt file instructions and reviewed the directories but am confused. The directories include duplicate files, would overwrite my configuration files with incorrect parameters and negate the changes made by following the txt file instructions. I uploaded your catalog directory and then re-applied the changes made using your txt file and html file, but now I am at a state where the shopping cart isn't getting populated. If I have to start over from the top I would like to know the correct installation procedure to follow. Also, I have made changes to the application_top, stylesheet and header files to accommodate a design. So I would prefer to use a process like the instructions in the txt file rather than simply replacing those files. Whatever you can do to help me resolve this I would appreciate.

Share this post


Link to post
Share on other sites

I've recently come back to osCommerce after a couple years and am glad to find this great contribution revised! I'm in the processing of installing it on a clean oscommerce version, but I feel like I'm missing some install instructions somewhere?

 

I didn't see the place where I was told to add the 3 image directories, and I'm also unsure on how I can utilize the drop in files vs the find and replace instructions listed in the install document?

 

Also, I had to move all the define(OPTION_TYPE.... declarations out of admin/include/configure.php and into english.php for the administrative screens to pick it up. Or have I missed something else.

 

Any help would be greatly appreciated! Thanks!

Share this post


Link to post
Share on other sites

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

Same problem. Any Ideas? I used the drop on top files from the contribution onto a clean installation. No other changes have been made.

 

Remove from cart, and update buttons missing from the shopping cart screen.

 

Any ideas?

Share this post


Link to post
Share on other sites

Hi,

 

I just encounterd this message:

 

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 '-0, MAX_DISPLAY_ALLMANUFACTURERS' at line 1
select manufacturers_name, manufacturers_id, manufacturers_image from manufacturers order by manufacturers_name limit -0, MAX_DISPLAY_ALLMANUFACTURERS
[TEP STOP]

 

Edit ; i do not have a line in my database that says : MAX_DISPLAY_ALLMANUFACTURERS , but should there be one?

 

Thats not good.

 

Can anybody help me to resolve this please?

 

Thanks in advance,

 

Rob

Edited by CrazyCarzCustoms

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

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

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

×