Jump to content
Latest News: (loading..)
Zappo

[Contribution] Option Types v2

Recommended Posts

As the error says, the column for option comments does not exist.

You probably didn't execute the SQL file...

I get the error:

1054 - Unknown column 'products_options_order' in 'order clause'

 

select * from products_options where language_id='1' order by products_options_order

 

[TEP STOP]

 

When you say "execute" the .sql file....Do you mean that I click on "import" and import the .sql file? I get an error message....

SQL query:

 

# osCommerce, Open Source E-Commerce Solutions

# http://www.oscommerce.com

#

# Database Changes for Option Types v2

#

# created by AvanOsch for http://Shop.CrystalCopy.nl

#

# Released under the GNU General Public License

# Add Option Types configuration menu in Admin

INSERT INTO `configuration_group`

VALUES (

 

'', 'Option Types', 'Configure Option Types and Upload settings.', '17', '1'

);

 

 

 

MySQL said:

 

#1062 - Duplicate entry '0' for key 'PRIMARY'

 

 

I'm TOTALLY lost!

Share this post


Link to post
Share on other sites

Help! I got the following error after running the sql file:

 

INSERT INTO configuration VALUES ('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options

None = No Progress Bars

Text = Textfields only

TextArea = TextAreas only

Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'), ('', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.

Database = insert id from database

Date = the upload Date

Time = the upload Time

DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'), ('', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.

Us[...]

 

MySQL said:

 

#1062 - Duplicate entry '0' for key 'PRIMARY'

 

 

I have no idea what that means! I'm new to all this! It took me forever just to figure out what phpMyAdmin was!!!! Then it took me forever to figure out how to run the file! What is it telling me I need to do?!

 

This query is adding some more lines, values, to the table "configuration" of your database. The value for each field is separated by a comma ","

 

So it says for example

('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options ......................

The field names of table configuration are:

configuration_id, configuration_title, configuration_key, configuration_value , configuration_description ...................

Each value is getting written into each field in the same order

 

You see that the first value (for the field "configuration_id") is empty. This is so, because that field is supposed to be "auto increment", so it doesn't need a value to be specified, it adds it by it self, adding +1 to the latest record.

 

For some reason your DB isn't doing that. So it adds the value "0". It's trying to do the same for the second entry, but because this field can have only unique entries, the error appears, telling you that there is a duplicate entry of 0

 

You can go to your database, table configuration to see the entries for all previous settings. If you order the table by "configuration_id (do this by clicking on the name in the "browse" view), you will find out what the highest latest id is. Lets say it is 726.

 

The next should be 727, then 728, 729 etc etc

 

You can add this numbers manually to the query, so the above posted would look like

('727', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options ......................

You see that I entered into the empty first fiel ('') the value '727'. This you can do for all other fields for the query

# Add Option Types configuration menu in Admin
INSERT INTO configuration VALUES ('727', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options<br>None = No Progress Bars<br>Text = Textfields only<br>TextArea = TextAreas only<br>Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'),
                                ('728', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.<br>Database = insert id from database<br>Date = the upload Date<br>Time = the upload Time<br>DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'),
                                ('729', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.<br>Usage: -2 weeks/-5 days/-1 year/etc.', last_insert_id(), '6', now(), now(), NULL, NULL),
                                ('730', 'Upload Directory', 'UPL_DIR', 'images/uploads/', 'The directory to store uploads from registered customers.', last_insert_id(), '7', now(), now(), NULL, NULL),
                                ('731', 'Temporary Directory', 'TMP_DIR', 'images/temp/', 'The directory to store temporary uploads (from guests) which is automatically cleaned.', last_insert_id(), '8', now(), now(), NULL, NULL),
                                ('732', 'Option Type Image - Images Directory', 'OPTIONS_TYPE_IMAGEDIR', 'images/options/', 'What directory to look for Option Type Images.<br>This is where the Images should be stored.', last_insert_id(), '9', now(), now(), NULL, NULL),
                                ('733', 'Option Type Image - Images Prefix', 'OPTIONS_TYPE_IMAGEPREFIX', 'Option_', 'What prefix to use when looking for Option Type Images.<br>This is what the Image\'s name should begin with.', last_insert_id(), '10', now(), now(), NULL, NULL),
                                ('734', 'Option Type Image - Images Name', 'OPTIONS_TYPE_IMAGENAME', 'Name', 'What Option Value item to use as Name for the Option Type Images.<br>When set to "Name", the images should be named: "PREFIX"-"Option value name"-"LanguageID".jpg (Option_RedShirt_1.jpg)<br>When set to "ID", the images should be named: "PREFIX"-"Option value ID"-"LanguageID".jpg (Option_5_1.jpg)', last_insert_id(), '11', now(), now(), NULL, 'tep_cfg_select_option(array(\'Name\', \'ID\'),'),
                                ('735', 'Option Type Image - Use Language ID', 'OPTIONS_TYPE_IMAGELANG', 'Yes', 'Use language ID in Option Type Images Names?<br>This is only needed if different images are used per Language (images with text for example).', last_insert_id(), '12', now(), now(), NULL, 'tep_cfg_select_option(array(\'Yes\', \'No\'),');

Of course you need to replace the numbers (727 etc) with your numbers. Then you run the query again. Before doing this, best is you restore the database you had before running the option types query

Share this post


Link to post
Share on other sites

 

You see that the first value (for the field "configuration_id") is empty. This is so, because that field is supposed to be "auto increment", so it doesn't need a value to be specified, it adds it by it self, adding +1 to the latest record.

 

For some reason your DB isn't doing that. So it adds the value "0". It's trying to do the same for the second entry, but because this field can have only unique entries, the error appears, telling you that there is a duplicate entry of 0

 

 

You said "For some reason...." and I have to laugh so I won't cry that I spent 7 hours trying to figure something out that I don't even slightly understand (although, I did self-teach myself HTML). The reason is that the box, "Do not use AUTO_INCREMENT for zero values" was checked in phpMyAdmin and, since I'm not familiar with all of this, I had no idea what that meant so I didn't uncheck it. After your (life-saving) post I restored my original database (thank God I took the advice to back it up before I made any changes) and ran the sql file with the box UNCHECKED and it worked like a charm!

 

THANK YOU! THANK YOU! THANK YOU!

 

I know this is off-topic but you might find some humor in this as I do. The first part isn't humorous but the end is....

 

My husband died about a year-and-a-half ago at the age of 31. (An accident in our driveway) Well, he was a Systems Administrator (did networking on computers) for a living. We always argued (in a joking way) over who's job was harder (I'm a nurse). Well, I know that what I'm trying to do with our website and what he did with computers (networking) are two totally different things but I still see what a pain in the a** computers can be now and I'd love to talk to him right now and give him credit for all of the evenings he came home and said that he just "needed some peace and quiet". I have to sit back, shake my head, laugh, and say to myself, "Maybe he was right! Maybe his job was harder! Computers suck!!!!" LOL Sometimes I picture him up there laughing at all the trouble I'm having building our website. You just wait til I see him again!! :-D

Share this post


Link to post
Share on other sites

This contribution is built on top of osCommerce 2.2rc2a.

It is an update/upgrade/revision/compilation of the following contributions:

* Option Type Feature v3 (Originally by Chandra Roukema)

* Option Type File Feature v.8 (Originally by Matt Fletcher)

* AJAX Attribute Manager v2.8.6 ((Almost unchanged) Originally by Sam West)

* Improvements by me (AvanOsch aKa Zappo the Wizard of Osch) for http://shop.crystalcopy.nl

 

Please post questions, comments, request, etc. right here!

 

The Contribution Page can be found here: http://www.oscommerce.com/community/contributions,xxxx

 

The contribution is really fantastic as it gives great flexibility to display various options for a product. Really nice work!

 

I've it implemented on my oscommerce copy but having a little problem when I checkout.

 

I can't see the 'text' options value on the orders page after the checkout when I select PAYPAL standard payment method. It works perfectly for COD payment method.

 

When I saw the database table 'orders_products_attributes' it has an entry but the following columns are empty for the said order:

products_options products_options_values options_values_price

 

Please be noted that the checkout process shows the values perfectly its only after the order has been confirmed by the customer that this mess is created. Simple to say is that the options value for the text option are not getting into the 'orders_products_attributes' table of the DB.

 

Please let me know if there is a solution to it.

 

Regards,

Muhammad Mahd

Share this post


Link to post
Share on other sites

Wondering if anyone has figured out how to add attributes as quantities or get something similar working with this contribution? For example, need to charge 2 bucks for each letter in a name that is entered in the text field....Thanks!!

Share this post


Link to post
Share on other sites

I have a HEAVILY Modified osCommerce shop which includes SPPC which had many conflicts with Option Types during compare. I thought I had it all working fine until I noticed that:

 

When I add a new product no problem.

When I add the same product again but change the options it adds to the cart as quantity of 2 and only holds the attributes of the later item (rather than making it a new line item with a quantity of 1)

 

Can you please look at the site and let me know what I am missing? www.statkids.com/store

 

Thanks,

Share this post


Link to post
Share on other sites

Hi all - hoping someone out there can help me with this. I've just installed (or tried to at least) this great contribution but when I try to add a text box to a product, it will only show up as a dropdown with (CUSTOMER-INPUT) as the only option. I've tried for several hours and can't seem to figure out what the issue is. I have the contribution, Attribute Sets Plus installed as well but I have it disabled for my test product and still can't get Option Types to work right. Here's a link to my store where I'm having the issue: http://freshfashionz.com/catalog/product_info.php?products_id=938

 

I read through the forum and saw that another user was having the same issue (back on page 15) but she was able to figure the problem out and didn't post the solution. Since so many people have successfully installed this, I'm sure it's something small that I'm overlooking. If anyone out there could possibly help, I would GREATLY appreciate it. Let me know if you need me to post any code or screenshot.

 

Thanks in advance!

Share this post


Link to post
Share on other sites

Hello everybody and what a contribution this is. Nice one..

 

I have installed complete as the instructions and everything works fine apart from 2 things on the product attribute page.

 

I have noticed that youcannot edit SORT ORDER or VALUE LENGTH.

 

OK what it does is this.. I click on edit, the options are available to edit.. I changed them.

 

When i click update the values for SORT ORDER & VALUE LENGTH revert back to the old settings.

 

Can anybody please help with this as i am not sure what is happening.

 

Thank You

Share this post


Link to post
Share on other sites

Hi people.

 

There are news about merging SPPC and Option Types v2. I have it working !. I will post my results here in the hope that somebody will take a look at them and make something more "sophisticated" of it:). I did following changes:

 

1) in file modules/option_types.php

 

1.1) After

  	$ProdOpt_Length = $products_options_name['products_options_length'];

I placed

// BOF SPPC multimixer 13 1 10
   $aid = tep_db_query("select pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and pa.options_id = '" . $ProdOpt_ID . "'");
 	$aid_result = tep_db_fetch_array($aid);
 	$ProdAtr_ID = $aid_result['products_attributes_id']; // SPPC
// EOF SPPC multimixer 13 1 10

so I have the attributes id available for a particular product/option combination

 

1.2) After

  
$products_attribs_query = tep_db_query("select distinct options_values_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int)tep_db_input($product_info['products_id']) . "' and options_id = '" . $ProdOpt_ID . "' order by products_options_sort_order");

I placed

// BOF SPPC multimixer 13 1 10
// forum http://forums.oscommerce.com/topic/338661-contribution-option-types-v2/page__view__findpost__p__1473708
     if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	// check if something in table attributes groups for this product/customer group/ attributes id
  	 	$cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and customers_group_id = '" . $customer_group_id . "' and products_attributes_id = '" . $ProdAtr_ID . "'");
   	$cid_result = tep_db_fetch_array($cid_query);
	if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id)
		  $products_attribs_query = tep_db_query("select distinct pa.options_values_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag where pa.products_attributes_id = '" . $ProdAtr_ID . "' and pa.products_attributes_id = pag.products_attributes_id and pag.customers_group_id = '" . $customer_group_id . "' and pag.products_id='" . (int)tep_db_input($product_info['products_id']) . "' order by products_options_sort_order");
		} // end if ($cid_result['total'] > 0)
} // end if ($customer_group_id > 0)
// EOF SPPC multimixer 13 1 10

