Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Option Type Feature v1.6 (for osc 2.2 MS2)


Guest

Recommended Posts

I just posted Version 1.6 of the Product Attributes - Option Type Feature. You can find it at.

 

http://www.oscommerce.com/community/contributions,160

 

The purpose of this contribution is to allow the use of various option types when setting up product attributes. Originally the contribution included support for Text options. It now also includes support for Radio Buttons and Checkboxes.

 

This page includes a link to a demo store using the contribution http://www.OpenStoreSolutions.com/option_t...ontribution.php

 

Version 1.6 of the contribution is built for osc 2.2 Milestone 2.

 

Cheers,

-Chandra

http://www.OpenStoreSolutions.com

Link to comment
Share on other sites

  • Replies 799
  • Created
  • Last Reply

Top Posters In This Topic

Would someone help me get this to work? I am trying to use this feature with Option as Images. With the code as below, the images option works but the text input does not -- the input option shows as a scroll down box with the words TEXT inside. If I comment out the Option as Images "if" and "true" statements (catalog/product_info.php), then the Option Type feature works perfectly.

 

I am too new to php to figure out how to rearrange the code, if possible, to work with both TEXT input option and images. I'd be really grateful if someone here could give it a go...this begins line 133 in my catalog/product_info.php

 

//Options as Images

   if (OPTIONS_AS_IMAGES_ENABLED == 'false') {

   $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 . "'");

   $products_attributes = tep_db_fetch_array($products_attributes_query);

   if ($products_attributes['total'] > 0) {

?>

         <table border="0" cellspacing="0" cellpadding="2">

           <tr>

             <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>

           </tr>

<?php

  //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 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_name");

     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

   //clr 030714 add case statement to check option type

       switch ($products_options_name['products_options_type']) {

         case PRODUCTS_OPTIONS_TYPE_TEXT:

           //CLR 030714 Add logic for text option

           $products_attribs_query = tep_db_query("select distinct 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);

           $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'] ;

           if ($products_attribs_array['options_values_price'] != '0') {

             $tmp_html .= '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], $product_info_values['products_tax_class_id']) .')';

           }

?>

           <tr>

             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

             <td class="main"><?php echo $tmp_html;  ?></td>

           </tr>

<?php

           break;

         case PRODUCTS_OPTIONS_TYPE_RADIO:

           //CLR 030714 Add logic for radio buttons

           $tmp_html = '<table>';

           $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)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

           $checked = true;

           while ($products_options_array = tep_db_fetch_array($products_options_query)) {

             $tmp_html .= '<tr><td class="main">';

             $tmp_html .= tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array['products_options_values_id'], $checked);

             $checked = false;

             $tmp_html .= $products_options_array['products_options_values_name'] ;

             $tmp_html .=$products_options_name['products_options_comment'] ;

             if ($products_options_array['options_values_price'] != '0') {

               $tmp_html .= '(' . $products_options_array['price_prefix'] . $currencies->display_price($products_options_array['options_values_price'], $product_info_values['products_tax_class_id']) .') ';

             }

             $tmp_html .= '</tr></td>';

           }

           $tmp_html .= '</table>';

?>

           <tr>

             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

             <td class="main"><?php echo $tmp_html;  ?></td>

           </tr>

<?php

           break;

         case PRODUCTS_OPTIONS_TYPE_CHECKBOX:

           //CLR 030714 Add logic for checkboxes

           $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">' . $products_options_name['products_options_name'] . ': </td><td class="main">';

           echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']);

           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'], $product_info_values['products_tax_class_id']) .') ';

           }

           echo '</td></tr>';

           break;

         default:

           //clr 030714 default is select list

           //clr 030714 reset selected_attribute variable

           $selected_attribute = false;

         $products_options_array = array();

         $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)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");

         while ($products_options = tep_db_fetch_array($products_options_query)) {

           $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

           if ($products_options['options_values_price'] != '0') {

             $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

           }

         }

 

         if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {

           $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];

         } else {

           $selected_attribute = false;

         }

?>

           <tr>

             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

             <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . $products_options_name['products_options_comment'];  ?></td>

           </tr>

<?php

       }  //clr 030714 end switch

     } //clr 030714 end while

?>

         </table>

<?php

      } //clr 030714 end if

//Options as Images added curly bracket next line

}

?>

<?php

   //Options as Images. Entire php clause added

if (OPTIONS_AS_IMAGES_ENABLED == 'true') include ('options_images.php');

?>

       </td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

     </tr>

 

Thanks,

Maureen

Link to comment
Share on other sites

Maureen,

 

You can display images next to radio buttons with the Option Type Feature. If this is all you need, then you don't need to make any code changes at all.

 

For radio options where you want an image displayed just set the Option Value to <img src=images/image_name.gif>.

 

There are a couple important things to note though:

  • 1. The option value is limited to 32 characters, so if you have long image names then you?ll have problems.

