If this is your first visit, check our documentation. To post, register or login.

Must Select Attributes

Started by kaddie on 11 Apr 2010, 8:54 PM · Views: 2,514

Results 1 to 9 of 9
11 Apr 2010, 8:54 PM
#1
kaddie avatar

kaddie

New Zenner

Join Date:
Feb 2009
Location:
In the Woods of Texas
Posts:
63
Plugin Contributions:
0

Post #1 by kaddie

I have read about adding a Must Select Option in several threads. However, when we moved our products from OSC to ZC it did not copy over the Must Select Option because it was coded in as a mod. The mod is below:


Installation Instructions

The product attributes must select OSC mod.

In catalog/product_info.php page:

FIND:
if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
$products_name = $product_info['products_name'];
}
?>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

REPLACE WITH:
if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
$products_name = $product_info['products_name'];
}
//BoF CB Show must error messages include any must select msg
if ($messageStack->size('product_info') > 0) {
?>
<tr>
<td><?php echo $messageStack->output('product_info'); ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>

<?php } // EoF CB ?>
  <tr>
    <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

In catalog/includes/application_top.php :

FIND:
// initialize the message stack for output messages
require(DIR_WS_CLASSES . 'message_stack.php');
$messageStack = new messageStack;

ADD BELOW:
//BoF CB Enforce option selection
if (isset($HTTP_GET_VARS['mustselect'])){
$error = true;
switch ($HTTP_GET_VARS['mustselect']) {
case 'product_info' :
$messageStack->add('product_info','You must select a value from the options dropdown');
break;
case 'product_listing' :
$messageStack->add('product_listing','You must select a value from the options dropdown for the products you are adding to cart');
break;
}
}
//EoF CB

In catalog/includes/application_top.php:

  1. add 'mustselect' as a parameter to ignore

FIND
if (DISPLAY_CART == 'true') {
$goto = FILENAME_SHOPPING_CART;
$parameters = array('action', 'cPath', 'products_id', 'pid');
} else {
$goto = basename($PHP_SELF);
if ($HTTP_GET_VARS['action'] == 'buy_now') {
$parameters = array('action', 'pid', 'products_id');
} else {
$parameters = array('action', 'pid');
}
}

REPLACE BY
// BOF CB add 'mustselect' as a parameter to ignore
if (DISPLAY_CART == 'true') {
$goto = FILENAME_SHOPPING_CART;
$parameters = array('action', 'cPath', 'products_id', 'pid','mustselect');
} else {
$goto = basename($PHP_SELF);
if ($HTTP_GET_VARS['action'] == 'buy_now') {
$parameters = array('action', 'pid', 'products_id','mustselect');
} else {
$parameters = array('action', 'pid','mustselect');
}
}
// EOF CB add 'mustselect' as a parameter to ignore

  1. Add the checking code

FIND:
case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

ADD BELOW: MAKE SURE TO CHANGE THE VALUE 9 TO THE IDENTIFIER FOR THE OPTION VALUE THAT YOU HAVE SETUP IN YOUR SHOP
TO PROMPT THE CUSTOMER TO MAKE A SELECTION.
IF YOU HAVE MULTIPLE VALUES COMMENTOUT THE SINGLE CHECK, AND USE SYNTAX THAT IS IN COMMENTS FOR MULTIPLES:

                           //BoF CB Enforce attribute selection
                           if (is_array($HTTP_POST_VARS['id']) ) {
                             $messageStack->reset();                                  
                             while (list($option, $value) = each($HTTP_POST_VARS['id'])) {
                              //if (($value == 9) or ($value == 10) or ($value == 999) ) {
                              // 9 is the value for "-select-"
                              if ($value == 9) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'] . '&mustselect=product_info'));
                                 break;
                              }
                             }
                           } elseif (tep_has_product_attributes($HTTP_POST_VARS['products_id'])) {
                               tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_POST_VARS['products_id']));
                               break;
                           } 
                           //EoF CB

Converting this mod code from OSC to ZC would be the way to go for me and everyone else. How do I convert this mod (Must Select) to a ZC mod?

The Must Select option should be coded in ZC from the get go anyways!

However, I have 3000 products with almost all having attribute options. Adding a Must Select Option would be extremely tedious and long going. If I could use the mod above, I would not need to add a Must Select Option because the mod code does it for you.

Any help appreciated!

Kaddie

11 Apr 2010, 10:43 PM
#2
coolcarpartsonline avatar