so I'm getting the data for customer groups in case they exist and they have defined options. This cover all option cases exept of drop down (covered by product info) and radio/images see below

 

1.3) In both cases (OPTIONS_TYPE_RADIO and OPTIONS_TYPE_IMAGE) I replaced this

      
$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' order by pa.products_options_sort_order");

by this

// BOF SPPC multimixer 13 1 10
// forum http://forums.oscommerce.com/topic/338661-contribution-option-types-v2/page__view__findpost__p__1473708
    if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	// check if something in table attributes groups for this product/customer group/ 
  	 	$cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_id = '" . (int)$product_info['products_id'] . "' and customers_group_id = '" . $customer_group_id . "'");
   	$cid_result = tep_db_fetch_array($cid_query);
	if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id)
     		$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name,  pag.options_values_price, pag.price_prefix, pag.products_attributes_id 
  		from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag
   		where pa.products_id = '" . (int)$product_info['products_id'] . "' 
   		and pa.options_id = '" . $ProdOpt_ID . "' 
   		and pa.options_values_id = pov.products_options_values_id 
   		and pov.language_id = '" . (int)$languages_id . "' 
   		and pa.products_attributes_id = pag.products_attributes_id 
   		and pag.customers_group_id = '" . $customer_group_id . "' 
   		and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 
   		order by pa.products_options_sort_order");

		} else { //if ($cid_result['total'] > 0) // reqular query	

    		$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order");

			} // end if ($cid_result['total'] > 0) 

	} else { //if ($customer_group_id > 0)	// reqular query	

    		$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order");

		} // end if ($customer_group_id > 0)
