コード例 #1
0
function cw_ps_get_featured_offer()
{
    global $tables, $domain_attributes, $addons, $smarty;
    $fields = $from_tbls = $query_joins = $where = $groupbys = $having = $orderbys = array();
    $fields = array("{$tables['ps_offers']}.offer_id", "{$tables['ps_offers']}.offer_id as id", 'title', 'description', 'enddate', 'priority', 'position');
    $offer = array();
    $from_tbls[] = 'ps_offers';
    if (isset($addons['multi_domains'])) {
        $conditions = cw_md_get_available_domains();
        if ($conditions !== false) {
            $query_joins['attributes_values'] = array('on' => "{$tables['ps_offers']}.offer_id = {$tables['attributes_values']}.item_id and {$tables['attributes_values']}.item_type = '" . PS_ATTR_ITEM_TYPE . "' and {$tables['attributes_values']}.attribute_id='" . $domain_attributes[PS_ATTR_ITEM_TYPE] . "' and {$tables['attributes_values']}.value in " . $conditions, 'is_inner' => 1);
        }
    }
    $query_joins['ps_bonuses'] = array('on' => "{$tables['ps_offers']}.offer_id = {$tables['ps_bonuses']}.offer_id", 'is_inner' => 1);
    $query_joins['ps_conditions'] = array('on' => "{$tables['ps_offers']}.offer_id = {$tables['ps_conditions']}.offer_id", 'is_inner' => 1);
    $where[] = "{$tables['ps_offers']}.enddate >= '" . cw_core_get_time() . "'";
    $having[] = "COUNT({$tables['ps_bonuses']}.bonus_id) > 0";
    $having[] = "COUNT({$tables['ps_conditions']}.cond_id) > 0";
    $groupbys[] = "{$tables['ps_offers']}.offer_id";
    $orderbys[] = 'priority DESC';
    $orderbys[] = 'position';
    $_query_joins = $query_joins;
    $_where = $where;
    $_having = $having;
    $_groupbys = $groupbys;
    $_fields = $fields;
    global $customer_id, $user_info;
    $customer_zone = null;
    if (isset($customer_id) && !empty($customer_id)) {
        if (!isset($user_info) || empty($user_info)) {
            $user_info = cw_user_get_info($customer_id, 1);
        }
        //cw_user_get_info($customer_id, 256)
        //cw_user_get_addresses
        //cw_user_get_addresses_smarty
        //cw_user_get_default_address
        //if ($info_type & 256)
        //$zones = cw_call('cw_cart_get_zones', array('address' => $address, 'is_shipping' => 1));
        $customer_zone = cw_func_call('cw_cart_get_zone_ship', array('address' => $user_info['current_address'], 'type' => 'D'));
    }
    //let's try to find an offer with the required category defined in the offer's condition
    global $cat;
    if (isset($cat) && !empty($cat)) {
        $query_joins['ps_cond_details'] = array('on' => "{$tables['ps_offers']}.offer_id = {$tables['ps_cond_details']}.offer_id", 'is_inner' => 1);
        $where[] = "{$tables['ps_cond_details']}.object_type = '" . PS_OBJ_TYPE_CATS . "'";
        $where[] = "{$tables['ps_cond_details']}.object_id = '" . $cat . "'";
        $search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys);
        if (empty($customer_zone)) {
            $offer = cw_stripslashes(cw_query_first($search_query . ' LIMIT 1'));
        } else {
            $cat_offers = cw_stripslashes(cw_query_hash($search_query, 'offer_id', false));
            if (!empty($cat_offers)) {
                $fields = $from_tbls = $query_joins = $where = $groupbys = $having = $orderbys = array();
                $from_tbls[] = 'ps_cond_details';
                $fields[] = 'offer_id';
                $where[] = "({$tables['ps_cond_details']}.object_type = '" . PS_OBJ_TYPE_ZONES . "' AND {$tables['ps_cond_details']}.object_id != '{$customer_zone}')";
                $where[] = "{$tables['ps_cond_details']}.offer_id IN ('" . implode("', '", array_keys($cat_offers)) . "')";
                $search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys);
                $zone_offers = cw_stripslashes(cw_query_hash($search_query, 'offer_id', false));
                $suitable_offers = array_diff_key($cat_offers, $zone_offers);
                if (!empty($suitable_offers)) {
                    $offer = array_shift($suitable_offers);
                    unset($suitable_offers);
                }
            }
        }
    }
    //if there is no suitable offer in the store, let's take the first one
    if (empty($offer)) {
        $query_joins = $_query_joins;
        $where = $_where;
        $having = $_having;
        $groupbys = $_groupbys;
        $fields = $_fields;
        if (!empty($customer_zone)) {
            $query_joins['ps_cond_details'] = array('on' => "{$tables['ps_offers']}.offer_id = {$tables['ps_cond_details']}.offer_id");
            $where[] = "({$tables['ps_cond_details']}.object_type = '" . PS_OBJ_TYPE_ZONES . "' AND {$tables['ps_cond_details']}.object_id = '{$customer_zone}')";
            $search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys);
            $offer = cw_stripslashes(cw_query_first($search_query . ' LIMIT 1'));
            if (empty($offer)) {
                $where = $_where;
                $where[] = "({$tables['ps_cond_details']}.object_type != '" . PS_OBJ_TYPE_ZONES . "' OR {$tables['ps_cond_details']}.object_type IS NULL)";
                $search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys);
                $offer = cw_stripslashes(cw_query_first($search_query . ' LIMIT 1'));
            }
        } else {
            $search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys);
            $offer = cw_stripslashes(cw_query_first($search_query . ' LIMIT 1'));
        }
        unset($_query_joins, $_where, $_having, $_groupbys);
    }
    if (!empty($offer)) {
        $fields = $from_tbls = $query_joins = $where = $groupbys = $having = $orderbys = array();
        $fields[] = '*';
        $from_tbls[] = PS_IMG_TYPE;
        $where[] = "id = '{$offer['id']}'";
        $where[] = "avail = 1";
        $search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys);
        $offer_image_info = cw_query_first($search_query);
        if (!empty($offer_image_info) && is_array($offer_image_info)) {
            $offer['img'] = cw_image_info(PS_IMG_TYPE, $offer_image_info);
            $smarty->assign('ps_image_width', $offer['img']['image_x']);
        }
    }
    return $offer;
}
コード例 #2
0
function dod_details($generator_id)
{
    global $tables, $top_message, $smarty, $available_fields;
    if (empty($generator_id)) {
        dod_redirect();
    }
    $generator_id = (int) $generator_id;
    if ($_SERVER['REQUEST_METHOD'] != 'GET') {
        dod_redirect($generator_id);
    }
    $generator_data = cw_query_first('SELECT `' . implode('`, `', array_keys($available_fields)) . '` FROM ' . $tables['dod_generators'] . ' WHERE generator_id = \'' . $generator_id . '\'');
    if (empty($generator_data) || !is_array($generator_data)) {
        dod_redirect();
    }
    $smarty->assign('generator_data', cw_stripslashes($generator_data));
    // bonuses
    $sess_bonuses =& cw_session_register('_dod_bonus');
    $bonuses = dod_get_generator_bonuses($generator_id);
    if (!is_array($bonuses) || empty($bonuses)) {
        $bonuses = array();
    }
    if (!empty($sess_bonuses)) {
        if (is_array($sess_bonuses)) {
            $bonuses = array_merge($bonuses, $sess_bonuses);
            $smarty->assign('not_sav_bons', $sess_bonuses);
        }
        cw_session_unregister('_dod_bonus');
    }
    $smarty->assign('dod_bonus', $bonuses);
    $bonus_types = array_flip(array_keys($bonuses));
    $bonus_types = array_map(create_function('$elm', 'return 1;'), $bonus_types);
    if (empty($bonus_types)) {
        $bonus_types = array();
    }
    $sess_bonus_types =& cw_session_register('_dod_bonuses');
    if (!empty($sess_bonus_types)) {
        if (is_array($sess_bonus_types)) {
            $bonus_types = array_merge($bonus_types, $sess_bonus_types);
        }
        cw_session_unregister('_dod_bonuses');
    }
    $smarty->assign('dod_bonuses', $bonus_types);
    cw_load('attributes');
    $dod_attr = cw_call('cw_attributes_filter', array(array('addon' => '', 'item_type' => 'P')));
    $smarty->assign('dod_attr', $dod_attr);
    $smarty->assign('dod_coupons', dod_get_coupons());
    $smarty->assign('dod_mans', dod_get_manufacturers());
    global $js_tab;
    if (isset($js_tab)) {
        $smarty->assign('js_tab', (string) $js_tab);
    }
    global $app_catalogs, $target, $mode;
    $smarty->assign('dod_url_get_coupons', "{$app_catalogs['admin']}/index.php?target={$target}&mode={$mode}&action=coupons&generator_id={$generator_id}&js_tab=dod_generator_bonuses");
    $smarty->assign('dod_url_add_coupon', "{$app_catalogs['admin']}/index.php?target=coupons");
    //$smarty->assign('dod_url_add_zone', "$app_catalogs[admin]/index.php?target=shipping_zones&mode=add");
    //attributes
    global $attributes;
    global $edited_language;
    $attributes = cw_func_call('cw_attributes_get', array('item_id' => $generator_id, 'item_type' => dod_ATTR_ITEM_TYPE, 'prefilled' => $attributes));
    $smarty->assign('attributes', $attributes);
}
コード例 #3
0
function cw_doc_prepare_user_information($user_info, $current_information = array())
{
    if (!is_array($user_info['additional_info'])) {
        $user_info['additional_info'] = array();
    }
    $current_information = array_merge($current_information, $user_info['additional_info']);
    $current_information['membership_id'] = $user_info['membership_id'];
    $current_information['email'] = $user_info['email'];
    if (!is_array($user_info['main_address'])) {
        $user_info['main_address'] = array();
    }
    if (!is_array($current_information['main_address'])) {
        $current_information['main_address'] = array();
    }
    if (!is_array($user_info['current_address'])) {
        $user_info['current_address'] = array();
    }
    if (!is_array($current_information['main_address'])) {
        $current_information['main_address'] = array();
    }
    unset($user_info['main_address']['address_id']);
    unset($user_info['current_address']['address_id']);
    $current_information['main_address'] = array_merge($current_information['main_address'], $user_info['main_address']);
    if ($user_info['current_address']['same_as_main']) {
        $current_information['current_address'] = $current_information['main_address'];
        $current_information['current_address']['same_as_main'] = 1;
    } else {
        $current_information['current_address'] = array_merge($current_information['current_address'], $user_info['current_address']);
        $current_information['current_address']['same_as_main'] = true;
        foreach ($current_information['main_address'] as $k => $v) {
            if ($v != $current_information['current_address'][$k]) {
                $current_information['current_address']['same_as_main'] = false;
                break;
            }
        }
    }
    $current_information['main_address']['customer_id'] = 0;
    $current_information['current_address']['customer_id'] = 0;
    $current_information['usertype'] = $user_info['usertype'];
    $current_information['main_address'] = cw_user_process_address($current_information['main_address']);
    $current_information['current_address'] = cw_user_process_address($current_information['current_address']);
    return cw_stripslashes($current_information);
}
コード例 #4
0
                $insert['variant_id'] = $product_info['variant_id'];
                $insert['product_id'] = $product_info['product_id'];
                cw_warehouse_insert_avail($insert, true);
            }
        } else {
            $result['error'] = 1;
        }
        $ean_products[] = $result;
    }
    if (count($ean_products)) {
        $mode = 'result';
    } else {
        cw_header_location('index.php?target=ean_serials');
    }
}
if ($mode == 'result' && is_array($ean_products)) {
    $errors_arr = array('1' => cw_get_langvar_by_name('lbl_not_found'), '2' => cw_get_langvar_by_name('lbl_err_serial_already_exists'));
    foreach ($ean_products as $k => $v) {
        $ean_products[$k] = cw_stripslashes($v);
        $ean_products[$k]['product_info'] = cw_func_call('cw_product_get', array('id' => $v['product_info']['product_id'], 'user_account' => $user_account, 'info_type' => 0));
        $ean_products[$k]['error_descr'] = $errors_arr[$v['error']];
    }
    $smarty->assign('ean_products', $ean_products);
}
foreach ($settings_vars as $val) {
    $value = $ean_settings[$val] ? $ean_settings[$val] : $config['sn'][$val];
    $smarty->assign($val, $value);
}
$smarty->assign('mode', $mode);
$location[] = array(cw_get_langvar_by_name('lbl_add_serial_number'), '');
$smarty->assign('main', 'ean_serials');
コード例 #5
0
    if (isset($field_product)) {
        $page_get_params['field_product'] = $field_product;
        $page_get_params['field_product_id'] = $field_product_id;
        $page_get_params['field_amount'] = $field_amount;
    }
    $navigation['script_raw'] = cw_call('cw_core_get_html_page_url', array(array_merge($page_get_params, array('att' => $search_data['products'][$use_search_conditions]['attributes']))));
    //    $navigation['script'] = cw_call('cw_product_get_filter_replaced_url', array('product_filter'=>$product_filter, 'ns'=>$navigation['script_raw']));
    $navigation['script'] = cw_call('cw_clean_url_get_seo_url', array($navigation['script_raw']));
    if ($current_area == 'A') {
        $navigation['script'] = str_replace('index.php', 'admin/index.php', $navigation['script']);
    }
    // alexv - #30133 2nd+ product list page in pop up bug
    $smarty->assign('navigation', $navigation);
    $smarty->assign('products', $products);
    $smarty->assign('product_filter', $product_filter);
    if ($config['product_filter']['is_ajax'] == 'Y' && $ajax_filter) {
        $ns = cw_call('cw_core_get_html_page_url', array($page_get_params));
        $url = cw_product_get_filter_replaced_url($product_filter, $ns);
        $smarty->assign('replaced_url', $url);
        $smarty->assign('ajax_filter', $ajax_filter);
    }
    // turn off infinite scroll if products more than max_count_view_products
    if (!empty($app_config_file['interface']['max_count_view_products']) && $navigation['total_items'] >= $app_config_file['interface']['max_count_view_products']) {
        $smarty->assign("infinite_scroll_manual_off", "Y");
    }
}
$search_data['products'][$use_search_conditions]["substring"] = htmlentities(stripslashes($search_data['products'][$use_search_conditions]["substring"]));
$smarty->assign('js_tab', $search_data['products'][$use_search_conditions]['js_tab']);
$smarty->assign('search_prefilled', cw_stripslashes($search_data['products'][$use_search_conditions]));
$smarty->assign('warehouses', cw_get_warehouses());
$smarty->assign('mode', $mode);
コード例 #6
0
            $additional_fields[$k]['value'] = stripslashes($_POST['additional_values'][$v['field_id']]);
            if (empty($_POST['additional_values'][$v['field_id']]) && $v['required'] == 'Y' && $v['avail'] == 'Y') {
                $fillerror = true;
            }
        }
    }
    if (!$fillerror) {
        $fillerror = empty($subject) || empty($body);
    }
    if (!$fillerror && !$antibot_err) {
        $contact['b_statename'] = cw_get_state($contact['b_state'], $contact['b_country']);
        $contact['b_countryname'] = cw_get_country($contact['b_country']);
        if ($config['General']['use_counties'] == "Y") {
            $contact['b_countyname'] = cw_get_county($contact['b_county']);
        }
        $contact = cw_stripslashes($contact);
        $smarty->assign('contact', $contact);
        $smarty->assign('profile_fields', $profile_fields);
        $smarty->assign('is_areas', $is_areas);
        $smarty->assign('additional_fields', $additional_fields);
        cw_call('cw_send_mail', array($contact['email'], $config['Company']['support_department'], 'mail/contactus/subj.tpl', 'mail/contactus/body.tpl', $config['default_admin_language']));
        $top_message = array('content' => cw_get_langvar_by_name('txt_contact_us_sent'), 'type' => 'I');
        cw_header_location(cw_call('cw_core_get_html_page_url', array(array("var" => "help", "section" => "contactus", 'delimiter' => '&'))));
    } else {
        cw_unset($_POST, 'additional_values');
        $userinfo = $_POST;
        $userinfo['customer_id'] = $userinfo['uname'];
    }
}
#
# Recover password feature regenerates password and sends it to user if mail match
コード例 #7
0
    $smarty->assign('serial_numbers', array_chunk($serial_numbers, $config['sn']['serial_per_row_product']));
}
if ($addons['estore_products_review']) {
    cw_include('addons/estore_products_review/product_modify.php');
}
$is_default_attributes = false;
if (empty($product_info)) {
    $smarty->assign('new_product', 1);
    # kornev, if the product is new and the product_modified_data is empty - we should set the default values for the attributes
    if (empty($product_modified_data)) {
        $is_default_attributes = true;
    }
}
if (!empty($product_modified_data)) {
    # Restore saved product data
    $product_info = cw_stripslashes($product_modified_data);
    $product_info['image_det']['tmbn_url'] = $app_web_dir . "/index.php?target=image&type=products_images_det&id=" . $product_id . "&tmp=1&imgid=0&timestamp=" . time();
    $product_info['image_thumb']['tmbn_url'] = $app_web_dir . "/index.php?target=image&type=products_images_thumb&id=" . $product_id . "&tmp=1&imgid=0&timestamp=" . time();
    $attributes = $product_info['attributes'];
    if ($config['Appearance']['categories_in_products'] == '1') {
        if (!empty($product_info['category_ids']) && is_array($product_info['category_ids'])) {
            $product_info['add_category_ids'] = array_flip($product_info['category_ids']);
            foreach ($product_info['add_category_ids'] as $k => $v) {
                $product_info['add_category_ids'][$k] = true;
            }
        }
    }
    if ($product_modified_data['image_det'] && $file_upload_data['products_images_det']) {
        $file_upload_data['products_images_det']['is_redirect'] = false;
    }
    if ($product_modified_data['image_thumb'] && $file_upload_data['products_images_thumb']) {