coolcarpartsonline

Totally Zenned

Join Date:
Feb 2008
Posts:
1,386
Plugin Contributions:
0

Post #2 by coolcarpartsonline

Zen Cart has this built in under the attribute controller. You can choose a value as a display only, which means customers can't add product to cart unless they choose a different option. Usually this setup as Select Option Below... or something of that nature.

3000 products is nothing. If you have the same options for all your products or for all categories you can configure your options to one product and then copy it to the whole store or category.

12 Apr 2010, 2:10 AM
#3
kaddie avatar

kaddie

New Zenner

Join Date:
Feb 2009
Location:
In the Woods of Texas
Posts:
63
Plugin Contributions:
0

Post #3 by kaddie

There is different attributes for every product. So, how do I setup a Please Select Option value and copy it to all product attributes without overwriting all attributes for a particular product?

Anyway, can someone else answer my post above about the osc mod converting to zc.

Thanks,
Kaddie

12 Apr 2010, 2:24 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #4 by ajeh

If you had, for example, Option Name Colors ...

and wanted to add to ALL Products that had Option Name Colors the Option Value for it of:
None

You could BACKUP your database first ... then go to the Catalog ... Option Name Manager ... and in the bottom of the page is a feature to copy 1 Option Name/Option Value to any Product with an Option Name ...

So you could pick:
Option Name: Color
Option Value: None

And then select COLOR for where to copy it to and leave Category blank to copy to ALL Products that use the Option Name Color ... and then set to:
Ignore existing attributes and add only new attributes

Now, all Option Name Color will get Option Value None set ...

Next, you can look to see what the values are for this in the products_attributes table and set the settings via phpMyAdmin for making these all set to:
Default: YES
Display Only: YES
Sort Order: 0 (I use 0 on the Sort Order for the Display Only/Default Attributes)

This would help speed up the updates to the Attributes on the Products ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 Apr 2010, 2:43 AM
#5
kaddie avatar

kaddie

New Zenner

Join Date:
Feb 2009
Location:
In the Woods of Texas
Posts:
63
Plugin Contributions:
0

Post #5 by kaddie

I simply do not understand your instructions. I am trying to make since of it all. :blush:

12 Apr 2010, 3:09 AM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #6 by ajeh

You have Option Names and Option Values on your Products ...

You want to have a Default Display Only Option Value on each of your Option Names to force the customer to select an Option Value by "choice" and not by "accident" ...

In order to do this, you can set an Option Value as:
Default: YES
Display Only: Yes

What that does is force the customer to make a "real" choice of one of the Option Values without "accidentally" selecting a "wrong" or "incorrect" Option Value by "accident" ...

As all of your Products already exist with Option Names and their Option Values ... you need to add this additional Option Value to each Option Name ...

So, you would add your "default display only" Option Value to each Product ...

Trying to do this 1 by 1 can be a headache ...

A faster method is to create the Option Value for each Option Name that you want to use as the "default display only" Option Value ... and there is a method to do this in the Option Value Manager ...

Before running it, you would want to make a backup of your database in case you goober things up ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 Apr 2010, 3:20 AM
#7
kaddie avatar

kaddie

New Zenner

Join Date:
Feb 2009
Location:
In the Woods of Texas
Posts:
63
Plugin Contributions:
0

Post #7 by kaddie

So, I create "Must Select Option" value for each Option Name? I did not know I could have duplicate "Must Select Option" values.

So, I would create a value "Select Option for each of these Value Names?

For example:

Size
Color
Type
Fabric Print
and so on....

It seems it would be much simpler to convert the osc mod to a zc mod.

Thanks for help,
Kaddie

12 Apr 2010, 3:24 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #8 by ajeh

You need a separate one for each Option Name ...

Size
Pick a Size Below

Color
Pick your favorite color

Type
What type do you want

Fabric Print
Which Fabric Print

You can call them whatever you want them to read that makes sense for the Option Name ... or you can make them all the same text ...

In the Option Values on the Attributes Controller you will see the Option Name next to the Option Value in the list ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

9 Sep 2011, 9:35 PM
#9
ryguylivinlife avatar

ryguylivinlife

New Zenner

Join Date:
Aug 2011
Posts:
6
Plugin Contributions:
0

Post #9 by ryguylivinlife

Thanks guys, took me a while to get a hang of it. But I got it to where radio button is already selected at first and customer has to rearrange it. That's better than the customer forgetting to choose the radio button in the first place. 0_0