// EOF SPPC multimixer 13 1 10

 

I know this looks not elegant at all, but I just didn't succeed to get the "replacement" logic of SPPC, like it is done in product_info.php into this file here. Anyway, it works at least

 

2) in shopping_cart.php (the main file, not the /classes/ one)

 

I replaced this

          $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");

 

by this

// BOF SPPC	multimixer 13 1 09
if ($customer_group_id > 0) { // only need to check if customer is not retail
	// mm get the attributes_id
       $aid = tep_db_query("select pa.products_attributes_id from  " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_values_id = '" . (int)$value . "'");
       $aid_result = tep_db_fetch_array($aid);
	// check if something in table attributes groups for this product/customer group
	$cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa  where pag.products_id = '" . (int)$products[$i]['id'] . "' and pag.customers_group_id = '" . $customer_group_id . "' and pag.products_attributes_id = '" . $aid_result['products_attributes_id'] . "' and pa.options_values_id = '" . (int)$value . "'");
	$cid_result = tep_db_fetch_array($cid_query);

	if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id and option value id)

         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pag.options_values_price, pag.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag,  " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
								   and pag.customers_group_id = '" .(int)$customer_group_id . "'
   						and pa.products_attributes_id = pag.products_attributes_id 
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");

		} else {// if ($cid_result['total'] > 0) // if nohing use reqular query	

         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");

		} // end if ($cid_result['total'] > 0)

	} else { //if ($customer_group_id > 0)	// reqular query	

	// BOF original Zappo - Option Types v2
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");
	// EOF original Zappo - Option Types v2

	} // end if ($customer_group_id > 0)
// EOF SPPC	multimixer 13 1 09

 

Again: not very elegant maybe, but it works

 

Thats all ! Preposition is of course a correct merging of the other files, valid for both contributions (SPPC and Option Types v2). There could be a confusion in files product_info.php and classes/shopping cart.php, so, here are some tips about how I did it

 

3) File product_info.php

 

I will post the 3 queries related to product attributes as they look after the merging

    $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$product_info['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_order, popt.products_options_name");

        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order");

 

4) File classes/shopping_cart.php

 

There is nothing that could cause a problem except of one thing that is resulting to text and image options not to be added to the cart properly.

 

In the SPPC instructions it says to replace this

        $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')) {

 

by this

