Perhaps best for someone to package and put in dowmloads section and get all the glory , just too busy at the moment to do it, but thought i would share a little mod to enable you to restrict a coupon from all items on special.
Its pretty basic in how it works, just two buttons added to the coupon restrictions page, an add and remove button.
The add button will search all products currently on special and will list them in the products retricted area, for that coupon for you.
the remove button removes all restricted products, that are on special for that coupon, from the restricted products.
File to change is /admin/coupon_restrict.php
The above is a core file so care to be taken, as always backup before performing any mod.
around line 36:
After:
Code:
where restrict_id = '" . $_GET['info'] . "'");
}
}
add:
Code:
if ($_GET['action']=='specials') {
$new_products_query = "select products_id from " . TABLE_SPECIALS . " where status = 1 and products_id not in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "')";
$new_products = $db->Execute($new_products_query);
while(!$new_products->EOF) {
// add all products from specials for each product not already defined in coupons_restrict
$db->Execute("insert into " . TABLE_COUPON_RESTRICT . " (coupon_id, product_id, coupon_restrict) values ('" . $_GET['cid'] . "', '" . $new_products->fields['products_id'] . "', 'Y')");
$new_products->MoveNext();
}
}
//remove specials
if ($_GET['action']=='remove_specials') {
// to delete existing products from coupon code that are selected as specials coupon_code that are already in the table
$new_products_query = "select products_id from " . TABLE_SPECIALS . " where status = 1 and products_id in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "')";
$new_products = $db->Execute($new_products_query);
// nothing to be done
if ($new_products->RecordCount() == 0) {
$messageStack->add(ERROR_DISCOUNT_COUPON_DEFINED_CATEGORY . ' ' . $_POST['cPath'], 'caution');
}
while(!$new_products->EOF) {
// product needs to be deleted
$db->Execute("delete from " . TABLE_COUPON_RESTRICT . " WHERE coupon_id = '" . $_GET['cid'] . "' and product_id = '" . $new_products->fields['products_id'] . "'");
$new_products->MoveNext();
}
}
around line 387
After:
Code:
<!-- body_text_eof //-->
</tr>
</table>
add:
Code:
<form name="restrict_specials" method="post" action="<?php echo zen_href_link('coupon_restrict.php', zen_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=specials&info=' . $cInfo->restrict_id, 'NONSSL'); ?>"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
<input type="submit" name="add" value="Add Specials">
</form>
<form name="remove_specials" method="post" action="<?php echo zen_href_link('coupon_restrict.php', zen_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=remove_specials&info=' . $cInfo->restrict_id, 'NONSSL'); ?>"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
<input type="submit" name="add" value="Remove Specials">
</form>
and that's it.
Bookmarks