2. Having quotes around the src value (for example src=?images/image_name.gif?) causes problems, so you can?t use quotes. This means there can?t be any spaces in the src value (i.e no spaces in your image names).

3. The <img src=images/image_name.gif> will be displayed in the email, so if you don?t use html emails this will look strange.

I'll add an example product to the demo catalog, so check http://www.OpenStoreSolutions.com/option_t...ontribution.php later today for an example.

 

Cheers,

Chandra

http://www.OpenStoreSolutions.com

Link to comment
Share on other sites

chandra,

 

Great Work.. I'm looking forward into installing this contribution, U have done a very great job to input text to anything. This make life so much easier... I'll install it tonight and see if everything all goes well ok

 

thanks

Link to comment
Share on other sites

Hi Chandra,

 

great contrib... just a quick [stupid] question!

 

I have osc 2.2 ms1, and have version 1.4 of your contrib - but i also need check boxes and radio buttons. I read the previous thread on version 1.4 and various discussions on how to add the above - but nothing was clear.

 

My question is this: Will it be possible to just copy the code from 1.6 only about radio/check boxes and place them beneath your code for 1.4?

 

I hope the functions hae not changed that much!

 

Regards,

 

Jiten

Link to comment
Share on other sites

Hi Chandra,

 

Thanks for such a fast reply! I did not know that images could be displayed this way. What I was hoping to be able to do was add the images in columns/rows instead of a straight listing. Some of the products have up to 60 design options; without using rows of at least 4 columns the pages are way too long. This is why I was trying to incorporate the Options as Images (as well as the ability to control the images per row and image size through admin).

 

Here is one of the products; this has 1/2 of the design options listed:

http://www.granthamintlsales.com/catalog/p...?products_id=69

 

I want the TEXT option for the engraving and the columns for the Head Designs. Any ideas or suggestions...

 

Thanks again!

 

Maureen

Link to comment
Share on other sites

installed the contribution with smooth...

 

Was wondering how do you input images in the radio buttom? The index.html you includes didn't show how to do that. Can you explain it here on where to go. or give me an example on how one is done..

 

thanks

Link to comment
Share on other sites

Chandra,

 

Your contribution reads exactly like what I need to add to my store. Here is my problem: It has taken me 2 days to get phpMyAdmin to function and I am not able to get phpMyAdmin to locate a 'data base'. The menu on the left say 'no database'. I have it installed to my 'store' directory.

 

Should it be located somewhere else?

 

Where are the data bases located?

 

I have done a search of my directories for a db and can't seem to locate it/them?

 

Do you offer any direct support for an install of your contribution?

 

Sorry if these seem to be basic questions to you but the last time I did any programing was to install wire jumpers on a backplane main board on a computer the size of my living room.

 

Thanks in advance.

Wayne

Link to comment
Share on other sites

Your problem is that you mess have copy the whole folder over to your NEW OSC 2.1.

 

Don't copy the configure.php in the contribution, as it got nothing in the configure.php

 

instead just edit the configure.php at the end. it should says, Option Type.

just copy that and paste it to your orginal configure.php

 

That will do the trick..

 

Also insert all the .sql file into your database..

Link to comment
Share on other sites

On the question about how to add comments... Currently you have to do this in the database directly (i.e. there is no user interface tool for doing it).

 

Find the row with your Option in the products_options table and add your comment in the products_options_comment field.

Link to comment
Share on other sites

Hi Chandra,

 

I am a very happy user of the option type feature, and it works great! But I have one problem. All the prices on my site or presented including Tax but the options are not. Is it easy to fix this?

 

I really hope you can help me.

 

Thank you already,

 

Jeroen

Link to comment
Share on other sites

Hi Chandra,

 

I think your contribution is just what I need,... that is if I ever get it installed.

 

I am new to PHP and the instructions that you give or not clear enough for someone with my limited experience. If you or someone else could help I would appreciate it.

 

OK as per your instructions....

 

1) I have "STEP 1. Add new fields to db" completed.

 

2) STEP 2. Install files containing the feature into your version of osCommerce is my problem.

 

I do not have a clean version of oscommerce, I have modified it quite a bit.

 

So my question is when you say merge a file. What do you mean?

 

I have Winmege and I can see the difference in the files. But when I use it to copy your code... that is not in the oscommerce original code then what I end up with is a file that is just like your file. Thus I have really just over written the file in essence.

 

Of course this is what I do not want to do, since I have already altered my oscommerce files before coming to your contribution.

 

So can I just copy your code for each file that is not in the original files at the bottom of the original files and have it work right?

 

If not want can I do?

 

Thanks

Leon

I'm having a great Day - hope you are too!

 

Leon

Link to comment
Share on other sites

Hi Jeroen,

 

To have the option prices display correctly when tax is included in the price display, you'll need to update your product_info.php.

 

Search for

 