// BOF SPPC attribute hide check, original query expanded to include attributes
			$check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'");
			while ($_check_product = tep_db_fetch_array($check_product_query)) {
				$check_product[] = $_check_product;
			} // end while ($_check_product = tep_db_fetch_array($check_product_query))
			$no_of_check_product = count($check_product);

 if (is_array($attributes)) {
			foreach($attributes as $attr_option => $attr_option_value) {
				$valid_option = '0';
				for ($x = 0; $x < $no_of_check_product ; $x++) {
					if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) {
						$valid_option = '1';
						if ($check_product[$x]['hide_attr_status'] == '1') {
						// delete hidden attributes from array attributes
						unset($attributes[$attr_option]);
						}
					} // end if ($attr_option == $check_product[$x]['options_id']....
				} // end for ($x = 0; $x < $no_of_check_product ; $x++)
				if ($valid_option == '0') {
					// after having gone through the options for this product and not having found a matching one
					// we can conclude that apparently this is not a valid option for this product so remove it
					unset($attributes[$attr_option]);
				}
			} // end foreach($attributes as $attr_option => $attr_option_value)
} // end if (is_array($attributes))
// now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again
			$products_id_string = tep_get_uprid($products_id, $attributes);

       if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) {
// EOF SPPC attribute hide check

 

If you leave the original code in place, then everything works fine. Would be great ofcourse if somebody could help in transforming the SPPC part to be option types compatible

----------------

Thats all people, it works, everything gets displayed and calculated correctly. As I said, I posting this in the hope that somebody will put an eye on it and make all necessary corrections.

 

 

If you add a product with text attributes, then go back and try to add the same product with different text attributes......does it work? Cause mine gives the product a quantity of 2 in the shopping cart with only the last text attributes added. Let me know if yours works!! Thanks,

Share this post


Link to post
Share on other sites

Hi there,

I'm looking for a contribution that will make it really easy for customers to add accessories to a product.

 

Ideally I'd like the optional accessories to be shown at checkboxes and the price dynamically updated when the checkboxes are selected. It would be perfect if these options could be actual products which are added to the basket separately when they are selected and have their stock adjusted accordingly.

 

I've had a look at Zappo's Linked Products addon which looks perfect, but in the support thread he advised against using it in a live shop.

 

Does Option Types offer any of the functionality I need? I'm also using QTpro, so would be interested to hear if anyone has that working with Option Types.

 

Thanks for your help!

Tim. :thumbsup:

Share this post


Link to post
Share on other sites

First of all i would like to say that this contribution is brilliant and works like a charm.

 

However i have a problem that i am hoping this support can help with..

 

Here is the scenario..

 

I have a t-shirt printing website and deal with 7 styles of t-shirts. eg baseball style, hoodie, v-neck, ladyfit

Each style has differant colours. eg v-neck (23 clours) hoodie (6 colours)

 

So what i need is this..

 

They select the style of t-shirt that they want.

This selection determines the colours available.

 

Is there any way that this can be done with this contribution and if so how...

 

Any help would be very much appreciated..

 

Thank You

 

Dean

Share this post


Link to post
Share on other sites

Hi,

 

I seem to have developed a problem with Option Types V2.

 

When I originally installed it everything worked fine.

 

However, I now find that when a customer makes an order, his Customer Inputs for the chosen optionns are displayed on the Order Confirmation page, but are not passed through with the order.

 

The options do not appear in the customers order history either.

 

Eg - all that is passed through is the name of the option and the words "CUSTOMER INPUT" as follows:

 

CPH Number: CUSTOMER-INPUT

Flock Mark (UK) CUSTOMER-INPUT

Consecutive No. (from) CUSTOMER-INPUT

Consecutive No. (to) CUSTOMER-INPUT

Colour Required Light Blue

 

The same happens on the order email.

 

I have no idea when this happened and have only just noticed.

 

Any assistange would be great thanks.

 

I have just found out that this only happens when one of the available payment options are used (Barclaycard EPDQ) when the other payment options (paypal & Cheque) are selected everything works as it should.

 

Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

In The paypal IPN Code I have the following :

 

                $attributes_values = tep_db_fetch_array($attributes);

// BOF - Zappo - Option Types v2 - Correction for Text Option Values
               $attr_name = $attributes_values['products_options_name'];
               if ($attributes_values['products_options_id'] == OPTIONS_VALUE_TEXT_ID) {
                 $attr_name_sql_raw = 'SELECT po.products_options_name FROM ' . TABLE_PRODUCTS_OPTIONS . ' po, ' . TABLE_PRODUCTS_ATTRIBUTES . ' pa WHERE ' .
                                                       ' pa.products_id="' . tep_get_prid($order->products[$i]['id']) . '" AND ' .
                                                       ' pa.options_id="' . $order->products[$i]['attributes'][$j]['option_id'] . '" AND ' .
                                                       ' pa.options_id=po.products_options_id AND ' .
                                                       ' po.language_id="' . $languages_id . '" ';
                 $attr_name_sql = tep_db_query($attr_name_sql_raw);
                 if ($arr = tep_db_fetch_array($attr_name_sql)) {
                   $attr_name = $arr['products_options_name'];
                 }
               }
               $sql_data_array = array('orders_id' => $insert_id,
                                       'orders_products_id' => $order_products_id,
                                       // 'products_options' => $attributes_values['products_options_name'],
                                       // 'products_options_values' => $attributes_values['products_options_values_name'],
                                       'products_options' => $attr_name,
                                       'products_options_values' => $order->products[$i]['attributes'][$j]['value'],
                                       'options_values_price' => $attributes_values['options_values_price'],
                                       'price_prefix' => $attributes_values['price_prefix']);
// EOF - Zappo - Option Types v2 - Correction for Text Option Values

               tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

 

But if I copy this to the EPDQ.php payment module it does not solve the problem.

 

Help Please......


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

OK - Please ignore my last post - the fix above does work in the EPDQ File.

 

Many Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Hi ! I'm a newbee here. Sorry ! :blush:

 

I have a problem with the contribution Option Types v2.

 

When I add a first product with options to the shopping cart, any problem (price is just). But when I add the second product with different options in the shopping cart it puts me (for the second product) the options of the first one and those of the second, but with the good price !!!

 

And when I add the third product, it adds me the options and of the first one and the second, and there also with the good price !

 

On the other hand, on the checkout confirmation, there's any problem ! The first two articles have the good options.

 

Has anybody got an idea ? The solution is maybe very simple, but I don't find it...

 

THX ALL.

Share this post


Link to post
Share on other sites

If you add a product with text attributes, then go back and try to add the same product with different text attributes......does it work? Cause mine gives the product a quantity of 2 in the shopping cart with only the last text attributes added. Let me know if yours works!! Thanks,

 

I just checked and I have no problem with this. Is your issue connected somehow with SPPC and OTv2? Do you have a modified store? Did you try on a vanilla install to see how it works?

Share this post


Link to post
Share on other sites

hi,

 

I have downloaded this contribution after seeing it on another site because i need for the customer to enter characters over 3 or 4 lines that can be engraved onto a product.

 

I am lost with the install file 'option types v2 installtion instruction.txt' because there are characters in there that i have no idea what they are or are refering too...

 

\f1\fs24 \
\

\f0\fs22         \cf2 echo \cf3 '<br><nobr><small> <i> - ' \cf0 . \cf4 $order\cf0 ->products[\cf4 $i\cf0 ][\cf3 'attributes'\cf0 ][\cf4 $j\cf0 ][\cf3 'option'\cf0 ] . \cf3 ': ' \cf0 . \cf4 $order\cf0 ->products[\cf4 $i\cf0 ][\cf3 'attributes'\cf0 ][\cf4 $j\cf0 ][\cf3 'value'\cf0 ] . \cf3 '</i></small></nobr>'\cf0 ;\
\

 

on the 1st part of the find this and replace with... i have no idea what all the /cf3 etc are as they are not proper php coding

 

can anyone help or maybe could supply proper install instructions??

 

many thanks - Mark

Share this post


Link to post
Share on other sites

Hi

 

Ive installed this contribution but when I upload a file nothing happens, it pauses for a few seconds as if uploading then just returns to the product page without adding anything to the cart or uploading the file. This also happens on all products in the store even those without attributes added, it won't add anything to the cart.

 

Has it something to do with the line:

 

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data"'); ?>

Share this post


Link to post
Share on other sites

hey

when i go to edit product i get this error

1054 - Unknown column 'products_options_order' in 'order clause'

select * from products_options where language_id='1' order by products_options_order

 

i read a few pages back that its cause i didnt run the sql file.. so i try and import it and i get this error

-- same as the person befor.

 

INSERT INTO configuration VALUES ('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options
None = No Progress Bars
Text = Textfields only
TextArea = TextAreas only
Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'), ('', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.
Database = insert id from database
Date = the upload Date
Time = the upload Time
DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'), ('', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.
Us[...] 

MySQL said: 

#1062 - Duplicate entry '0' for key 'PRIMARY' 

 

then i edited the sql file starting at number 213 as per waht you said to start with the higest numder...

 

then i tryed to import the file again ... same issue. as i was typing this and went to try and import again i unchecked "Do not use AUTO_INCREMENT for zero values"

and it seems to of taken the file and the error seems to be gone...lol

yay! thought id share that info for anyone else

Share this post


Link to post
Share on other sites

Hello people

 

A time ago I posted a solution to set products options to be calculated per item or per unit.

 

Example:

1) Per unit (product price:5 + option price:1 = 6 x quantity: 500 = total: 3000)

2) Per item (product price:5 x quantity: 500 = 2500 + option price:1 = total:2501)

 

