Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Is it possible to add another type of attribute? I'm looking for a way to add a textarea box so a user can put in special instructions for each product, but I haven't been able to do it.

 

Could I modify the tables that were created / modified in Option Type by adding a field and coding in something in the product_info.php page? Would I need to change anything else?

 

Any help greatly appreciated, this is a big obstacle (and probably the last big one) towards getting the site live!

Posted
Is it possible to add another type of attribute? I'm looking for a way to add a textarea box so a user can put in special instructions for each product, but I haven't been able to do it.

 

Could I modify the tables that were created / modified in Option Type by adding a field and coding in something in the product_info.php page? Would I need to change anything else?

 

Any help greatly appreciated, this is a big obstacle (and probably the last big one) towards getting the site live!

looking for the same thing ! The contribution is limited to a text box of 32 chars. I need more and also with html chars. I would like the customers to format their text that goes with the products (invitation card in my case).

 

Problem is not adding a field to products, but storing it in the customer_basket, order tables, etc. The way of adding a text box as "option" is a good thang,but it must be possible to extend it to a textarea. I already succeeded in displaying an html textarea + a javascript "htmlarea". But I did not go further.

 

I checked out the complete OTF 1.6 thread and it seems that other people are also interested in this "textarea" feature.

 

Maybe we can work together on this...

 

Didier.

Posted

I think the best way to do this would be to copy from the comment box in the checkout shipping page. Someone suggested this to me before, but in my stupidity I just copied the code and it messed things up.

 

I've been trying to look at the logic of that section, but I can't find everything, I'm not sure where to put/change stuff.

 

Any help from anyone would be appreciated.

Posted (edited)

Someone tried to help me but got stuck. I'm trying to do it. Here is what I have documented. I'm just trying to copy the Option Type contribution and add another...option type :-)

Change MySQL Database:

 

ALTER TABLE customers_basket_attributes ADD products_options_value_textbox TEXT ;

 

ALTER TABLE products_options ADD products_options_length_textbox SMALLINT( 2 ) DEFAULT '75' NOT NULL ,

 

INSERT INTO products_options_values (products_options_values_id, language_id, products_options_values_name) VALUES (1, 1, 'TEXTBOX');

 

 

Add to includes/configure.php (must make writeable):

 

define('PRODUCTS_OPTIONS_TYPE_TEXTBOX', 4);

define('PRODUCTS_OPTIONS_VALUE_TEXT_ID', 1);? //Must match id for user defined "TEXTBOX" value in db table TABLE_PRODUCTS_OPTIONS_VALUES

 

 

 

In product_info.php:

 

add this:

 

popt.products_options_length_textbox

 

to this:

 

//clr 030714 update query to pull option_type

? ? ? $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, popt.products_options_length_textbox 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 . "' order by popt.products_options_id");

 

add this:

 

$tmpbox_html = '<input type="textarea" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" <br> size="' . $products_options_name['products_options_length_textbox'] .'" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'">? ' . $products_options_name['products_options_comment'] ;

 

after this:

 

$tmp_html = '<input type="text" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" size="' . $products_options_name['products_options_length'] .'" maxlength="' . $products_options_name['products_options_length'] . '" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'">? ' . $products_options_name['products_options_comment'] ;

 

That last part can't be right. I don't want to put in the ECHO and have it duplicate the options with a textarea box. I need to make it so it selects from the options which id=1 then show those with the textarea.

 

Am I on the right track?

 

I want it to look something like this http://www.takenoteonline.com/catalog/prod...&products_id=92

 

If I'm an idiot tell me, but please show me how I'm an idiot and how to fix it.

Edited by soccercheese
  • 2 months later...
Posted

I too am curious if you ever got this working.

 

I just got the idea to give this a try today.

  • 4 weeks later...
Posted

Didier,

will v1.7 also support 2 or more text areas ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted
Didier,

will v1.7 also support 2 or more text areas ?

 

Goeie vraag Carine ! (hehe..yes..I'm from Gent-Belgium but let's go in english).

 

I have it working for one textarea and even added a script that tests the maximum input size of the textfield.

 

I will do the test to see if I can have 2 textarea fields for 1 product each with a different length.

 

Didier.

Posted
Goeie vraag Carine ! (hehe..yes..I'm from Gent-Belgium but let's go in english).

 

