ok, i have searched a bit in this thread for this bug, and i did not see it. if i missed it, and i am duplicating a post, i apologize in advance. i suppose in the grand scheme of things, this bug is minor, but, a bug is still a bug.
if an admin enters a coupon code for an order, the coupon code does not get populated in the orders table. and without the field, the couponpopupWindow will NOT properly display on the customers side (or the admin side). the easiest fix i have found without changing much of the logic, starts at line 465. below is the original section of code along with my proposed fix to it.
PHP Code:
case 'ot_coupon':
// Default to using the title from the module
$coupon = rtrim($order_total['title'], ': ');
$order_total['title'] = $GLOBALS[$order_total['code']]->title;
// Look for correctly formated title
preg_match('/([^:]+):([^:]+)/', $coupon, $matches);
if(count($matches) > 2) {
$order_total['title'] = trim($matches[1]);
$coupon = $matches[2];
}
$cc_id = $db->Execute(
'SELECT coupon_id FROM `' . TABLE_COUPONS . '` ' .
'WHERE coupon_code=\'' . trim($coupon) . '\''
);
unset($matches, $coupon);
if(!$cc_id->EOF) $_SESSION['cc_id'] = $cc_id->fields['coupon_id'];
else {
$messageStack->add_session(WARNING_ORDER_COUPON_BAD, 'warning');
$order_total['title'] = '';
$order_total['value'] = 0;
}
unset($cc_id);
// proposed fix:
case 'ot_coupon':
// Default to using the title from the module
$coupon = rtrim($order_total['title'], ': ');
$order_total['title'] = $GLOBALS[$order_total['code']]->title;
// Look for correctly formated title
preg_match('/([^:]+):([^:]+)/', $coupon, $matches);
if(count($matches) > 2) {
$order_total['title'] = trim($matches[1]);
$coupon = $matches[2];
}
$cc_id = $db->Execute(
'SELECT coupon_id, coupon_code FROM `' . TABLE_COUPONS . '` ' .
'WHERE coupon_code=\'' . trim($coupon) . '\''
);
unset($matches, $coupon);
if(!$cc_id->EOF) {
$_SESSION['cc_id'] = $cc_id->fields['coupon_id'];
$sql_data_array['coupon_code'] = $cc_id->fields['coupon_code'];
zen_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = \'' . (int)$oID . '\'');
unset($sql_data_array);
$order_updated = true;
} else {
$messageStack->add_session(WARNING_ORDER_COUPON_BAD, 'warning');
$order_total['title'] = '';
$order_total['value'] = 0;
}
unset($cc_id);
Bookmarks