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;
}
*/
// bonuses were already once extracted earlier in this script (not in session)
if (!empty($user_bonuses)) {
    return true;
}
// $user_bonuses is empty, try to find it in session
x_session_register('user_bonuses');
x_session_register('user_bonuses_logged_userid');
// Do not update bonuses for current user if
// - it is already stored in session
// - AND stored for current logged_userid
// - AND update is not forced by config
if (!empty($user_bonuses) && $logged_userid == $user_bonuses_logged_userid && !PS_FORCE_USER_BONUSES) {
    return true;
}
x_load('cart');
if (empty($logged_userid) && $config["General"]["apply_default_country"] == "Y") {
    # Use the default address
    $userinfo["b_country"] = $userinfo["s_country"] = $config["General"]["default_country"];
    $userinfo["b_state"] = $userinfo["s_state"] = $config["General"]["default_state"];
    $userinfo["b_zipcode"] = $userinfo["s_zipcode"] = $config["General"]["default_zipcode"];
    $userinfo["b_city"] = $userinfo["s_city"] = $config["General"]["default_city"];
    $userinfo["b_countryname"] = $userinfo["s_countryname"] = cw_get_country($userinfo["s_country"]);
    $userinfo["b_statename"] = $userinfo["s_statename"] = cw_get_state($userinfo["s_state"], $userinfo["s_country"]);
}
if (!empty($logged_userid)) {
    $userinfo = cw_userinfo($logged_userid, $current_area);
}
$where_statement = '';
$join_statement = '';
# Multidomain addon integration
<?php

// CartWorks.com - Promotion Suite
if (!defined('XCART_START')) {
    header("Location: ../../");
    die("Access denied");
}
if (empty($addons["Promotion_Suite"])) {
    return;
}
x_load('cart', 'shipping', 'product', 'user');
if (!empty($logged_userid)) {
    $userinfo = cw_userinfo($logged_userid, $current_area, false, false, "H");
}
if (!$cw_is_cart_empty && !in_array($mode, array("wishlist", "wl2cart"))) {
    # array of bonuses and supplies which are applicable to the cart
    # $special_offers_apply = array(
    #	"supply" = array (
    #		[bonusid.subindex] = array (
    #			[bonus_type] = <scalar or array data>
    #			[bonus_type] = <scalar or array data>
    #			...
    #		...
    #		)
    #	"free_shipping" = array (
    #		"type" = N|Y|C|S
    #		"products" = array (
    #			[product_id] = <quantity>
    #			...
    #       "method" = array (<shippingid>)
    #		)
// CartWorks.com - Promotion Suite
if (!defined('XCART_START')) {
    header("Location: ../../");
    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'];
}
if (empty($addons["Promotion_Suite"])) {
    return;
}
// This setting was cut-off from the new version.
// Show recently viewed products among all visitors - quite useless. The feature was not demanded
if ($config['Promotion_Suite']['recently_viewed_enable'] != 'Y') {
    return;
}
if (empty($cat)) {
    if (!empty($product_added)) {
        $productid = $product_added;
    }
    if (!empty($productid)) {
        $cat_ps = cw_query_first_cell("SELECT categoryid FROM {$tables['products_categories']} WHERE main='Y' AND productid='{$productid}'");
    }
} else {
    $cat_ps = $cat;
}
if (!empty($cat_ps)) {
    x_load('product');
    $recent_pids = cw_query_column("select s.id FROM xcart_stats_shop s, xcart_products_categories c WHERE s.action='V' AND s.id=c.productid AND c.categoryid='{$cat_ps}' AND s.id!='{$productid}' order by s.date desc limit " . $config['Promotion_Suite']['recently_viewed_items'] * 3);
    $recent_pids = array_slice(array_unique($recent_pids), 0, $config['Promotion_Suite']['recently_viewed_items']);
    $pids_query['where'][] = $tables['products'] . ".productid IN ('" . implode($recent_pids, "','") . "')";
    if (!empty($recent_pids)) {
        $recent_products = cw_search_products($pids_query, $userinfo['membershipid']);
    }
    $smarty->assign('recent_products', $recent_products);
    unset($recent_products, $recent_pids, $pids_query);
}
// CartWorks.com - Promotion Suite
Exemple #6
0
# Read Modules and put in into $active_modules
#
$import_specification = array();
$active_modules = func_data_cache_get("modules");
if (!is_array($active_modules)) {
    $active_modules = array();
}
$active_modules["Simple_Mode"] = true;
$addons = array();
$body_onload = "";
$tbl_demo_data = $tbl_keys = array();
$css_files = array();
$container_classes = array();
$predefined_setup_images = array();
$image_caches = array();
x_load('image');
if ($active_modules) {
    foreach ($active_modules as $active_module => $tmp) {
        if (file_exists($xcart_dir . "/modules/" . $active_module . "/config.php")) {
            include $xcart_dir . "/modules/" . $active_module . "/config.php";
        }
        if (file_exists($xcart_dir . "/modules/" . $active_module . "/func.php")) {
            include $xcart_dir . "/modules/" . $active_module . "/func.php";
        }
    }
}
$smarty->assign_by_ref("active_modules", $active_modules);
$mail_smarty->assign_by_ref("active_modules", $active_modules);
$config['setup_images'] = func_data_cache_get("setup_images");
foreach ($config['available_images'] as $k => $v) {
    if (isset($config['setup_images'][$k])) {
<?php

define('SKIP_COOKIE_CHECK', true);
require_once './auth.php';
include './payment/includes/autoload.php';
x_load('order');
$posted_data = file_get_contents("php://input");
if (empty($posted_data)) {
    // empty request
    exit;
} else {
    $payment_cc_data = func_query_first("SELECT * FROM {$sql_tbl['ccprocessors']} WHERE processor='checkoutapipayment.php'");
    $Api = CheckoutApi_Api::getApi(array('mode' => $payment_cc_data['param01']));
    $objectCharge = $Api->chargeToObj($posted_data);
    if ($objectCharge->isValid()) {
        /*
         * Need to get track id
         */
        $order_id = $objectCharge->getTrackId();
        if ($objectCharge->getCaptured()) {
            $advinfo = 'Your payment has been successfully completed';
            func_change_order_status($order_id, 'C', $advinfo);
            // completed status?
        } elseif ($objectCharge->getRefunded()) {
            $advinfo = 'Your payment has been refunded';
            func_change_order_status($order_id, 'D', $advinfo);
            // declined status?
        } elseif (!$objectCharge->getAuthorised()) {
            $advinfo[] = 'Your order has been cancelled';
            func_change_order_status($order_id, 'D', $advinfo);
            // cancelled status?