コード例 #1
0
    die("Access denied");
}
if (empty($addons['Promotion_Suite'])) {
    return false;
}
/*
Script updates $user_bonuses array with all active bonuses applicable for current user taking into account his zone.
Depending on PS_FORCE_USER_BONUSES may use session or extract it every time.
*/
// 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"]);
コード例 #2
0
 #	"discount" = array (
 #		"type" = N|Y|S
 #		"discount" = <discount>
 #		"discount_type" = "percent"|"absolute"
 #		"max_discount" = <discount_amount>
 #		"products" = array (
 #			[product_id] = array (
 #				"discount" = <discount>
 #				"discount_type" = "percent"|"absolute"
 #				"max_discount" = <discount_amount>
 #				)
 #			...
 #		)
 #	)
 # )
 x_session_register("special_offers_apply");
 $special_offers_apply = array();
 $special_offers_apply['free_shipping'] = false;
 $join_statement = $where_statement = '';
 if ($domain_info) {
     $join_statement = " LEFT JOIN {$tables['domain_bonuses']} ON {$tables['domain_bonuses']}.bonusid = b.bonusid AND {$tables['domain_bonuses']}.domainid = {$domain_info['domainid']}";
     $where_statement = " AND {$tables['domain_bonuses']}.bonusid IS NOT NULL";
 }
 $bonuses = cw_query("SELECT b.bonusid, b.exclusive, b.repeat, b.pid FROM {$tables['bonuses']} b {$join_statement} WHERE b.bonus_active='Y' AND b.start_date<UNIX_TIMESTAMP() and (b.end_date+86400)>UNIX_TIMESTAMP() {$where_statement} ORDER BY priority");
 # Delete all free added products
 foreach ($cart['products'] as $kk => $vv) {
     if ($vv["special_offer"]["free_product"] == 'Y') {
         cw_delete_from_cart($cart, $vv['cartid']);
     } else {
         unset($cart['products'][$kk]['special_offer']);
     }