The post is here

 

It's all working fine, the only issue was, that the whole thing was not working with the "Order Editor" addon. I don't know if anyone is interested or even using this solution, anyway, here is the way to have this working with order editor too. Not to mention that you need to have order editor installed, I have the version by surfalot (of 18 11 09)

 

Modification to enable "Order Editor" to calculate products options per item or per unit.

Involved Files are

 

checkout_process.php

 

admin/edit_orders_add_product.php

admin/edit_orders_ajax.php

admin/edit_orders.php

 

admin/order_editor/cart.php

admin/order_editor/javascript.php

admin/order_editor/order.php

 

------------------------------

Add one more field to the database

 

If you did already my previous mod, then import this sql file to your DB via phpMyAdmin

# osCommerce, Open Source E-Commerce Solutions
# http://www.oscommerce.com
#
# Database Changes for Option Types v2
#
# created by multimixer for http://multimixer.gr
#
# Released under the GNU General Public License


# Add choice for options price to be calculated per item (once) or per unit
# Upgrade to version 1 For order editor

# Add calculation way to the orders_products_attributes table
ALTER TABLE orders_products_attributes
 ADD options_price_calc INT( 1 ) DEFAULT '0' NOT NULL;

 

If you did not, then you can use this, it contains all necessary DB changes

# osCommerce, Open Source E-Commerce Solutions
# http://www.oscommerce.com
#
# Database Changes for Option Types v2
#
# created by multimixer for http://multimixer.gr
#
# Released under the GNU General Public License


# Add choice for options price to be calculated per item (once) or per unit

# Add calculation way and name to the products_options table
ALTER TABLE products_options
 ADD products_options_price_calc INT( 1 ) DEFAULT '0' NOT NULL ,
 ADD products_options_per_name VARCHAR( 32 ) DEFAULT 'per unit'  NULL;

# Add calculation way to the products_attributes table
ALTER TABLE products_attributes
 ADD options_price_calc INT( 1 ) DEFAULT '0' NOT NULL;

# Add calculation way and name to the orders_products_attributes table
ALTER TABLE orders_products_attributes
 ADD options_price_calc INT( 1 ) DEFAULT '0' NOT NULL,
 ADD options_per_name VARCHAR( 32 ) DEFAULT 'per unit'  NULL;

 

From here on just "upgrade"instructions to my previous post, you need to do the changes there first. if you did, go on

 

------------------------

1) File Checkout_process.php

 

Find

          
// set price per unit / per item multimixer 15 4 10	added , popt.products_options_per_name	
         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename, popt.products_options_per_name 

 

Replace with

			
// set price per unit / per item multimixer 15 4 10	added , popt.products_options_per_name, popt.products_options_price_calc (20 8 10)	
         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename, popt.products_options_per_name, popt.products_options_price_calc 

 

Find

			
// set price per unit / per item multimixer 15 4 10	added , popt.products_options_per_name	
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, popt.products_options_per_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

 

Replace with

// set price per unit / per item multimixer 15 4 10	added , popt.products_options_per_name, popt.products_options_price_calc (20 8 10)	
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, popt.products_options_per_name, popt.products_options_price_calc from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

 

Find

                                
'options_per_name' => $attributes_values['products_options_per_name']);
// set price per unit / per item multimixer 15 4 10 ( 2 line above added / second on 20 8 10 For Order Editor)

 

Replace with

                               
'options_per_name' => $attributes_values['products_options_per_name'],
'options_price_calc' => $attributes_values['products_options_price_calc']);
// set price per unit / per item multimixer 15 4 10 ( 2 line above added / second on 20 8 10 For Order Editor)

 

----------------------

2) File admin/edit_orders_add_product.php

 

Find

			
				if ($opt_price_prefix == '-')
				{$AddedOptionsPrice -= $opt_options_values_price;}
				else //default to positive
				{$AddedOptionsPrice += $opt_options_values_price;}

 

Replace with

// BOF set price per unit / per item multimixer 20 8 10
			if ($opt_options_price_calc == '1') { // case per item
				if ($opt_price_prefix == '-')
				{$AddedOptionsPrice -= $opt_options_values_price / ($_POST['add_product_quantity']) ;}
				else //default to positive
				{$AddedOptionsPrice += $opt_options_values_price / ($_POST['add_product_quantity']) ;}
			} else { // default per unit
				if ($opt_price_prefix == '-')
				{$AddedOptionsPrice -= $opt_options_values_price;}
				else //default to positive
				{$AddedOptionsPrice += $opt_options_values_price;}
			}
// EOF set price per unit / per item multimixer 20 8 10

 

Find

            
$option_values_names[$option_value_id] = $opt_products_options_values_name;

 

Add After

			
$options_per_name[$option_id] = $opt_products_options_per_name; // set price per unit / per item multimixer 20 8 10
$options_price_calc[$option_id] = $opt_products_options_price_calc; // set price per unit / per item multimixer 20 8 10

 

Find

            
'price_prefix' => tep_db_prepare_input($option_value_details[$option_id][$option_value_id]['price_prefix']));

 

Replace with

            
'price_prefix' => tep_db_prepare_input($option_value_details[$option_id][$option_value_id]['price_prefix']),
'options_per_name' => tep_db_prepare_input($options_per_name[$option_id]),
'options_price_calc' => tep_db_prepare_input($options_price_calc[$option_id]),
// set price per unit / per item multimixer 20 8 10 2 lines above added
);

 

Find

      
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$add_product_products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

 

Replace with

	  
// set price per unit / per item multimixer 20 8 10 added , popt.products_options_per_name  
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_per_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$add_product_products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

 

Find

            
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->format($products_options['options_values_price'], true, $order->info['currency'], $order->info['currency_value']) .')';

 

Replace with

            
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->format($products_options['options_values_price'], true, $order->info['currency'], $order->info['currency_value']) . ' ' . $products_options_name['products_options_per_name'] .')'; // set price per unit / per item multimixer 20 8 10 $products_options_name['products_options_per_name']

 

----------------------

3) File admin/edit_orders_ajax.php

 

