function cw_special_offer_check($bonusid)
{
    global $tables;
    $pid = cw_query_first_cell("SELECT pid FROM {$tables['bonuses']} WHERE bonusid='{$bonusid}'");
    if ($pid > 0) {
        $logic = 'AND';
    } elseif (defined('PS_COND_LOGIC')) {
        $logic = PS_COND_LOGIC;
    } else {
        $logic = 'AND';
    }
    $check_func = array('E', 'D', 'T', 'W', 'Z', 'P', 'M', 'C');
    $result = true;
    foreach ($check_func as $func) {
        $check[$func] = call_user_func('cw_check_condition_' . $func, $bonusid, $logic == 'AND');
        $result &= $check[$func];
        if (!$result) {
            break;
        }
    }
    if ($_GET["showmedebug"] == 'Y' && ($pid == 0 || $_GET['all'] == 'Y')) {
        x_load("debug");
        global $affected_product_ids, $_affected_product_ids;
        echo __FILE__, ': bonusID, Conditions check result, Already used products, could be used with this bonus if it pass';
        cw_print_r($bonusid, $check, $affected_product_ids, $_affected_product_ids);
    }
    return $result;
}
    die("Access denied");
}
if (empty($addons["Promotion_Suite"])) {
    return;
}
if ($config['Promotion_Suite']['display_offers_cat'] != 'Y' && $config['Promotion_Suite']['display_offers_product'] != 'Y') {
    return;
}
include_once $xcart_dir . '/addons/Promotion_Suite/user_bonuses.php';
$bonuses = $user_bonuses;
if ($_GET['showmedebug'] == 'Y') {
    x_load("debug");
    $zones = cw_get_customer_zones_avail($userinfo, "");
    echo 'Promotion Suite addon ', PS_VERSION, " \n<br />";
    echo __FILE__, ' : Customer $zones, List of appropriated $bonuses before zones and categories filter';
    cw_print_r($zones, $bonuses);
}
/*
	For current category show first offer, where this category mentioned in conditions. If there are no such offers, then show first offer.
*/
if (!empty($cat) && !empty($bonuses) && empty($productid)) {
    if ($config['Promotion_Suite']['display_offers_cat'] != 'Y') {
        return;
    }
    $featured = array();
    $pos = cw_query_first("SELECT lpos, rpos FROM {$tables['categories']} WHERE categoryid='{$cat}'");
    $lpos = $pos['lpos'];
    $rpos = $pos['rpos'];
    $all_parents = cw_query_column("SELECT categoryid FROM {$tables['categories']} WHERE {$lpos} BETWEEN lpos AND rpos");
    if ($config['Promotion_Suite']['also_look_in_subcategories'] == 'Y') {
        $all_children = cw_query_column("SELECT categoryid FROM {$tables['categories']} WHERE lpos BETWEEN {$lpos} AND {$rpos}");