I have it working for one textarea and even added a script that tests the maximum input size of the textfield.

 

I will do the test to see if I can have 2 textarea fields for 1 product each with a different length.

 

Didier.

 

Yip..no problem..I have 2 different textareas for 2 options each of a different length and price.

 

Didier.

Posted
Yip..no problem..I have 2 different textareas for 2 options each of a different length and price.

 

Didier.

Looks like you just gave me an incentive to upgrade :) Thanks a lot !

Vree weis. :thumbsup:

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted

Hi, all: While I understand that Didier will be posting a more complete upgrade in the next few hours or so (thanks!), I wrote this solution to use if you just want to add text boxes to an earlier installation. It's pretty straight forward:

 

1) In includes/configuration.php add the following line:

define('PRODUCTS_OPTIONS_TYPE_TEXTAREA', 4);

 

2) Go to the 'order_products_attributes' table and change the 'products_option_values' type to a longer value. (I used mediumtext, but even Text will do.)

 

3) In product_info.php add the following lines to the switch statement:

 

                <?php
                	 
                 case PRODUCTS_OPTIONS_TYPE_TEXTAREA:
                	 //CLR 030714 Add logic for text area fields
                	 $products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
                	 $products_attribs_array = tep_db_fetch_array($products_attribs_query);
                	 echo '<tr><td class="main" nowrap>' . $products_options_name['products_options_name'] . ': </td><td class="main" width="80%">';
        	 
           echo tep_draw_textarea_field('id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']','virtual', '35','5');//see above...Not sure if you need last attribute
              	 
                	 echo $products_options_name['products_options_comment'];
                	 if ($products_attribs_array['options_values_price'] != '0') {
                    echo '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
                	 }
                	 echo '</td></tr>';
                	 break;
                	 ?>
                	 <tr>
                    <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
                    <td class="main"><?php echo $tmp_html;  ?></td>
                	 </tr>

4) Go into admin/products_attributes and add

 $values[] = array('id' => 4, 'text' => 'TextArea');//line 169

and

 

  if ($opt_type == 4) return 'TextArea'; //line 180

 

For the sake of presentation, I'd also do the following to checkout_confirmation.php: at around line 233, get rid of the <nobr></nobr> tags, otherwise the new long text that people put in will make the page wrap outside the browser window. (You might consider doing the same in admin/orders.php.)

 

Now, if everything is working, you should see a new option in the 'Options' dropdown menu that says, 'TextArea'. After you add this new option to a product, select 'TEXT' as it's option, and you will be good to go. Hope this helps....

Posted

Correct Mark. You will have the same code in v1.7. I also decided to add another option type 4 so that people can choose between text and textarea fields (the best of both worlds).

I also added a *very* nice progress bar under the textarea that indicates how many chars are left in the textarea box (based on the maxlength value). I'm working on the packaging right now.

 

Bye,

 

Didier.

Posted

I just published version v1.7 of Option Type Feature : Version v1.6 has been updated to include textarea option type fields so that text is not limited anymore to 32 characters. This new feature has been requested *a lot* on the support thread.

 

This is the changelog for v1.7 :

 

- Updated file "ReadMe.html" to include correct information on new textarea type option (read Step 4)

- /includes/configure.php : added new value 'PRODUCTS_OPTIONS_TYPE_TEXTAREA (4)'.

- changed column datatype of customers_basket_attributes.products_options_value_text from varchar(32) to "text".

- added admin support of fields products_options_length and products_options_comment (no need anymore to update the database manually).

- added javascript "Form Field Progress bar" to indicate how many characters are left for the customer to type. The size is determined by the 'products_options_length' field. Thanks to Dynamic Drive for this script (http://www.dynamicdrive.com).

- added stylesheet.css in package : needed for javascript Form Field Progress bar (new style '.progress')

- includes price tax fix of 26.07.2004 by Patrick_S

- includes dutch language file for admin/producs_attributes.php (thanks to Stef Verlint)

 

You can find it here :

 

URL : 7 Nov 2004 - Product Attributes - Option Type Feature v1.7

 

Support thread : http://www.oscommerce.com/forums/index.php?sho...ic=57259&st=100

 

Try it it and tell me how it works.

 

Didier.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...