Find

	  
tep_db_query("UPDATE " . TABLE_ORDERS_PRODUCTS . " SET " . $_GET['field'] . " = '" . oe_iconv($_GET['new_value']) . "' WHERE orders_products_id = '" . $_GET['pid'] . "' AND orders_id = '" . $_GET['oID'] . "'");

 

Add after

// BOF set price per unit / per item multimixer 20 8 10
  if (isset($_GET['final_price'])) {
	tep_db_query("UPDATE " . TABLE_ORDERS_PRODUCTS . " SET final_price = '" . tep_db_input(tep_db_prepare_input($_GET['final_price'])) . "' WHERE orders_products_id = '" . $_GET['pid'] . "' AND orders_id = '" . $_GET['oID'] . "'");
  }
// EOF set price per unit / per item multimixer 20 8 10

 

------------------------

4) File admin/edit_orders.php

 

Find

			// Update Any Attributes
			if(isset($products_details['attributes'])) { 
			  foreach($products_details['attributes'] as $orders_products_attributes_id => $attributes_details) {
				$Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
					products_options = '" . $attributes_details["option"] . "',
					products_options_values = '" . $attributes_details["value"] . "',
					options_values_price ='" . $attributes_details["price"] . "',
					price_prefix ='" . $attributes_details["prefix"] . "'
					where orders_products_attributes_id = '$orders_products_attributes_id';";
					tep_db_query($Query);
				}//end of foreach($products_details["attributes"]
			}// end of if(isset($products_details[attributes]))

 

Replace with

			// Update Any Attributes
			// set price per unit / per item multimixer 20 8 10	added options_per_name ='" . $attributes_details['pername'] . "', options_price_calc ='" . $attributes_details['calcway'] . "',
			if(isset($products_details['attributes'])) { 
			  foreach($products_details['attributes'] as $orders_products_attributes_id => $attributes_details) {
				$Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
					products_options = '" . $attributes_details["option"] . "',
					products_options_values = '" . $attributes_details["value"] . "',
					options_values_price ='" . $attributes_details["price"] . "',
					options_per_name ='" . $attributes_details['pername'] . "',
					options_price_calc ='" . $attributes_details['calcway'] . "',
					price_prefix ='" . $attributes_details["prefix"] . "'
					where orders_products_attributes_id = '$orders_products_attributes_id';";
					tep_db_query($Query);
				}//end of foreach($products_details["attributes"]
			}// end of if(isset($products_details[attributes]))

 

Find

 // currecies drop-down array
 $currency_query = tep_db_query("select distinct title, code from " . TABLE_CURRENCIES . " order by code ASC");  
 $currency_array = array();
 while($currency = tep_db_fetch_array($currency_query)) {
   $currency_array[] = array('id' => $currency['code'],
                             'text' => $currency['code'] . ' - ' . $currency['title']);
 }

 

Add after

//BOF multimixer set price per unit / per item 20 8 10 
 $products_options_calc_way[OPTIONS_PER_UNIT] = OPTIONS_PER_UNIT_NAME;
 $products_options_calc_way[OPTIONS_PER_ITEM] = OPTIONS_PER_ITEM_NAME;
// Translate calculation way values to english string
function translate_type_to_name1($calc_way) {
 global $products_options_calc_way;
 return isset($products_options_calc_way[$calc_way]) ? $products_options_calc_way[$calc_way] : 'Error ' . $calc_way;
}
//EOF multimixer set price per unit / per item 20 8 10 

 

Find

"<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][price]' size='7' value='" . $order->products[$i]['attributes'][$j]['price'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" onChange=\"updateAttributesField('hard', 'options_values_price', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>";

 

Replace with

"<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][price]' size='7' value='" . $order->products[$i]['attributes'][$j]['price'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" onChange=\"updateAttributesField('hard', 'options_values_price', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>" . 
			//BOF set price per unit / per item multimixer 20 8 10
			"<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][pername]' size='10'  value='" . oe_html_quotes($order->products[$i]['attributes'][$j]['pername']) . "' onChange=\"updateAttributesField('simple', 'options_per_name', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\">" .
			"<input type=hidden name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][calcway]' size='1' id='p" . $orders_products_id . "_" . $orders_products_attributes_id . "_calcway' value='" . $order->products[$i]['attributes'][$j]['calcway'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" onChange=\"updateAttributesField('hard', 'options_price_calc', '" . $orders_products_attributes_id . "', '" . $orders_products_id . "', encodeURIComponent(this.value))\">"; echo translate_type_to_name1($order->products[$i]['attributes'][$j]['calcway']);
			//EOF set price per unit / per item multimixer 20 8 10

 

Find

"<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][price]' size='7' value='" . $order->products[$i]['attributes'][$j]['price'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>";

 

Replace with

"<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][price]' size='7' value='" . $order->products[$i]['attributes'][$j]['price'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>" . 
			//BOF set price per unit / per item multimixer 20 8 10
			"<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][pername]' size='10' value='" . oe_html_quotes($order->products[$i]['attributes'][$j]['pername']) . "'>".
			"<input type=hidden name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][calcway]' size='1' id='p" . $orders_products_id . "_" . $orders_products_attributes_id . "_calcway' value='" . $order->products[$i]['attributes'][$j]['calcway'] . "' onKeyUp=\"updatePrices('att_price', '" . $orders_products_id . "')\">" ; echo translate_type_to_name1($order->products[$i]['attributes'][$j]['calcway']);				
//EOF set price per unit / per item multimixer 20 8 10

 

-----------------------------

5) File admin/order_editor/cart.php

 

Find

            $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }

 

Replace with

	// BOF set price per unit / per item multimixer 20 8 10	added options_price_calc	
           $attribute_price_query = tep_db_query("select options_values_price, price_prefix, options_price_calc from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");
// EOF set price per unit / per item multimixer 20 8 10		
           $attribute_price = tep_db_fetch_array($attribute_price_query);

// BOF set price per unit / per item multimixer 20 8 10		
  	if ($attribute_price['options_price_calc'] == '0') {
// EOF set price per unit / per item multimixer 20 8 10		
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
// BOF set price per unit / per item multimixer 20 8 10		
} else {
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
}		
// EOF set price per unit / per item multimixer 20 8 10		

 

Find

          $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $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'];
         }

 

Replace with

	// BOF set price per unit / per item multimixer 20 8 10	added options_price_calc	
         $attribute_price_query = tep_db_query("select options_values_price, price_prefix, options_price_calc from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");
// EOF set price per unit / per item multimixer 20 8 10		
         $attribute_price = tep_db_fetch_array($attribute_price_query);

// BOF set price per unit / per item multimixer 20 8 10		
  	if ($attribute_price['options_price_calc'] == '0') {
// EOF set price per unit / per item multimixer 20 8 10		
         if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
// BOF set price per unit / per item multimixer 20 8 10		
} else {
         if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'] / $this->contents[$products_id]['qty'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'] / $this->contents[$products_id]['qty'];
         }
}		
// EOF set price per unit / per item multimixer 20 8 10		

 

