Jump to content



Photo
* * * * * 2 votes

[Contribution] Option Types v2


  • Please log in to reply
935 replies to this topic

#801   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 09 August 2012 - 10:20

Sorry , can not change the above post but it´s in the wrong forum!

#802   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 09 August 2012 - 14:36

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

#803   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 09 August 2012 - 16:05

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

#804   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 10 August 2012 - 10:30

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>


#805   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 10 August 2012 - 11:12

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!!

#806   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 10 August 2012 - 11:15

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?

#807   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 11 August 2012 - 10:35

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


#808 ONLINE   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,578 posts
  • Real Name:George Zarkadas
  • Gender:Male
  • Location:Greece

Posted 11 August 2012 - 10:54

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


#809   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 11 August 2012 - 11:04

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, 11 August 2012 - 11:19.


#810   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 11 August 2012 - 11:30

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

#811   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 11 August 2012 - 11:49

@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! [img]http://forums.oscommerce.com//public/style_emoticons/default/whistling.gif[/img])



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

#812   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 13 August 2012 - 09:59

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 /whistling.gif' class='bbc_emoticon' alt=':-' />(

Regards,

Rob

#813   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 13 August 2012 - 13:52

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 /whistling.gif' class='bbc_emoticon' alt=':-' />(


ALTER TABLE products_attributes
ADD products_price_calc type INT( 2 ) NOT NULL

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

Edited by CrazyCarzCustoms, 13 August 2012 - 13:53.


#814   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 13 August 2012 - 14:36

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, 13 August 2012 - 14:40.


#815   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 13 August 2012 - 15:01

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

#816   billcbos

billcbos
  • Members
  • 28 posts
  • Real Name:Bill Champitto
  • Gender:Male
  • Location:Boston, MA, USA

Posted 14 August 2012 - 19:10

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.



#817   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 15 August 2012 - 10:32

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

#818   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 15 August 2012 - 10:43

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, 15 August 2012 - 10:43.


#819   CrazyCarzCustoms

CrazyCarzCustoms
  • Members
  • 151 posts
  • Real Name:Rob
  • Gender:Male
  • Location:Oliveira do Hospital - Portugal

Posted 15 August 2012 - 11:27

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

#820   FridayNight

FridayNight
  • Members
  • 79 posts
  • Real Name:HGM
  • Gender:Male
  • Location:Germany

Posted 28 August 2012 - 13:31

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.