$product_info_values['products_tax_class_id']

 

and replace it with

 

tep_get_tax_rate($product_info['products_tax_class_id'])

 

You should find and replace three occurences - one for text options, one for radio buttons, and one for checkboxes.

 

Cheers,

Chandra

http://www.OpenStoreSolutions.com

Link to comment
Share on other sites

I am need of the correct verison of this contribution for a 2.2 CVS shop. I cant upgrade to MS2 beacuse i have too many contributions added now and will have to wait a whil before i can do this.

Is there a version I can use for 2.2 CVS shop that will allow me to define the display type for my options?

 

Thanks,

ant

Link to comment
Share on other sites

There are a couple important things to note though:

1. The option value is limited to 32 characters, so if you have long image names then you?ll have problems.

Can the 32 character limit be changed by tweaking the database fields?

 

Are there any unfortunate side effects of doing that?

Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

Download STS: http://www.oscommerce.com/community/contributions,1524

Support: http://www.oscommerce.com/forums/index.php?showtopic=58541

Link to comment
Share on other sites

Hi,

 

I started over but am having these problems. I do not understand the instructions.

 

When I click the "edit" link on the http://www.designhosting.us/catalog/checko...onfirmation.php page it goes to the shopping cart page:

http://www.designhosting.us/catalog/shopping_cart.php

 

All of the product options in the attribute section is linked to the option value "TEXT". I don't understand what this is suppose to do. It looks funny when checking out to see the option name and then TEXT. When I fill in the text box in the product description it doesn't stay during checkout.

http://www.designhosting.us/catalog/produc...3&products_id=8

 

Is this text box for me to fill in which would be nice or for the customer?

 

Also, I get this on the last page of the checkout:

 

Fatal error: Call to undefined function: tep_decode_specialchars() in /home/designus/public_html/catalog/checkout_process.php on line 214

 

I have installed your contribution sql exactly like you had it leaving the TEXT set to 0.

Edited by modom
Link to comment
Share on other sites

Is there a way to sort the way the options appear, or does it just do it alphabetically by Option name?

 

Also, everything seems to work except my Text field on this sample page when it goes into the cart.

 

It looks like I've got the updated shopping_cart.php in place. What did I forget to do? :)

 

Thanks for the great contribution!

 

- Brian

Edited by DiamondSea

Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

Download STS: http://www.oscommerce.com/community/contributions,1524

Support: http://www.oscommerce.com/forums/index.php?showtopic=58541

Link to comment
Share on other sites

Hi,

 

Does anyone know how to fix these problems?

 

When I click the "edit" link on the http://www.designhosting.us/catalog/checko...onfirmation.php page it goes to the shopping cart page:

http://www.designhosting.us/catalog/shopping_cart.php

 

All of the product options in the attribute section is linked to the option value "TEXT". I don't understand what this is suppose to do. It looks funny when checking out to see the option name and then TEXT. When I fill in the text box in the product description it doesn't stay during checkout.

http://www.designhosting.us/catalog/produc...3&products_id=8

 

Is this text box for me to fill in which would be nice or for the customer?

 

Also, I get this on the last page of the checkout:

 

Fatal error: Call to undefined function: tep_decode_specialchars() in /home/designus/public_html/catalog/checkout_process.php on line 214

 

I have installed your contribution sql exactly like you had it leaving the TEXT set to 0.

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

Please Help I'm getting the following error after installing the option type feature

 

Fatal error: Call to undefined function: tep_decode_specialchars() in /home/designus/public_html/catalog/checkout_process.php on line 214

 

I have installed your contribution sql exactly like you had it leaving the TEXT set to 0.

Link to comment
Share on other sites

Melinda,

 

I see three possible problems. One, you don't have option value 0 selected for the text attribute. Two, you don't have PRODUCTS_OPTIONS_VALUE_TEXT_ID defined as 0 (in configure.php). Three, you're missing some code that would interpret those values in shopping_cart.php or includes/classes/shopping_cart.php. On the bright side, if you look in the URL, you will see that it is passing the text.

 

Since it doesn't know what type the option is in the shopping_cart, it looks at PRODUCTS_OPTIONS_VALUE_TEXT_ID to recognize that an option is a text option.

 

tep_decode_specialchars is defined in the includes/functions/general.php that comes with the contribution. Make sure you copy the definition over if you don't use the file that comes with the contribution.

 

Hth,

Matt

Link to comment
Share on other sites

Matt,

 

Thanks, I found it after I decided to compare the files that came in the package. It is at the very end of the general.php file. I was working on this one for 24 hours straight. However I did find that most of the variables that are defined within the OSCommerce package begin with tep_ this helped me to figure out what was going on. Does anyone know of a complete list of variables & their functions? I guess my Basic & Cobol programming habits are coming back (SHAME ON ME! that was 20 years ago. This package is great!

 

The Tech :rolleyes:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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