-----------------------------

 

6) File admin/order_editor/javascript.php

 

Find

        var url = "<?php echo FILENAME_ORDERS_EDIT_AJAX; ?>?action=update_product_field&oID=<?php echo $_GET['oID']; ?>&pid=" + pid + "&field=" + field + "&new_value=" + value;

 

Replace with

// BOF set price per unit / per item multimixer 20 8 10
	var final_price = document.getElementById("update_products[" + pid + "][final_price]").value; // set price per unit / per item multimixer 20 8 10
       var url = "<?php echo FILENAME_ORDERS_EDIT_AJAX; ?>?action=update_product_field&oID=<?php echo $_GET['oID']; ?>&pid=" + pid + "&field=" + field + "&new_value=" + value + "&final_price=" + final_price;
// EOF set price per unit / per item multimixer 20 8 10

 

Find

	if ((action != 'qty') && (action != 'price_incl')) {
document.getElementById("update_products[" + pid + "][price_incl]").value = doFormat(priceInclValue, 4);
}

 

Replace with

//BOF set price per unit / per item multimixer 20 8 10	if ((action != 'qty') && (action != 'price_incl')) {
// BOF original
/* 
if ((action != 'qty') && (action != 'price_incl')) {
document.getElementById("update_products[" + pid + "][price_incl]").value = doFormat(priceInclValue, 4);
}
*/ 
//EOF original
if (action != 'price_incl') { // The (action != 'qty') condition taken out, so reaktion ok on qty changes // price incl
document.getElementById("update_products[" + pid + "][price_incl]").value = doFormat(priceInclValue, 10);
}
//EOF set price per unit / per item multimixer 20 8 10	

 

Find

   function getAttributesPrices(pid){ //get any attributes prices that may exist 
   var sum =0;
   var el=document.getElementsByTagName('input');//all the input elements
     for(var i=0;i<el.length;i++){
      if(el[i].id.indexOf(pid)>-1){
       var aid=el[i].id.replace(pid,'').replace('p', '').replace('a', '');//extract the attribute id
       var p=el[i].id.replace(pid,'').replace(/\d/g,'');
         if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '-') {
          sum-=Number(el[i].value);
         }
         if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '+') {
          sum+=Number(el[i].value);
         }
        }
       }
     return sum
    } //end function getAttributePrices(pid)

 

Replace with

//BOF set price per unit / per item multimixer 20 8 10	if ((action != 'qty') && (action != 'price_incl')) {
// BOF original
/* 
  function getAttributesPrices(pid){ //get any attributes prices that may exist 
   var sum =0;
   var el=document.getElementsByTagName('input');//all the input elements
   var qty = document.getElementById("update_products[" + pid + "][qty]").value; //set price per unit / per item multimixer 20 8 10
     for(var i=0;i<el.length;i++){
      if(el[i].id.indexOf(pid)>-1){
       var aid=el[i].id.replace(pid,'').replace('p', '').replace('a', '');//extract the attribute id
       var p=el[i].id.replace(pid,'').replace(/\d/g,'');
         if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '-') {
          sum-=Number(el[i].value);
         } // if((p=='pa')
         if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '+') {
          sum+=Number(el[i].value);
         } // if((p=='pa')
        } // end if(el[i].id.indexOf(pid)>-1){
       } // end for(var i=0;i<el.length;i++){
     return sum
    } //end function getAttributePrices(pid)
*/ 
//EOF original

  function getAttributesPrices(pid){ //get any attributes prices that may exist 
   var sum =0;
   var el=document.getElementsByTagName('input');//all the input elements
   var qty = document.getElementById("update_products[" + pid + "][qty]").value; //set price per unit / per item multimixer 20 8 10
     for(var i=0;i<el.length;i++){
      if(el[i].id.indexOf(pid)>-1){
       var aid=el[i].id.replace(pid,'').replace('p', '').replace('a', '');//extract the attribute id
       var p=el[i].id.replace(pid,'').replace(/\d/g,'');

         if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_calcway')) && (document.getElementById('p' + pid + '_' + aid + '_calcway').value) == '0') { // if per unit

         		if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '-') {
          		sum-=Number(el[i].value);
         		} // if((p=='pa')
         		if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '+') {
          		sum+=Number(el[i].value);
         		} // if((p=='pa')
		} // end if per unit

         if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_calcway')) && (document.getElementById('p' + pid + '_' + aid + '_calcway').value) == '1') { // if per item

         		if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '-') {
          		sum-=Number(el[i].value) / qty;
         		} // if((p=='pa')
         		if((p=='pa') && (document.getElementById('p' + pid + '_' + aid + '_prefix')) && (document.getElementById('p' + pid + '_' + aid + '_prefix').value) == '+') {
          		sum+=Number(el[i].value) / qty;
         		} // if((p=='pa')
		} // end if per item

        } // end if(el[i].id.indexOf(pid)>-1){
       } // end for(var i=0;i<el.length;i++){
     return sum
    } //end function getAttributePrices(pid)

//EOF set price per unit / per item multimixer 20 8 10	

 

--------------------------------------

7) File admin/order_editor/order.php

 

