Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Making Attribute Selection Required


bmac

Recommended Posts

I sell apparel on a store and customers have been neglecting to input their size / color. Is there any way I can make these attributes "required fields" so they have to choose something before they put the item in their cart?

 

Thank you all so much,

 

Brian

Link to comment
Share on other sites

Thanks, this is what I was looking for.

 

However, I'm having a little trouble with it. The first section says to edit "product_info.php" and has a section of code, but I can't figure out what needs to be edited, etc.

 

Here is the code that is posted in the contrib:

 

$products_attributes = tep_db_query("select popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

if (tep_db_num_rows($products_attributes)) {

$products_attributes = '1';

} else {

$products_attributes = '0';

}

//BoF CB Show must error messages include any must select msg

if ($messageStack->size('product_info') > 0) {

?>

 

output('product_info'); ?>

 

 

And here is the code that is in my product_info.php:

 

<?php

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

?>

 

 

They seem to have a lot of differences, but they seem almost like different versions...

 

Any help, obviously, would be _much_ appreciated. Thanks all,

 

Brian

 

 

 

 

 

 

Link to comment
Share on other sites

Hello,

I prepared (hopefully) better instructions a while ago, someone was beta testing them, but I didn't get any feedback since a few weeks. So, I've taken the plunge and uploaded the new file.

 

Hope things are a bit clearer now

 

Carine

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

Link to comment
Share on other sites

I haven't installed this contribution but I'll take a shot at it. I also can't test it today for you (busy elsewhere) so you may need to play with the positioning in the code. You are correct the code in the documention looks like an older version. The application_top.php stuff looks ok though.

 

Make a back up and try changing this in the product_info.php around line 124

 

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

?>

 

to

 

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

//BoF CB Show must error messages include any must select msg

if ($messageStack->size('product_info') > 0) {

    output('product_info');

}

?>

 

Good Luck

Tom

 

Maybe someone else can chime in here if the above doesn't work for you.

Link to comment
Share on other sites

Please let me know how it goes.

I know it's not 100% suitable for newbies yet as it assumes you have created a 'must select' value and know how to retrieve the identifier ... time will tell if this is clear enough, if not, someone can explain how to do that and add it to the instructions :D

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

Link to comment
Share on other sites

Hey all,

 

I really appreciate your help. Admittedly, I'm not sure how to create a "must select" value at all... if anyone could offer a bit of insight, I'd really appreciate it. I'll take a look at everything else here in a bit. Thanks again,

 

 

Brian

 

 

 

 

 

 

 

 

 

 

 

 

Please let me know how it goes.

I know it's not 100% suitable for newbies yet as it assumes you have created a 'must select' value and know how to retrieve the identifier ... time will tell if this is clear enough, if not, someone can explain how to do that and add it to the instructions :D

Link to comment
Share on other sites

Hi Brian, (and Carine)

 

I installed the "Must Select" contribution following Carine's revised documentation and everything works like a dream..... :thumbsup:

 

You will just need to be very carefull on replacing the code exactly as Carine has detailed in the contribution. Look at your code and her changes, then look at them again to make sure you are doing them correctly.

 

I'll try here to walk you through how I created the "must select" option.

 

1. Go to Administration->Catalog->Product Attributes

 

You'll see three areas to work with

 

Top Left - "Product Options"

Top Right - "Option Values"

Bottom Left - "Products Attributes"

 

2. You'll be working in the Top Right "Option Values" area only

 

3. At the bottom of the "Option Values" you'll see a drop down list of your Product options. To the right of the drop down list will be the language text boxes, then to the right of those there is an "insert" button.

 

4. Also notice the "number" to the left of the drop down. That will be the special number assigned to the "must select" Option you be creating.

 

5. It doesn't matter which Product Option Name that you create the "must select" option under. I used the Color option choice cause it was just there. Fill in the english (en: text box) with something like "- Please Select -". Then make note of the number (mine was 15) and click on the Insert button. You now have the "must select" value in the system and can now add that option to any of your product Attributes at the bottom left "Product Attributes".

 

6. Make sure to change the default "must select" value of 9 in the contribution code to your particular number you got back in step 5.

 

7. I also added a sort in my attribute drop down to sort alphabetically so that my text "- Please Select -" would always sort to the top.

 

Around line 147

 

$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 . "' order by pov.products_options_values_name");

 

Hopefully this will help out. Once again, backup your files, make the changes carefully and you'll be good to go.

 

HTH

Tom

Link to comment
Share on other sites

You two are superstars, truly. This works _perfectly!_ Thank you so much for your time, I really really appreciate it.

 

Another question, if you don't mind: have either of you ever had problems with shipping UPS / USPS items over a certain weight? When someone orders a few hundred items, the UPS system tries to put them all into one (absurdly huge!) box & it overloads the UPS system.

 

If you have a moment and could take a look, here's my post:

 

http://www.oscommerce.com/forums/index.php?act=ST&f=22&t=134076

 

 

Again, thank you so much, you've both been a real help.

 

 

best,

 

Brian

 

 

 

Hi Brian, (and Carine)

 

I installed the "Must Select" contribution following Carine's revised documentation and everything works like a dream..... :thumbsup:

 

You will just need to be very carefull on replacing the code exactly as Carine has detailed in the contribution. Look at your code and her changes, then look at them again to make sure you are doing them correctly.

 

I'll try here to walk you through how I created the "must select" option.

 

1. Go to Administration->Catalog->Product Attributes

 

You'll see three areas to work with

 

Top Left - "Product Options"

Top Right - "Option Values"

Bottom Left - "Products Attributes"

 

2. You'll be working in the Top Right "Option Values" area only

 

3. At the bottom of the "Option Values" you'll see a drop down list of your Product options.  To the right of the drop down list will be the language text boxes, then to the right of those there is an "insert" button.

 

4. Also notice the "number" to the left of the drop down. That will be the special number assigned to the "must select" Option you be creating.

 

5. It doesn't matter which Product Option Name that you create the "must select" option under. I used the Color option choice cause it was just there. Fill in the english (en: text box) with something like "- Please Select -".  Then make note of the number (mine was 15) and click on the Insert button. You now have the "must select" value in the system and can now add that option to any of your product Attributes at the bottom left "Product Attributes".

 

6. Make sure to change the default "must select" value of 9 in the contribution code to your particular number you got back in step 5.

 

7. I also added a sort in my attribute drop down to sort alphabetically so that my text "- Please Select -" would always sort to the top.

 

Around line 147

Hopefully this will help out. Once again, backup your files, make the changes carefully and you'll be good to go.

 

HTH

Tom

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...