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