It might have been covered before but i did not find it.
v 1.3.8a
In Catalog->Special menu, there is an option to select the ID without going to the drop down menu
The selection is not checked againt Vouchers Certificate, as made in the drop down menu filter
It not checked against "none cartable" products either
After next segment of code ended around line 150
if ($skip_special == false) {
$sql = "select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$_POST['pre_add_products_id'] . "'";
$check_special = $db->Execute($sql);
if ($check_special->RecordCount() > 0) {
$skip_special = true;
$messageStack->add_session(WARNING_SPECIALS_PRE_ADD_DUPLICATE, 'caution');
}
}
I added this code as validation
if ($skip_special == false) {
$check_special = $db->Execute("select p.products_id
from " . TABLE_PRODUCTS . " p
where p.products_model rlike '" . "GIFT" . "' and
p.products_id ='" . (int)$_POST['pre_add_products_id'] . "'" );
if ($check_special->RecordCount() > 0) {
$skip_special = true;
$messageStack->add_session(WARNING_SPECIALS_PRE_ADD_BAD_PRODUCTS_ID, 'caution');
}
}
if ($skip_special == false) {
// do not include things that cannot go in the cart
$check_special = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCT_TYPES . " pt on p.products_type= pt.type_id
where pt.allow_add_to_cart = 'N' and
p.products_id ='" . (int)$_POST['pre_add_products_id'] . "'" );
if ($check_special->RecordCount() > 0) {
$skip_special = true;
$messageStack->add_session(WARNING_SPECIALS_PRE_ADD_BAD_PRODUCTS_ID, 'caution');
}
}
Second, upon entering pID, if you click cancel, the products remains in the data base special with price zero.
To avoid that i changed the whole logic behind this procedure.
Basically, it adds a record into the special data base, to be processed by the action=edit portion of code
What I did was to disable adding the record, jumping into the action=insert code.
So rather than using the products array, i used the pID value instead.
It requires PID name and price, plus the form values passed then to the action=insert code before body.
I added a 'GET['select']' variable to differentiate standard insert from this.
It is working so far
I apologize for my poor php skills but what I did follows
coomented out next section and modified zen_redirect statement:
// add empty special
/*
$specials_date_available = ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start']));
$expires_date = ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']));
$products_id = zen_db_prepare_input($_POST['pre_add_products_id']);
$db->Execute("insert into " . TABLE_SPECIALS . "
(products_id, specials_new_products_price, specials_date_added, expires_date, status, specials_date_available)
values ('" . (int)$products_id . "',
'" . zen_db_input($specials_price) . "',
now(),
'" . zen_db_input($expires_date) . "', '0', '" . zen_db_input($specials_date_available) . "')");
$new_special = $db->Execute("select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$products_id . "'"); */
// $messageStack->add_session(SUCCESS_SPECIALS_PRE_ADD, 'success');
// zen_redirect(zen_href_link(FILENAME_SPECIALS, 'action=edit' . '&sID=' . $new_special->fields['specials_id']));
zen_redirect(zen_href_link(FILENAME_SPECIALS, 'action=new&select=1' . '&sID=' . $_POST['pre_add_products_id']));
break;
then
after
<tr> <form name="new_special" <?php
echo 'action="' . zen_href_link(FILENAME_SPECIALS, zen_get_all_get_params(array('action', 'info', 'sID')) . 'action=' . $form_action . "&go_back=" . $_GET['go_back'] , 'NONSSL') . '"';
?> method="post"><?php if ($form_action == 'update') echo zen_draw_hidden_field('specials_id', $_GET['sID']); ?>
<td><br><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo TEXT_SPECIALS_PRODUCT?> </td>
<td class="main"><?php
i added/modified next piece of code
if ( $_GET['select'] == '1' ) {
$again = $db->Execute("select pd.products_name, p.products_price
from ". TABLE_PRODUCTS_DESCRIPTION . " pd ," . TABLE_PRODUCTS . " p
where p.products_id = pd.products_id and
p.products_id = '". $_GET['sID'] . "'");
echo $again->fields['products_name'] . '['.$again->fields['products_price'] .']';
echo zen_draw_hidden_field('products_price',zen_get_products_base_price($_GET['sID']));
echo zen_draw_hidden_field('products_id',$_GET['sID']);
}
else
echo (isset($sInfo->products_name)) ? $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>' : zen_draw_products_pull_down('products_id', 'size="5" style="font-size:10px"', $specials_array, true, $_GET['add_products_id'], true); echo zen_draw_hidden_field('products_price', (isset($sInfo->products_price) ? $sInfo->products_price : ''));
I modified the cancel buttom after
<td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
<td class="main" align="right" valign="top"><br><?php
this way ( to prevent a non stardard return screen)
echo (($form_action == 'insert') ? zen_image_submit('button_insert.gif', IMAGE_INSERT) :
zen_image_submit('button_update.gif', IMAGE_UPDATE)) . '
<a href="' . ($_GET['go_back'] == 'ON' ?
zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['add_products_id']) :
zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] .
((isset($_GET['sID']) and $_GET['sID'] != '' and $_GET['select'] != '1') ? '&sID=' . $_GET['sID'] : ''))) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?>
</td>
around line 29 in the
break;
case 'insert':
code, i modified next IF line
if ($_POST['products_id'] < 1 && $_GET['select'] != '1' ) {
$messageStack->add_session(ERROR_NOTHING_SELECTED, 'caution');
} else {
and the item gets added correctly to the specials DB