Find

        $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
       if (tep_db_num_rows($attributes_query)) {
         while ($attributes = tep_db_fetch_array($attributes_query)) {
           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
                                                                    'value' => $attributes['products_options_values'],
                                                                    'prefix' => $attributes['price_prefix'],
                                                                    'price' => $attributes['options_values_price'],
                                            'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);

 

Replace with

		// set price per unit / per item multimixer 20 8 10	added , options_per_name, options_price_calc	
       $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id, options_per_name, options_price_calc from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
       if (tep_db_num_rows($attributes_query)) {
         while ($attributes = tep_db_fetch_array($attributes_query)) {
           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
                                                                    'value' => $attributes['products_options_val2520'calcway' => $attributes['options_price_calc'],
							     // set price per unit / per item multimixer 20 8 10 (2 lines above added)
                                            'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);

------------------------------

You are done :)

------------------------------

What is new?

 

Going now to your order editor in admin, you will see that adding a new product with attributes will calculate the price correctly, depending on the option setting you have for every option (to be per item or per unit)

 

After the product is added you will see 2 more field beside each attribute price.

- Th2520'calcway' => $attributes['options_price_calc'],

// set price per unit / per item multimixer 20 8 10 (2 lines above added)

'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);

[/code]

------------------------------

You are done :)

------------------------------

What is new?

 

Going now to your order editor in admin, you will see that adding a new product with attributes will calculate the price correctly, depending on the option setting you have for every option (to be per item or per unit)

 

After the product is added you will see 2 more field beside each attribute price.

- The input field is to enter a calculation way description, that free text up to 32 characters

 

- On the right there is a text saying "per item" or "per unit", thats just for you to know how the attributes price is getting calculated. This is not meant to be changed (it's set once per option in attribute manager) but if you want you can:

 

In file admin/edit_orders.php search for

"<input type=hidden

and delete the

 type=hidden

Doing this, you will see one more input field with values 0 (=per unit) or 1 (=per item). Changing between this 2 values will change the attribute calculation way just for this attribute, this product and this order, no influence to other settings

--------------------------------

Last note: I'm sorry if this all appear like replacing huge parts of code. In real in most of the cases you are just adding something to the code. Reading the issues the most users have with "details" like a forgotten } etc, I prefered to post complete parts of code to make it easier to copy paste without too much thinking

 

Have a nice day all

Edited by multimixer

Share this post


Link to post
Share on other sites

Somehow the upload got corrupted

 

Again just for 7) File admin/order_editor/order.php

 

Find

        $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
       if (tep_db_num_rows($attributes_query)) {
         while ($attributes = tep_db_fetch_array($attributes_query)) {
           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
                                                                    'value' => $attributes['products_options_values'],
                                                                    'prefix' => $attributes['price_prefix'],
                                                                    'price' => $attributes['options_values_price'],
                                            'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);

 

Replace with

		// set price per unit / per item multimixer 20 8 10	added , options_per_name, options_price_calc	
       $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id, options_per_name, options_price_calc from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
       if (tep_db_num_rows($attributes_query)) {
         while ($attributes = tep_db_fetch_array($attributes_query)) {
           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
                                                                    'value' => $attributes['products_options_values'],
                                                                    'prefix' => $attributes['price_prefix'],
                                                                    'price' => $attributes['options_values_price'],
                                                                    'pername' => $attributes['options_per_name'],
							      'calcway' => $attributes['options_price_calc'],
							     // set price per unit / per item multimixer 20 8 10 (2 lines above added)
                                            'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);

Share this post


Link to post
Share on other sites

hi,

 

I have downloaded this contribution after seeing it on another site because i need for the customer to enter characters over 3 or 4 lines that can be engraved onto a product.

 

I am lost with the install file 'option types v2 installtion instruction.txt' because there are characters in there that i have no idea what they are or are refering too...

 

\f1\fs24 \

\

 

\f0\fs22 \cf2 echo \cf3 '<br><nobr><small> <i> - ' \cf0 . \cf4 $order\cf0 ->products[\cf4 $i\cf0 ][\cf3 'attributes'\cf0 ][\cf4 $j\cf0 ][\cf3 'option'\cf0 ] . \cf3 ': ' \cf0 . \cf4 $order\cf0 ->products[\cf4 $i\cf0 ][\cf3 'attributes'\cf0 ][\cf4 $j\cf0 ][\cf3 'value'\cf0 ] . \cf3 '</i></small></nobr>'\cf0 ;\

\

 

 

 

on the 1st part of the find this and replace with... i have no idea what all the /cf3 etc are as they are not proper php coding

 

can anyone help or maybe could supply proper install instructions??

 

many thanks - Mark

Share this post


Link to post
Share on other sites

I am lost with the install file 'option types v2 installtion instruction.txt' because there are characters in there that i have no idea what they are or are refering too...

 

\f1\fs24 \

\

 

\f0\fs22 \cf2 echo \cf3 '<br><nobr><small> <i> - ' \cf0 . \cf4 $order\cf0 ->products[\cf4 $i\cf0 ][\cf3 'attributes'\cf0 ][\cf4 $j\cf0 ][\cf3 'option'\cf0 ] . \cf3 ': ' \cf0 . \cf4 $order\cf0 ->products[\cf4 $i\cf0 ][\cf3 'attributes'\cf0 ][\cf4 $j\cf0 ][\cf3 'value'\cf0 ] . \cf3 '</i></small></nobr>'\cf0 ;\

\

 

 

You are not the first one who report this problem. The installation instructions uploaded by rosemaryann (13 11 2009) are either wrong or corrupted.

 

Take the version of 18 10 2009 by Zappo and use a file comparison tool to merge the files

 

Also go through the pages of this topic from 18 10 2009 on, for reported bugs, fixes and improvements

 

A new version will be coming soon, but till then thats the best you can do

Share this post


Link to post
Share on other sites

Hi...after a bit of 'trial and error' with STS 4.6 i finally got this great contrib going...as most have stated it was exactly what they were after.

 

I am pretty fresh with php so some direction/confirmation of my thoughts would be appreciated. On your cart you sell a product with which a buyer can select size, colour, upload a picture to have printed on etc. Lets say s/he has successfully chosen 6 drop down boxes...choosing a variable from each and then proceeds through checkout.

 

They receive an email soon after that lists the 6 drop down boxes and variables they have chosen and we see it in Admin view in both packing/invoice detail.

 

I have installed a contrib called PDF_Customer_Invoice_v1.1 where via accessing My Account the user can print off an invoice once the product etc has been delivered.

 

It is in this area I'd like to ask a question. The pdf invoice without any modification will only show a single line of the customer purchase. Once you run out of line, that also means the end of any purchase description that equates not giving a full invoice of purchase. (want to duplicate what admin invoice or packing slip offers where you see full account of purchase)

 

How or where do I begin to start the modifications. Amongst some files uploaded, common ones are catalog/pdfinvoice and account_history_info and includes/languages/english/pdfinvoice and account_history_info

I am assuming it is a table properties setting...but assuming is about all.

 

Any thoughts would be great!!

 

cheers

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

×