Note: This article discusses a known bug in Zen Cart that is present in all versions up to and including version 1.3.9g. Hopefully after reading this, the Zen Cart team will implement this simple fix.
Today a client was trying to re-enable one of his old coupon codes that had expired by simply changing the start and finish dates. You’d be astonished to know this isn’t possible without deleting and recreating the coupon or by copying it and then using the copy. Basically, extra steps that a store owner shouldn’t have to do.
So, I did a quick search of the Zen-Cart.com forum and found this thread from 2007 explaining the steps above. http://www.zen-cart.com/forum/showthread.php?p=386571#post386571. Wow, this thread is from 2007 and the bug still hasn’t been fixed? So I looked into it and found it can be resolved with a single line of code. Took less time to fix than to perform the “recommended” rename/copy workaround.
Open admin/coupon_admin.php and find:
$sql_data_array = array('coupon_code' => zen_db_prepare_input($_POST['coupon_code']), 'coupon_amount' => zen_db_prepare_input($_POST['coupon_amount']), 'coupon_type' => zen_db_prepare_input($coupon_type), 'uses_per_coupon' => zen_db_prepare_input((int)$_POST['coupon_uses_coupon']), 'uses_per_user' => zen_db_prepare_input((int)$_POST['coupon_uses_user']), 'coupon_minimum_order' => zen_db_prepare_input((float)$_POST['coupon_min_order']), 'restrict_to_products' => zen_db_prepare_input($_POST['coupon_products']), 'restrict_to_categories' => zen_db_prepare_input($_POST['coupon_categories']), 'coupon_start_date' => $_POST['coupon_startdate'], 'coupon_expire_date' => $_POST['coupon_finishdate'], 'date_created' => 'now()', 'date_modified' => 'now()', 'coupon_zone_restriction' => $_POST['coupon_zone_restriction']);
if ( (date('Y-m-d',time()) >= $_POST['coupon_startdate']) && ( (date('Y-m-d',time()) < $_POST['coupon_finishdate']) || !isset($_POST['coupon_finishdate']) ) $sql_data_array['coupon_active'] = 'Y';
I love Zen Cart, but seriously, something like this should have been fixed a lot sooner…