function check_coupons($auto_apply = true) { check_add_coupons($auto_apply, "", $coupon_error); }
if (isset($site_id)) { $sql .= "("; } $sql .= $table_prefix . "coupons c"; if (isset($site_id)) { $sql .= " LEFT JOIN " . $table_prefix . "coupons_sites s ON s.coupon_id=c.coupon_id)"; } $sql .= " WHERE c.coupon_code=" . $db->tosql($coupon_code, TEXT); if (isset($site_id)) { $sql .= " AND (c.sites_all=1 OR s.site_id=" . $db->tosql($site_id, INTEGER, true, false) . ")"; } else { $sql .= " AND c.sites_all=1 "; } $db->query($sql); if ($db->next_record()) { check_add_coupons(true, $coupon_code, $coupon_errors); } else { $coupon_errors = COUPON_NOT_FOUND_MSG; } } } elseif ($operation == "rm_coupon") { $coupon_id = get_param("coupon_id"); remove_coupon($coupon_id); } else { // check coupons without adding new coupons check_coupons(false); } // get shopping cart and order coupons $shopping_cart = get_session("shopping_cart"); $coupons = get_session("session_coupons"); $quantities_discounts = array();