function cw_sections_get($section, $data = array(), $where = '', $info_type = 264) { global $tables, $current_area, $user_account; // extract($params); $table = $tables[$section]; if (!$info_type) { $info_type = 264; } if ($current_area == 'C') { $where .= ($where ? ' and ' : ' ') . $table . '.active=1 '; if (in_array($section, array('arrivals', 'hot_deals', 'clearance', 'super_deals'))) { $current_time = time(); $where .= " and ({$table}.from_time <= {$current_time} or {$table}.from_time = 0) and ({$table}.to_time >={$current_time} or {$table}.to_time = 0) and ({$table}.min_amount <= {$tables['products_warehouses_amount']}.avail or {$table}.min_amount = 0)"; } $add_data['query_joins'][$section] = array('on' => "{$tables['products']}.product_id={$table}.product_id", 'is_inner' => 1); $data['where'] = $where; if ($data['sort_field'] == 'orderby' || empty($data['sort_field'])) { $data['sort_field'] = "{$table}.pos"; } $return = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => $info_type), $add_data); if ($data['all']) { $return = $return[0]; } } else { $return = cw_query("select {$table}.*, {$tables['products']}.product_id, {$tables['products']}.product from {$table}, {$tables['products']}, {$tables['products_warehouses_amount']} where {$tables['products_warehouses_amount']}.product_id = {$tables['products']}.product_id and {$tables['products_warehouses_amount']}.warehouse_customer_id = 0 and {$tables['products_warehouses_amount']}.variant_id=0 and {$tables['products']}.product_id={$table}.product_id {$where} order by {$table}.pos, {$tables['products']}.product"); } return $return; }
function export() { global $REQUEST_METHOD, $smarty, $config, $addons, $top_message, $customer_id, $tables; global $mode, $action, $amazon_config; $success = false; if ($REQUEST_METHOD != 'POST') { cw_header_location('index.php?target=' . addon_target); } if ($_POST['export_type'] == 'PaQ' && (empty($_POST['price']) && empty($_POST['quantity']))) { $top_message = array('content' => 'At least Price or Quantity must be exported.', 'type' => 'E'); cw_header_location('index.php?target=' . addon_target); return false; } $_filename = 'files/amazon/' . date('Ymd') . '_' . date('His') . '_' . $_POST['export_type'] . '.csv'; if (($filename = cw_allow_file($_filename, true)) && ($file = cw_fopen($_filename, 'w', true))) { $pids = cw_call('cw_objects_get_list_ids', array('P')); if (empty($pids)) { $pids = cw_query_column("SELECT product_id FROM {$tables['products']} WHERE status=1"); // Very bad. Use API } if ($pids) { $amazon_config = cw_array_merge($amazon_config, $config['amazon'], $_POST); cw_config_update('amazon', $_POST); $warnings = array(); $data = array(); $header_put = false; foreach ($pids as $v) { $variants = array(); $prod = cw_func_call('cw_product_get', array('id' => $v, 'info_type' => 8 | 64 | 128 | 256 | 512 | 2048)); $attr = cw_query_hash("SELECT a.field, av.value\n FROM {$tables['attributes_values']} av, {$tables['attributes']} a\n WHERE av.item_id={$v} AND av.item_type='P' AND a.attribute_id=av.attribute_id", 'field', false, true); // very bad. Use API if ($prod['is_variants']) { $variants = cw_call('cw_get_product_variants', array($v)); } else { $variants[0] = $prod; } foreach ($variants as $var) { $var = cw_array_merge($var, $attr); if ($_POST['export_type'] == 'PaQ') { $data = array('sku' => $var['productcode'], 'price' => $_POST['price'] ? $var['price'] : '', 'quantity' => $_POST['quantity'] ? $var['avail'] : '', 'leadtime-to-ship' => $amazon_config['default_leadtime_to_ship']); } if ($_POST['export_type'] == 'InvLoad') { $data = array('sku' => $var['productcode'], 'product-id' => empty($amazon_config['product_id_type']) ? '' : (string) $var[$amazon_config['product_id']], 'product-id-type' => $amazon_config['product_id_type'], 'price' => $var['price'], 'item-condition' => empty($var[$amazon_config['item_condition']]) ? $amazon_config['default_item_condition'] : $var[$amazon_config['item_condition']], 'quantity' => empty($amazon_config['fulfillment_center_id']) ? $var['avail'] : '', 'add-delete' => empty($_POST['add-delete']) ? 'a' : $_POST['add-delete'], 'will-ship-internationally' => empty($var[$amazon_config['ship_internationally']]) ? $amazon_config['default_ship_internationally'] : $var[$amazon_config['ship_internationally']], 'expedited-shipping' => empty($var[$amazon_config['expedited_shipping']]) ? $amazon_config['default_expedited_shipping'] : $var[$amazon_config['expedited_shipping']], 'standard-plus' => empty($var[$amazon_config['standard_plus']]) ? $amazon_config['default_standard_plus'] : $var[$amazon_config['standard_plus']], 'item-note' => $var[$amazon_config['item_note']], 'fulfillment-center-id' => $amazon_config['fulfillment_center_id'], 'product-tax-code' => $amazon_config['default_product_tax_code'], 'leadtime-to-ship' => $amazon_config['default_leadtime_to_ship']); } if (!$header_put) { fputcsv($file, array_keys($data), "\t"); $header_put = true; } fputcsv($file, $data, "\t"); } } } fclose($file); $top_message = array('content' => 'File <b>' . $_filename . '</b> successfully created'); } cw_header_location('index.php?target=' . addon_target); }
function smarty_function_select_category($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } cw_load('category'); $smarty->assign($assign, cw_func_call('cw_category_get', array('cat' => $category_id))); }
function on_add_cart(&$cart, $added_product) { global $smarty; cw_load('ajax', 'product'); $product_id = $cart['products'][$added_product['productindex']]['product_id']; $product = cw_func_call('cw_product_get', array('id' => $product_id, 'info_type' => 0 | 128)); $product = cw_array_merge($product, $added_product); $smarty->assign('product', $product); cw_add_ajax_block(array('id' => 'add2cart_popup', 'action' => 'update', 'template' => 'addons/ajax_add2cart/add2cart_popup.tpl'), 'add2cart_popup'); cw_add_ajax_block(array('id' => 'script', 'content' => 'sm("add2cart_popup",add2cart_popup_width,add2cart_popup_height, true, "' . $added_product['added_amount'] . ($added_product['added_amount'] > 1 ? ' items' : ' item') . ' added to cart")'), 'add2cart_popup_script'); }
function dashboard_action_setting() { global $smarty, $tables; $params = array('mode' => 'setting', 'sections' => null); $dashboard = cw_func_call('dashboard_build_sections', $params); foreach ($dashboard as $name => $dash) { $dashboard[$name] = array_merge($dashboard[$name], cw_query_first('SELECT * FROM ' . $tables['dashboard'] . ' WHERE name="' . mysql_real_escape_string($name) . '"')); } uasort($dashboard, 'cw_uasort_by_order'); $smarty->assign('dashboard', $dashboard); }
function cw_checkout_login() { global $smarty; cw_func_call('cw_checkout_login_prepare'); $top_message =& cw_session_register('top_message'); $smarty->assign('top_message', $top_message); $top_message = array(); header("Content-type: application/xml"); cw_display('customer/checkout/xml_login.tpl', $smarty); die; }
function cw_attributes_get($params, $return) { if ($params['item_type'] != 'P' || empty($params['item_id'])) { return $return; } $product = cw_func_call('cw_product_get', array('id' => $params['item_id'], 'info_type' => 0)); if (is_array($product) && $product['product_id'] && !cw_is_catalog_product($product)) { unset($return['original_url']); } return $return; }
function cw_ps_products_in_cart_pre($cart, $user_info) { $special_offers_apply =& cw_session_register("special_offers_apply"); # Delete all free added products if (is_array($cart['products'])) { foreach ($cart['products'] as $kk => $vv) { if ($vv["promotion_suite"]["free_product"] == 'Y') { cw_call('cw_delete_from_cart', array(&$cart, $vv['cartid'])); } } } # / Delete all free added products if (!empty($special_offers_apply['free_products'])) { foreach ($special_offers_apply['free_products'] as $pid => $qty) { # # Add product to the cart # $product = cw_func_call('cw_product_get', array('id' => $pid, 'info_type' => 8192)); $avail_amount = $product['avail']; $qty = min($qty, $avail_amount); $min_amount = $product['min_amount']; if ($qty >= $min_amount) { cw_load('warehouse'); $possible_warehouses = cw_warehouse_get_avails_customer($pid); $warehouse = key($possible_warehouses); $add_product = array(); $add_product["product_id"] = $pid; $add_product["amount"] = $qty; $add_product["product_options"] = ""; $add_product["price"] = 0.0; // warehouse is required, otherwise free product will be placed as separate order $add_product['warehouse_customer_id'] = $warehouse; // do to use cw_warehouse_add_to_cart_simple. It operates with global $cart while we use here local $cart copy // $result = cw_call('cw_warehouse_add_to_cart_simple', array($pid, $qty, '', 0.00)); $result = cw_call('cw_add_to_cart', array(&$cart, $add_product)); # Adjust just added product foreach ($cart['products'] as $ck => $cv) { if ($cv["cartid"] == $result['cartid']) { $cart['products'][$ck]["promotion_suite"]["free_product"] = true; // mark just added product as offered } } } else { unset($special_offers_apply['free_products'][$pid]); } } // foreach } // if return new EventReturn($cart['products'], array($cart, $user_info)); // replace cart in input params for main function }
function cw_google_base_cron() { global $domain_id; cw_include('addons/google_base/gb_attributes_map.php'); $log = array(); $domains = cw_func_call('cw_md_get_domains'); foreach ($domains as $domain) { $domain_id = $domain['domain_id']; $count = cw_include('addons/google_base/create_gb_xml.php'); $log[] = $count . ' records were exported to feed'; } return join("\n", $log); }
function smarty_modifier_attribute_data($value) { cw_load('attributes'); $data = ""; $use_description =& cw_session_register('use_description', true); if (preg_match('/(\\w+)\\.name/', $value, $matches)) { // Get attribute name by field $field_name = $matches[1]; if (!empty($field_name)) { $attribute_id = cw_attributes_get_attribute_by_field($field_name); $attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $attribute_id)); $data = $attribute['name']; } } else { if (preg_match('/(\\w+)\\.value/', $value, $matches)) { // Get attribute value by field global $product_filter; $pf =& $product_filter; $field_name = $matches[1]; if ($pf && $field_name) { foreach ($pf as $pf_value) { if ($pf_value['field'] == $field_name) { if ($pf_value['selected']) { foreach ($pf_value['selected'] as $pfs_value) { if (isset($pf_value['values'][$pfs_value])) { $data = $pf_value['values'][$pfs_value]['name']; } } } } } } } else { if ($use_description && preg_match('/(\\w+)\\.description/', $value, $matches)) { // Get attribute value by field $field_name = $matches[1]; if (!empty($field_name)) { global $smarty; $attribute_id = cw_attributes_get_attribute_by_field($field_name); $attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $attribute_id)); $use_description = false; require_once $smarty->_get_plugin_filepath('function', 'eval'); $data = smarty_function_eval(array('var' => $attribute['description']), $smarty); $use_description = true; } } } } return $data; }
function cw_ac_get_product_info($product_id) { global $user_account, $addons, $tables, $config; $product_id = intval($product_id); if (empty($product_id)) { return false; } $product = cw_func_call('cw_product_get', array('id' => $product_id, 'info_type' => 8 | 32 | 64 | 128 | 2048, 'user_account' => $user_account)); if (!(!empty($product) && is_array($product))) { return false; } if (!empty($addons['wholesale_trading'])) { $allowed_membership_ids = array(0); $membership_id = intval($user_account['membership_id']); if (!empty($membership_id)) { $allowed_membership_ids[] = $membership_id; } $query = "SELECT pp.quantity, pp.price " . "FROM {$tables['products_prices']} AS pp " . "WHERE pp.product_id = '" . $product_id . "' AND pp.membership_id IN ('" . implode("','", $allowed_membership_ids) . "') " . "AND pp.quantity > 1 AND pp.variant_id = 0 " . "GROUP BY pp.quantity " . "ORDER BY pp.quantity"; $wholesale_prices = cw_query($query); if (!empty($wholesale_prices) && is_array($wholesale_prices)) { $query = "SELECT MIN(pp.price) " . "FROM {$tables['products_prices']} AS pp " . "WHERE pp.quantity = 1 AND pp.membership_id IN ('" . implode("','", $allowed_membership_ids) . "') " . "AND pp.variant_id = 0 AND pp.product_id = '" . $product_id . "'"; $min_price = doubleval(cw_query_first_cell($query)); $prev_key = false; foreach ($wholesale_prices as $k => $wholesale_price) { if (doubleval($wholesale_price['price']) > $min_price) { unset($wholesale_prices[$k]); continue; } $min_price = doubleval($wholesale_price['price']); $wholesale_taxes = cw_tax_price(intval($wholesale_price['price']), $user_account, $product_id); $wholesale_prices[$k]['taxed_price'] = $wholesale_taxes['taxed_price']; $wholesale_prices[$k]['taxes'] = $wholesale_taxes['taxes']; if ($prev_key !== false && isset($wholesale_prices[$prev_key])) { $wholesale_prices[$prev_key]['next_quantity'] = intval($wholesale_price['quantity']) - 1; if (intval($product_accessory['min_amount']) > intval($wholesale_prices[$prev_key]['next_quantity'])) { unset($wholesale_prices[$prev_key]); } elseif (intval($product_accessory['min_amount']) > intval($wholesale_price['quantity'])) { $wholesale_prices[$prev_key]['quantity'] = intval($product_accessory['min_amount']); } } $prev_key = $k; } $wholesale_prices = array_values($wholesale_prices); $product['product_wholesale'] = $wholesale_prices; } } return $product; }
function smarty_function_price_filter_url($params, &$smarty) { static $pf_count = null; if (is_null($pf_count)) { $pf_count = count($smarty->get_template_vars('product_filter'), COUNT_RECURSIVE); } if ($pf_count > 200 || 1) { // For big filter unset($params['ns']); $params['prepared'] = 'no'; // This marker says to cw_pf_load() that passed URL is not prepared and must be re-requested from server return http_build_query($params); } else { // Old approach is not optimal for huge amount of attribute values return cw_func_call('cw_product_navigation_filter_url', $params); } }
function cw_mobile_get_domain_by_mobile_host_attr($host) { global $tables, $HTTPS; cw_load('attributes'); $mobile_attributes = cw_func_call('cw_attributes_get_attributes_by_field', array('field' => 'mobile_host')); if (!empty($mobile_attributes['DM'])) { $attribute_id = intval($mobile_attributes['DM']); // get domain data return cw_query_first("SELECT d.*, av.value as mobile_host \n\t\t\t\t\t\t\t\tFROM {$tables['domains']} d\n\t\t\t\t\t\t\t\tLEFT JOIN {$tables['attributes_values']} av ON av.item_id = d.domain_id\n\t\t\t\t\t\t\t\tLEFT JOIN {$tables['attributes']} a ON a.attribute_id = av.attribute_id\n\t\t\t\t\t\t\t\tWHERE av.attribute_id = '" . $attribute_id . "'\n\t\t\t\t\t\t\t\t\tAND av.value = '" . $host . "' \n\t\t\t\t\t\t\t\t\tAND a.active = 1"); } else { $mobile_mobile_flag = cw_session_register('mobile_mobile_flag'); if ($mobile_mobile_flag == 'on' && $_GET['mobile_version'] != 'off') { $result = cw_query_first("SELECT *, http_host as mobile_host\n\t\t\t\t\tFROM {$tables['domains']}\n\t\t\t\t\tWHERE " . ($HTTPS ? "https_host" : "http_host") . " ='" . $host . "'"); $result['skin'] .= mobile_addon_skin_prefix; return $result; } } return array(); }
function parse_ini_str($content, $name = '') { if (!is_object($this->_parse_ini_obj)) { require_once SMARTY_DIR . $this->config_class . '.class.php'; $this->_parse_ini_obj = new $this->config_class(); $this->_parse_ini_obj->overwrite = $this->config_overwrite; $this->_parse_ini_obj->booleanize = $this->config_booleanize; $this->_parse_ini_obj->read_hidden = $this->config_read_hidden; $this->_parse_ini_obj->fix_newlines = $this->config_fix_newlines; } # kornev # only required data $ret = array(); $buttons = array(); $_tmp = $this->_parse_ini_obj->parse_contents($content); $js_tab = $_tmp['vars']['default_tab']; $default_template = $_tmp['vars']['default_template']; if (is_array($_tmp['sections'])) { foreach ($_tmp['sections'] as $section => $vars) { if ($section == 'submit' || $section == 'reset' || $vars['vars']['type'] == 'button') { $buttons[] = $vars['vars']; continue; } if (!$vars['vars']['template']) { $vars['vars']['template'] = $default_template; } $ret[$section] = $vars['vars']; if (!$js_tab || !$_tmp['sections'][$js_tab]) { $js_tab = $section; } } } $ret = cw_func_call('cw_tabs_js_abstract', array('name' => $name, 'selected' => $js_tab, 'js_tabs' => $ret, 'buttons' => $buttons)); # kornev, we should defaine the selected tab.... # kornev, try to find the default once again if ($ret['selected'] != $_tmp['vars']['default_tab']) { if (isset($ret['js_tabs'][$_tmp['vars']['default_tab']])) { $ret['selected'] = $_tmp['vars']['default_tab']; } } return $ret; }
function cw_top_menu_make_sql_query() { global $tables, $app_web_dir; cw_load('category'); $pcats_ = cw_func_call('cw_category_search', array('data' => array('active' => 1, 'all' => 1))); $pcats_ = $pcats_[0]; foreach ($pcats_ as $v) { extract($v); $mid = 'p' . $category_id; $pmid = $parent_id; if ($pmid != 0) { $pmid = 'p' . $pmid; } $title = $category; $pcount = $product_count_web; //$link="$app_web_dir/?target=index&cat=$category_id"; $link = cw_call('cw_core_get_html_page_url', array(array('var' => 'index', 'cat' => $category_id))); $pos = $tm_pos; $active = $tm_active; $title2 = $tm_title; $type = 'pcat'; if (APP_AREA != 'customer' || $active != 0) { $pcats[] = compact('mid', 'pmid', 'title', 'pcount', 'link', 'pos', 'active', 'title2', 'type'); } } unset($pcats_); $fields = "CONCAT('u',category_id) as mid, CONCAT(parent_id_tag,parent_id) as pmid, category as title,\n"; $fields .= "0 as pcount, link, pos, active, '' as title2, 'ucat' as type\n"; if (APP_AREA == 'customer') { $where = "where active=1"; } else { $where = ""; } $sql = "select {$fields} from {$tables['top_menu_user_categories']} {$where};"; $ucats = cw_query($sql); $cats = array_merge($pcats, $ucats); foreach ($cats as $k => $v) { $sorter[$k] = $v['pos']; } array_multisort($sorter, $cats); return $cats; }
function cw_payment_paypalpro_payflow_run_processor($params, $return) { global $config; global $pp_final_action; if ($params['payment_data']['processor'] == 'paypal_pro_payflow') { $pp_final_action = $config['paypal_pro_payflow']['use_preauth'] == 'Y' ? 'Authorization' : 'Sale'; $result = cw_func_call('cw_paypal_pro_payflow_request', $params); if ($result['status'] == 'success') { $return['code'] = 1; $bill_message = 'Accepted (' . $result['respmsg'] . ')'; } else { $return['code'] = 2; $return['hide_mess'] = true; $bill_message = "Reason: " . $result['error']; if (isset($result['error_code']) && in_array($result['error_code'], array('12', '22', '23', '24'))) { $return['hide_mess'] = false; } else { $return['is_error'] = true; } } $bill_message .= "\nPayPal method: PayPal Website Payments Pro PayFlow Edition / Direct Payment"; $return["billmes"] = $bill_message; $return['avsmes'] = ''; if (isset($result['avsaddr'])) { $return['avsmes'] .= "AVS address: " . (empty($avs_codes[$result['avsaddr']]) ? "Code: " . $result['avsaddr'] : $avs_codes[$result['avsaddr']]) . "; "; } if (isset($result['avszip'])) { $return['avsmes'] .= "AVS zipcode: " . (empty($avs_codes[$result['avszip']]) ? "Code: " . $result['avszip'] : $avs_codes[$result['avszip']]) . "; "; } if (isset($result['cvv2match'])) { $return['cvvmes'] = empty($cvv_codes[$result['cvv2match']]) ? "Code: " . $result['cvv2match'] : $cvv_codes[$result['cvv2match']]; } if ($pp_final_action != 'Sale') { $return['is_preauth'] = true; } $cart =& cw_session_register('cart'); $return['extra_order_data'] = array("pnref" => $result['pnref'], "paypal_type" => "UKDP", "capture_status" => $pp_final_action != 'Sale' ? 'A' : '', 'transaction_amount' => $cart['info']['total']); } return $return; }
function cw_payment_authorize_sim_run_processor($params, $return) { if ($params['payment_data']['processor'] == authorize_sim_addon_name) { global $config, $tables, $current_location, $cart, $APP_SESS_ID; $addon_name = str_replace("-", "_", authorize_sim_addon_name); $asim_api_login_id = $config[$addon_name]['asim_api_login_id']; $asim_transaction_key = $config[$addon_name]['asim_transaction_key']; $asim_md5_hash = $config[$addon_name]['asim_md5_hash']; $asim_mode = $config[$addon_name]['asim_test_live_mode']; $asim_currency = $config[$addon_name]['asim_currency']; $asim_prefix = intval($config[$addon_name]['asim_prefix']); if (empty($asim_api_login_id) || empty($asim_transaction_key)) { $top_message = array("content" => "Enter your merchant credentials on settings page before running the payment.", "type" => "E"); cw_header_location($current_location . "index.php?target=cart&mode=checkout"); } define("AUTHORIZENET_API_LOGIN_ID", $asim_api_login_id); define("AUTHORIZENET_TRANSACTION_KEY", $asim_transaction_key); define("AUTHORIZENET_SANDBOX", $asim_mode == "live" ? FALSE : TRUE); define("AUTHORIZENET_MD5_SETTING", $asim_md5_hash); $payment_data = $params['payment_data']; $userinfo = $params['userinfo']; $doc_ids = $params['doc_ids']; $cart =& cw_session_register('cart'); $time = time(); $asim_amount = price_format($cart['info']['total']); $asim_fp_sequence = $asim_prefix . $time; $asim_fp_hash = AuthorizeNetDPM::getFingerprint($asim_api_login_id, $asim_transaction_key, $asim_amount, $asim_fp_sequence, $time); $asim_fp_timestamp = $time; $asim_relay_url = $current_location . '/index.php?target=' . authorize_sim_addon_target; // save $APP_SESS_ID $unique_id = strtolower(md5($asim_md5_hash . $asim_api_login_id . $userinfo['email'])); db_query("INSERT INTO {$tables['payment_data']} (ref_id, session_id) VALUES ('{$unique_id}', '{$APP_SESS_ID}')"); $card_expire_Month = intval($_POST['card_expire_Month']); $card_expire_Year = intval($_POST['card_expire_Year']); cw_func_call('cw_payment_create_form', array('url' => AUTHORIZENET_SANDBOX ? AuthorizeNetDPM::SANDBOX_URL : AuthorizeNetDPM::LIVE_URL, 'fields' => array('x_relay_response' => "FALSE", 'x_version' => "3.1", 'x_delim_char' => ",", 'x_delim_data' => "TRUE", 'x_amount' => $asim_amount, 'x_fp_sequence' => $asim_fp_sequence, 'x_fp_hash' => $asim_fp_hash, 'x_fp_timestamp' => $time, 'x_relay_response' => "TRUE", 'x_relay_url' => $asim_relay_url, 'x_login' => $asim_api_login_id, 'x_card_num' => $_POST['card_number'], 'x_exp_date' => date("m/y", mktime(0, 0, 0, $card_expire_Month, 1, $card_expire_Year)), 'x_card_code' => $_POST['card_cvv2'], 'x_first_name' => $_POST['first_name'], 'x_last_name' => $_POST['last_name'], 'x_address' => $_POST['address'], 'x_city' => $_POST['city'], 'x_state' => $_POST['state'], 'x_zip' => $_POST['zipcode'], 'x_country' => $_POST['country'], 'x_email' => $userinfo['email']), 'name' => $payment_data['title'])); exit; } return $return; }
function cw_bestseller_get_menu($category_id, $limit = 0, $info_type = 288, $att = array()) { global $addons, $config, $tables, $user_account, $current_area; $data = array(); $data['all'] = true; $data['flat_search'] = true; if ($config['General']['disable_outofstock_products'] == 'Y') { $data['min_avail'] = 0; } if ($category_id) { $data['category_id'] = $category_id; } $data['where'] = "IFNULL({$tables['products_stats']}.views_stats,0) > 0 and IFNULL({$tables['products_stats']}.sales_stats,0) > 0"; $data['sort_condition'] = "{$tables['products_stats']}.sales_stats DESC, {$tables['products_stats']}.views_stats DESC"; $data['limit'] = $limit ? $limit : $config['bestsellers']['number_of_bestsellers']; $data['attributes'] = $att; cw_load('product'); $return = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => $info_type)); if (!$limit) { return $return[0]; } return $return; }
function cw_payment_paypal_run_processor($params, $return) { if ($params['payment_data']['processor'] == 'paypal') { global $config, $tables, $current_location; $cart =& cw_session_register('cart'); $skey = cw_call('cw_payment_start'); cw_call('cw_payment_put_data', array($skey, array('state' => 'GO', 'doc_ids' => $params['doc_ids']))); if ($params['userinfo']['current_address']['country'] == "US") { $_customer_state = $params['userinfo']['current_address']['state']; } else { $_customer_state = $params['userinfo']['current_address']['statename']; } $u_phone = preg_replace('![^\\d]+!', '', $params['userinfo']['current_address']['phone']); $pp_ordr = $config['paypal']['prefix'] . join("-", $params['doc_ids']); $fields = array("charset" => 'UTF-8', "cmd" => "_ext-enter", "custom" => $skey, "invoice" => $pp_ordr, "redirect_cmd" => "_xclick", 'item_name' => $config['paypal']['pp_payment_for'] . ' (Order #' . $pp_ordr . ')', "mrb" => "R-2JR83330TB370181P", "pal" => "RDGQCFJTT6Y6A", "rm" => "2", "email" => $params['userinfo']['email'], "first_name" => $params['userinfo']['current_address']['firstname'], "last_name" => $params['userinfo']['current_address']['firstname'], "country" => $params['userinfo']['current_address']['country'], "address1" => $params['userinfo']['current_address']['address'], "address2" => $params['userinfo']['current_address']['address_2'], "city" => $params['userinfo']['current_address']['city'], "zip" => $params['userinfo']['current_address']['zipcode'], "state" => $_customer_state, "day_phone_a" => substr($u_phone, -10, -7), "day_phone_b" => substr($u_phone, -7, -4), "day_phone_c" => substr($u_phone, -4), "night_phone_a" => substr($u_phone, -10, -7), "night_phone_b" => substr($u_phone, -7, -4), "night_phone_c" => substr($u_phone, -4), "business" => $config['paypal']['pp_account'], "item_name" => $config['paypal']['pp_payment_for'], "amount" => sprintf("%0.2f", $cart['info']['total']), "currency_code" => $config['paypal']['pp_currency'], "return" => $current_location . '/index.php?target=paypal&mode=success&secureid=' . $skey, 'cancel_return' => $current_location . '/index.php?target=paypal&mode=cancel&secureid=' . $skey, 'shopping_url' => $current_location . '/index.php?target=paypal&mode=cancel&secureid=' . $skey, "notify_url" => $current_location . '/index.php?target=paypal', "bn" => "cartworks"); if ($config['paypal']['use_preauth'] == 'Y') { $fields['paymentaction'] = 'authorization'; } cw_func_call('cw_payment_create_form', array('url' => 'https://' . ($config['paypal']['test_mode'] == 'N' ? "www.paypal.com" : "www.sandbox.paypal.com") . '/cgi-bin/webscr', 'fields' => $fields, 'name' => $params['payment_data']['title'])); die; } return $return; }
function smarty_function_tunnel($params, &$smarty) { global $cw_allowed_tunnels; if (empty($params['func'])) { $smarty->trigger_error("tunnel: missing 'func' parameter"); return; } if (!in_array($params['func'], $cw_allowed_tunnels, true)) { $smarty->trigger_error("tunnel: function {$params['func']} is not allowed for call from templates", E_USER_ERROR); return; } if ($params['load']) { cw_load($params['load']); } $assign = $params['assign']; $func = $params['func']; if ($params['via'] == 'cw_call') { // order and number of params is important for cw_call() // we accept only paramX as params $func_params = array(); foreach ($params as $k => $v) { if (strpos($k, 'param') !== false) { $func_params[$k] = $v; } } ksort($func_params); $result = cw_call($params['func'], $func_params); } else { unset($params['load'], $params['func'], $params['assign']); $result = cw_func_call($func, $params); } if ($assign) { $smarty->assign($assign, $result); } else { echo $result; } }
} if ($mode == 'wishlist') { db_query("UPDATE {$tables['wishlist']} SET options = '" . addslashes(serialize($poptions)) . "' WHERE wishlist_id = '{$id}' AND event_id = '{$eventid}'"); } else { $variant_id = cw_get_variant_id($product_options, $product_id); $amount = cw_warehouse_get_warehouse_avail($cart['products'][$cartindex]['warehouse'], $product_id, null, $variant_id); // $amount = cw_get_options_amount($poptions, $cart['products'][$cartindex]['product_id']); if ($amount >= $cart['products'][$cartindex]['amount']) { $cart['products'][$cartindex]['options'] = $poptions; cw_unset($cart['products'][$cartindex], 'variant_id'); } else { cw_header_location("index.php?target=popup_poptions&target={$target}&id={$id}&err=avail"); } # Recalculate cart totals after updating $products = cw_call('cw_products_in_cart', array($cart, $user_account)); $cart = cw_func_call('cw_cart_calc', array('cart' => $cart, 'products' => $products, 'userinfo' => $user_account)); } ?> <script type="text/javascript"> <!-- if (window.opener) window.opener.location.reload(); window.close(); --> </script> <?php exit; } if (!$min_avail) { $min_avail = cw_query_first_cell("SELECT min_amount FROM {$tables['products']} WHERE product_id = '{$product_id}'"); } if (!$min_avail) {
cw_doc_make_relation($relation_doc_id, $rel_item_id, $v['amount']); } cw_doc_recalc($relation_doc_id); } } if ($doc_data['giftcerts'] && is_numeric($relation_doc_id)) { cw_doc_make_related_doc($doc_id, $relation_doc_id); } } } $secure_oid = $doc_ids; } else { $doc_ids = $secure_oid; } cw_session_save(); if ($action == 'request_for_quote') { cw_call('cw_doc_change_status', array($doc_ids, "Q")); $request = $app_catalogs['customer'] . "/index.php?target=order-message&doc_ids=" . implode(",", $doc_ids); $cart = $secure_oid = array(); cw_save_customer_cart($customer_id, $cart); cw_header_location($request); } else { $return = cw_func_call('cw_payment_run_processor', array('payment_data' => $payment_data, 'doc_ids' => $doc_ids, 'userinfo' => $userinfo)); if ($return && $payment_data['payment_type'] == 'cc') { $a = strlen($userinfo['card_cvv2']); $return['cvvmes'] = ($a ? $a . " digit(s)" : "not set") . " / "; } $return = cw_call('cw_payment_check_results', array($return)); cw_call('cw_payment_stop', array($return)); } exit;
function cw_dod_generate() { global $tables, $config, $current_language; $generator = cw_query_first("select * from {$tables['dod_generators']} where active=1 and startdate<='" . time() . "' and enddate>'" . time() . "' and dod_interval<>0 order by position asc, generator_id asc"); if (!empty($generator)) { //check last generation date $last_gen_date = $generator['current_offer_date']; $hrs_since_last_generation = intval((time() - $last_gen_date) / 3600); $generate_again = false; if ($generator['dod_interval_type'] == 'D') { $generate_again = $hrs_since_last_generation >= $generator['dod_interval'] * 24; $offer_enddate = min($generator['enddate'], time() + $generator['dod_interval'] * 24 * 3600); } elseif ($generator['dod_interval_type'] == 'T') { $dod_period_hrs = intval(($generator['enddate'] - $generator['startdate']) / 3600); $hrs_interval = intval($dod_period_hrs / $generator['dod_interval']); $generate_again = $hrs_since_last_generation >= $hrs_interval; $offer_enddate = min($generator['enddate'], time() + $dod_period_hrs / $generator['dod_interval'] * 3600); } if ($generate_again || $_GET['force_generate']) { if (!empty($generator['used_pids'])) { $used_pids = explode(';', $generator['used_pids']); } else { $used_pids = array(); } $dod_products = cw_query_column("select dbd.object_id from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_PRODS . "'"); $dod_categories = cw_query_column("select dbd.object_id from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_CATS . "'"); $dod_manufacturers = cw_query_column("select dbd.object_id from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_MANS . "'"); $dod_attributes = cw_query("select dbd.* from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_ATTR . "'"); //select products by dod conditions $data = array(); $dod_data_where_pids = ''; if ($dod_products) { $dod_data_where_pids = "{$tables['products']}.product_id in ('" . implode("','", $dod_products) . "')"; } if ($dod_categories) { $data['search_in_subcategories'] = 1; $data['category_ids'] = $dod_categories; } if ($dod_manufacturers) { $manufacturer_id_attribute = cw_query_first_cell("select attribute_id from {$tables['attributes']} where field='manufacturer_id' and addon='manufacturers'"); if ($manufacturer_id_attribute) { if (!isset($ret_params)) { $ret_params = array(); } if (!isset($ret_params['query_joins'])) { $ret_params['query_joins'] = array(); } $ret_params['query_joins']['atv_manufacturer'] = array('tblname' => 'attributes_values', 'on' => "{$tables['products']}.product_id=atv_manufacturer.item_id and atv_manufacturer.item_type='P' and atv_manufacturer.attribute_id = '{$manufacturer_id_attribute}' and atv_manufacturer.code in ('{$current_language}', '') and atv_manufacturer.value in ('" . implode("','", $dod_manufacturers) . "')", 'is_inner' => 1); } } if ($dod_attributes) { $param2_sql = array('eq' => '=', 'lt' => '<', 'le' => '<=', 'gt' => '>', 'ge' => '=>'); foreach ($dod_attributes as $attr_data_k => $attr_data) { $is_def_values = cw_query_first("select * from {$tables['attributes_default']} where attribute_value_id='{$attr_data['param1']}' and attribute_id='{$attr_data['object_id']}'"); //print_r($is_def_values);print("<br><br>"); $sql_operation = $param2_sql[$attr_data['param2']]; if (empty($sql_operation)) { continue; } if (!isset($ret_params)) { $ret_params = array(); } if (!isset($ret_params['query_joins'])) { $ret_params['query_joins'] = array(); } if ($is_def_values) { $ret_params['query_joins']['atv_dod_' . $attr_data_k] = array('tblname' => 'attributes_values', 'on' => "{$tables['products']}.product_id=atv_dod_{$attr_data_k}.item_id and atv_dod_{$attr_data_k}.item_type='P' and atv_dod_{$attr_data_k}.attribute_id = '{$attr_data['object_id']}' and atv_dod_{$attr_data_k}.code in ('{$current_language}', '')", 'is_inner' => 1); $ret_params['query_joins']['atd_dod_' . $attr_data_k] = array('tblname' => 'attributes_default', 'on' => "atd_dod_{$attr_data_k}.attribute_value_id=atv_dod_{$attr_data_k}.value and atv_dod_{$attr_data_k}.attribute_id=atd_dod_{$attr_data_k}.attribute_id and atd_dod_{$attr_data_k}.value{$sql_operation}'" . addslashes($is_def_values['value']) . "'", 'is_inner' => 1); } else { $ret_params['query_joins']['atv_dod_' . $attr_data_k] = array('tblname' => 'attributes_values', 'on' => "{$tables['products']}.product_id=atv_dod_{$attr_data_k}.item_id and atv_dod_{$attr_data_k}.item_type='P' and atv_dod_{$attr_data_k}.attribute_id = '{$attr_data['object_id']}' and atv_dod_{$attr_data_k}.code in ('{$current_language}', '') and atv_dod_{$attr_data_k}.value{$sql_operation}'{$attr_data['param1']}'", 'is_inner' => 1); } } } global $user_account, $current_area, $items_per_page_targets, $target; $items_per_page_targets[$target] = 1; $new_pid = 0; $safety_cnt = 1000; while (!$new_pid && $safety_cnt > 0) { if (!empty($data) || !empty($dod_data_where_pids)) { $data['sort_field'] = 'rand'; $data['flat_search'] = 1; $dod_data_where = array(); if (!empty($dod_data_where_pids)) { $dod_data_where[] = $dod_data_where_pids; } if (!empty($used_pids)) { $dod_data_where[] = "{$tables['products']}.product_id not in ('" . implode("','", $used_pids) . "')"; } $data['where'] = implode(' and ', $dod_data_where); list($products, $nav, $product_filter) = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => 8, 'product_id_only' => 1), $ret_params); } $product = reset($products); //print_r(array('product'=>$product));print("<br><br>"); $new_pid = $product['product_id']; if (!$new_pid) { if ($generator['no_item_repeat']) { break; } else { if (!empty($used_pids)) { array_shift($used_pids); } else { break; } } } $safety_cnt--; } //die; if ($new_pid) { $used_pids[] = $new_pid; } $generator['used_pids'] = implode(';', $used_pids); $regenerate_offer = true; if ($regenerate_offer) { //regenerate offer if (!empty($generator['current_offer_id'])) { $offer_ids = array($generator['current_offer_id']); $offer_ids_query = implode("', '", $offer_ids); db_query("DELETE FROM {$tables['ps_offers']} WHERE offer_id IN ('" . $offer_ids_query . "')"); db_query("DELETE FROM {$tables['ps_bonuses']} WHERE offer_id IN ('" . $offer_ids_query . "')"); db_query("DELETE FROM {$tables['ps_bonus_details']} WHERE offer_id IN ('" . $offer_ids_query . "')"); db_query("DELETE FROM {$tables['ps_conditions']} WHERE offer_id IN ('" . $offer_ids_query . "')"); db_query("DELETE FROM {$tables['ps_cond_details']} WHERE offer_id IN ('" . $offer_ids_query . "')"); db_query("DELETE FROM {$tables['attributes_values']} WHERE item_id IN ('" . $offer_ids_query . "') and item_type='PS'"); foreach ($offer_ids as $offer_id) { cw_image_delete($offer_id, PS_IMG_TYPE); } cw_attributes_cleanup($offer_ids, PS_ATTR_ITEM_TYPE); cw_cache_clean('shipping_rates'); } if ($new_pid) { cw_log_add('dod_generator', array('new DOD product selected' => $new_pid)); $new_offer_id = cw_array2insert('ps_offers', array('title' => 'Deal Of The Day', 'description' => $generator['description'], 'startdate' => time(), 'enddate' => $offer_enddate, 'active' => 1)); } $current_offer_id = 0; if ($new_offer_id) { $mdm_attribute_id = cw_query_first_cell("select attribute_id from {$tables['attributes']} where addon='multi_domains' and item_type='PS'"); if ($mdm_attribute_id) { cw_array2insert('attributes_values', array('item_id' => $new_offer_id, 'attribute_id' => $mdm_attribute_id, 'value' => 0, 'code' => '', 'item_type' => 'PS')); } //copy bonus and bonus details $dod_bonuses = cw_query("select * from {$tables['dod_bonuses']} where generator_id='{$generator['generator_id']}' and unused=0"); foreach ($dod_bonuses as $dod_bonus) { $_dod_bonus = $dod_bonus; unset($_dod_bonus['generator_id']); $_dod_bonus['offer_id'] = $new_offer_id; $new_bonus_id = cw_array2insert('ps_bonuses', $_dod_bonus); if ($_dod_bonus['type'] == 'D' && $_dod_bonus['apply'] == 3) { cw_array2insert('ps_bonus_details', array('bonus_id' => $new_bonus_id, 'offer_id' => $new_offer_id, 'object_id' => $new_pid, 'quantity' => 1, 'object_type' => DOD_OBJ_TYPE_PRODS)); } else { $dod_bonus_details = cw_query("select * from {$tables['dod_bonus_details']} where generator_id='{$generator['generator_id']}' and bonus_id='{$dod_bonus['bonus_id']}'"); if (!empty($dod_bonus_details)) { foreach ($dod_bonus_details as $dod_bonus_detail) { $_dod_bonus_detail = $dod_bonus_detail; unset($_dod_bonus_detail['generator_id']); $_dod_bonus_detail['offer_id'] = $new_offer_id; $_dod_bonus_detail['bonus_id'] = $new_bonus_id; cw_array2insert('ps_bonus_details', $_dod_bonus_detail); } } } } $new_cond_id = cw_array2insert('ps_conditions', array('type' => 'P', 'total' => '0.00', 'offer_id' => $new_offer_id)); if ($new_cond_id) { cw_array2insert('ps_cond_details', array('cond_id' => $new_cond_id, 'offer_id' => $new_offer_id, 'object_id' => $new_pid, 'quantity' => 1, 'object_type' => DOD_OBJ_TYPE_PRODS)); } $current_offer_id = $new_offer_id; } } //update dod_generator fields cw_array2update('dod_generators', array('current_offer_id' => $current_offer_id, 'used_pids' => $generator['used_pids'], 'current_offer_date' => $current_offer_id ? time() : 0), "generator_id='{$generator['generator_id']}'"); if ($current_offer_id && !empty($config['deal_of_day']['dod_news_template']) && $config['deal_of_day']['dod_newslist']) { $newslist = cw_query_first("select * from {$tables['newslists']} where list_id='" . $config['deal_of_day']['dod_newslist'] . "' and avail=1"); if (!empty($newslist)) { //create message global $smarty; $smarty->assign('promotion', $generator); $smarty->assign('product_id', $new_pid); $product_info = cw_func_call('cw_product_get', array('id' => $new_pid, 'user_account' => $user_account, 'info_type' => 65535)); $smarty->assign('product', $product_info); $smarty->assign('news_message', $config['deal_of_day']['dod_news_template']); $message = cw_display("addons/deal_of_day/admin/generate_news.tpl", $smarty, false, $newslist['lngcode']); $smarty->assign('news_message', $config['deal_of_day']['dod_news_template_subject']); $message_subject = cw_display("addons/deal_of_day/admin/generate_news.tpl", $smarty, false, $newslist['lngcode']); // $message = $smarty->display('addons/deal_of_day/admin/generate_news.tpl'); print $message_subject . "<hr />" . $message; if (!empty($message)) { cw_array2insert('newsletter', array('subject' => $message_subject, 'body' => $message, 'created_date' => time(), 'send_date' => time(), 'updated_date' => time(), 'status' => 'N', 'list_id' => $config['deal_of_day']['dod_newslist'], 'show_as_news' => 1, 'allow_html' => 1)); } } } } } return $new_pid; }
<?php if (cw_query_first_cell("SELECT COUNT(*) FROM {$tables['categories']} WHERE category_id='{$cat}'") == 0) { cw_header_location('index.php?target=categories'); } $category_page =& cw_session_register('category_page'); $data = array(); $data['flat_search'] = 1; $data['category_id'] = $cat; $data['category_main'] = "Y"; $data['category_extra'] = "Y"; $data['page'] = $page; $data['objects_per_page'] = $category_page['objects_per_page']; $data['sort_field'] = $category_page['sort_field']; $data['sort_direction'] = $category_page['sort_direction']; list($products, $navigation) = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => 0)); $navigation['script'] = 'index.php?target=' . $target . '&mode=' . $mode . '&cat=' . $cat; $smarty->assign('navigation', $navigation); $smarty->assign('products', $products); $smarty->assign('current_category', cw_func_call('cw_category_get', array('cat' => $cat))); $smarty->assign('main', 'category_products');
function cw_apply_special_offer_shipping($params, $return) { global $tables; $special_offers_apply =& cw_session_register('special_offers_apply'); $products = $params['products']; if (empty($special_offers_apply['free_shipping'])) { return $return; } if (empty($return)) { return $return; } //cw_var_dump($return); $new_rates = array(); // Re-calculate applicable total weight / items / subtotal taking into account bonuses $total = $params['what_to_ship_params']; if (is_array($special_offers_apply['free_shipping']) && is_array($special_offers_apply['free_shipping']['products']) && !empty($special_offers_apply['free_shipping']['products'])) { $hash = crc32(serialize($total)); foreach ($special_offers_apply['free_shipping']['products'] as $pid => $qty) { foreach ($products as $kk => $product) { if ($product['product_id'] == $pid) { $tmp_qty = min($qty, $product['amount']); if ($tmp_qty <= 0) { continue; } # Calculate total_cost and total_+weight for shipping calculation if ($product["free_shipping"] == "Y") { continue; } if ($product['shipping_freight'] <= 0 || $config['Shipping']['replace_shipping_with_freight'] != 'Y') { $total['apply']['weight'] -= $product["weight"] * $tmp_qty; $total['apply']['items'] -= $tmp_qty; $total['apply']['DST'] -= $product['display_discounted_price'] * $tmp_qty / $product['amount']; $total['apply']['ST'] -= $product['display_subtotal'] * $tmp_qty / $product['amount']; // Correct products array $product['amount'] -= $tmp_qty; $product['display_subtotal'] = $product['display_subtotal'] * $product['amount'] / ($tmp_qty + $product['amount']); $product['display_discounted_price'] = $product['display_discounted_price'] * $product['amount'] / ($tmp_qty + $product['amount']); $products[$kk] = $product; if ($products[$kk]['amount'] <= 0) { unset($products[$kk]); } $qty -= $tmp_qty; } } } } if ($hash != crc32(serialize($total)) && $total['apply']['items'] > 0) { // Unset this function hook and retrieve rates again with corrected params cw_addons_unset_hooks(array('post', 'cw_shipping_get_rates', 'cw_apply_special_offer_shipping')); $_params = $params; $_params['what_to_ship_params'] = $total; $_params['weight'] = $total['apply']['weight']; $_params['products'] = $products; $new_rates = cw_func_call('cw_shipping_get_rates', $_params); // Restore function hook cw_addons_set_hooks(array('post', 'cw_shipping_get_rates', 'cw_apply_special_offer_shipping')); } } // Re-calc rates foreach ($return as $k => $rate) { // If bonus is applicable for certain methods only, then check this method if (!empty($special_offers_apply['free_shipping']['methods']) && is_array($special_offers_apply['free_shipping']['methods']) && !in_array($rate['shipping_id'], $special_offers_apply['free_shipping']['methods'])) { continue; } // If bonus is applicable for whole cart, then set the new rate regardless cart content if ($special_offers_apply['free_shipping']['apply'] == constant('PS_APPLY_CART')) { $return[$k]['saved_rate'] = $rate['original_rate']; // save initial rate to calc discount $return[$k]['original_rate'] = $special_offers_apply['free_shipping']['rate']; continue; } // If bonus is applicable for selected products then if (in_array($special_offers_apply['free_shipping']['apply'], array(PS_APPLY_COND, PS_APPLY_PRODS)) && !empty($special_offers_apply['free_shipping']['products'])) { if (isset($new_rates[$k])) { $return[$k] = $new_rates[$k]; } if ($total['apply']['items'] <= 0) { $return[$k]['original_rate'] = 0; } $return[$k]['original_rate'] += $special_offers_apply['free_shipping']['rate']; $return[$k]['saved_rate'] = $rate['original_rate']; // save initial rate to calc discount if (defined('AOM') && constant('AOM')) { $return[$k]['shipping'] .= '*'; //$return[$k]['shipping'] .= ' [offer: '.$rate['original_rate'].' => '.floatval($special_offers_apply['free_shipping']['rate']).'+'.floatval($new_rates[$k]['original_rate']).']'; } } } // strange, but $rate['original_rate'] is exactly final rate value, not initial as you may think return $return; }
function dod_get_attr_ajax() { global $smarty, $tables; global $attribute_id, $bd_id; $value = $operation = $quantity = ''; if (!empty($bd_id)) { // extract from DB certain condition details $bonus_details = cw_query_first("SELECT * FROM {$tables['dod_bonus_details']} WHERE bd_id='{$bd_id}'"); $attribute_id = $bonus_details['object_id']; $quantity = $bonus_details['quantity']; $value = $bonus_details['param1']; $operation = $bonus_details['param2']; } if (empty($attribute_id)) { return false; } cw_load('attributes'); $attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $attribute_id)); $attribute['value'] = $value; $attribute['values'] = array($value); $smarty->assign(array('attribute' => $attribute, 'index' => empty($bd_id) ? time() : 'bd_id' . $bd_id, 'quantity' => $quantity, 'value' => $value, 'operation' => $operation)); cw_ajax_add_block(array('action' => 'append', 'id' => 'dod_attributes', 'template' => 'addons/deal_of_day/admin/attribute_row.tpl')); return true; }
cw_review_recalculate_avg_rating($review_data['product_id'], $attr_id); } cw_review_recalculate_avg_rating($review_data['product_id']); cw_add_top_message(cw_get_langvar_by_name('txt_thank_you_for_review')); } else { cw_add_top_message(cw_get_langvar_by_name('err_filling_form'), 'E'); } cw_header_location("index.php?target=global_reviews"); } $items_per_page_targets[$target] = 10; $total_items = cw_call('cw_review_get_global_review', array()); $navigation = cw_core_get_navigation($target, $total_items, $page); $global_reviews = cw_call('cw_review_get_global_review', array('', '', " ORDER BY {$tables['products_reviews']}.ctime DESC ", "LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}", FALSE)); $items_per_page_targets[$target] = PHP_INT_MAX; $navigation['script'] = 'index.php?target=' . $target; $smarty->assign('navigation', $navigation); if (!empty($global_reviews)) { $rating_cond = "type='global_rating'"; list($attributes, $nav) = cw_func_call('cw_attributes_search', array('data' => array('active' => 1, 'is_show' => 1, 'sort_field' => 'orderby')), array('where' => array($rating_cond))); if (!empty($attributes)) { foreach ($global_reviews as $rev_k => $rev_v) { $global_reviews[$rev_k]['votes'] = array(); foreach ($attributes as $att) { $global_reviews[$rev_k]['votes'][] = array('attribute' => $att, 'vote_value' => cw_query_first_cell("SELECT 100*({$tables['products_votes']}.vote_value/5.00) FROM {$tables['products_votes']} WHERE {$tables['products_votes']}.review_id = '{$rev_v['review_id']}' AND {$tables['products_votes']}.attribute_id='{$att['attribute_id']}' AND {$tables['products_votes']}.product_id = 0")); } } $smarty->assign('vote_attributes', $attributes); } } $smarty->assign('global_reviews', $global_reviews); $smarty->assign('main', 'global_reviews');
<?php # [TOFIX] # kornev, move to addon $product_info = cw_func_call('cw_product_get', array('id' => $product_id, 'user_account' => $user_account, 'info_type' => 136)); $smarty->assign('product', $product_info); include $app_main_dir . '/include/products/send_to_friend.php'; $smarty->assign('main', 'popup_send2friend'); $smarty->assign('home_style', 'popup'); if (defined('IS_AJAX') && constant('IS_AJAX')) { cw_ajax_add_block(array('id' => 'send_to_friend_dialog', 'template' => 'customer/main/send_to_friend.tpl')); cw_ajax_add_block(array('id' => 'script', 'content' => 'sm("send_to_friend_dialog", send_to_friend_dialog_width, send_to_friend_dialog_height, false, send_to_friend_dialog_title)')); }
<?php $shipping = cw_func_call('cw_shipping_get_list', array('cart' => $aom_orders[$doc_id], 'products' => $aom_orders[$doc_id]['products'], 'userinfo' => $aom_orders[$doc_id]['userinfo'])); if (!empty($_saved_data)) { extract($_saved_data); } if (is_array($shipping)) { $found = false; foreach ($shipping as $k => $v) { if ($doc_data['order']['shipping_id'] == $v['shipping_id']) { $found = true; break; } } if (!$found && empty($doc_data['order']['shipping_id'])) { } else { if (!$found && $aom_orders[$doc_id]['shipping_id'] == $doc_data['order']['shipping_id']) { $aom_orders[$doc_id]['shipping_id'] = $shipping[0]['shipping_id']; $aom_orders[$doc_id]['shipping'] = $shipping[0]['shipping']; } if (!$found) { $smarty->assign('shipping_lost', $shipping); } } } $smarty->assign('shipping', $shipping);
<?php $params = array('mode' => 'dashboard', 'sections' => cw_query_hash("SELECT * FROM {$tables['dashboard']}", 'name', false, false)); $dashboard = cw_func_call('dashboard_build_sections', $params); // Re-check if some addon ignored active flag foreach ($dashboard as $name => $dash) { $dashboard[$name] = array_merge(array('frame' => 1, 'header' => 1), $dashboard[$name]); if (isset($params['sections'][$name])) { $dashboard[$name] = array_merge($dashboard[$name], $params['sections'][$name]); } if ($dashboard[$name]['active'] == 0) { unset($dashboard[$name]); } } uasort($dashboard, 'cw_uasort_by_order'); $smarty->assign('dashboard', $dashboard);