beachkitty85 Posted June 22, 2007 Posted June 22, 2007 I am trying to add $messagestack errors based on the product quantity and (at a later stage) the attribute option value. This is so I can limit the quantity based on which attribute is selected. I've duplicated the $messageStack code from create_account.php, but I just can't get it to work. I've added this to the page top: $process = false; if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { $process = true; $quantity = tep_db_prepare_input($HTTP_POST_VARS['quantity']); if (strlen($quantity) > 1) { $error = true; $messageStack->add('cart_quantity', 'Error!'); } if ($error == false) { $sql_data_array = array('qty' => $quantity); $qty = $quantity; tep_session_register('qty'); } } and changed the form to this: (added a hidden field just like in create_account.php) <?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data" onsubmit="return check_form(cart_quantity);"') . tep_draw_hidden_field('action', 'process'); ?> And this where the error shoud display: <?php if ($messageStack->size('cart_quantity') > 0) { ?> <table class="error"> <tr> <td><?php echo $messageStack->output('cart_quantity'); ?></td> </tr> </table> <?php } ?> Could someone please help out? Also, if anyone knows how I could implement validation based on attribute option values, please let me know.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.