本文整理汇总了PHP中cw_query_column函数的典型用法代码示例。如果您正苦于以下问题:PHP cw_query_column函数的具体用法?PHP cw_query_column怎么用?PHP cw_query_column使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cw_query_column函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cw_ps_bundle_update
function cw_ps_bundle_update($product_id)
{
global $tables, $config;
$product_id = (int) $product_id;
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
cw_ps_bundle_redirect($product_id);
}
$offer_id = cw_call('cw_ps_offer_bundle_update', array($product_id, $_POST));
// Delete selected products
if (is_array($_POST['del_cond'])) {
foreach ($_POST['del_cond'] as $k => $v) {
$k = intval($k);
db_query("DELETE FROM {$tables['ps_cond_details']} WHERE offer_id='{$offer_id}' AND object_id='{$k}' AND object_type='" . PS_OBJ_TYPE_PRODS . "'");
db_query("DELETE FROM {$tables['ps_bonus_details']} WHERE offer_id='{$offer_id}' AND object_id='{$k}' AND object_type='" . PS_OBJ_TYPE_PRODS . "'");
}
}
$cond_products = cw_query_column("SELECT object_id FROM {$tables['ps_cond_details']} WHERE offer_id='{$offer_id}' AND object_type='" . PS_OBJ_TYPE_PRODS . "'");
if (count($cond_products) <= 1) {
//delete offer
cw_call('cw_ps_offer_delete', array($offer_id));
}
cw_array2update('ps_offers', array('auto' => 0), "offer_id='{$offer_id}'");
// TODO: Domain assignation
cw_ps_bundle_redirect($product_id);
}
示例2: export
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);
}
示例3: cw_file_area_delete_list
function cw_file_area_delete_list($type, $id, $field = 'customer_id')
{
global $tables;
$list = cw_query_column("select file_id from " . $tables[$type] . " where {$field}='{$id}'");
if (is_array($list)) {
foreach ($list as $v) {
cw_file_area_delete($type, $v);
}
}
}
示例4: cw_add_class_data
function cw_add_class_data($data, $product_id)
{
global $tables;
# Update class data
$comp = $data['class'];
$comp['product_id'] = $product_id;
cw_unset($comp, "product_option_id");
$comp = cw_addslashes($comp);
$product_option_id = cw_query_first_cell("SELECT product_option_id FROM {$tables['product_options']} WHERE class = '{$comp['class']}' AND product_id = '{$comp['product_id']}'");
$is_new = empty($product_option_id);
if (!empty($product_option_id)) {
cw_array2update("product_options", $comp, "product_option_id = '{$product_option_id}'");
} else {
$product_option_id = cw_array2insert("product_options", $comp);
}
# Update class multilanguage data
db_query("DELETE FROM {$tables['product_options_lng']} WHERE product_option_id = '{$product_option_id}'");
foreach ($data['product_options_lng'] as $v) {
$v['product_option_id'] = $product_option_id;
$v = cw_addslashes($v);
cw_array2insert("product_options_lng", $v, true);
}
# Update class options
$ids = array();
foreach ($data['product_options_values'] as $k => $opt) {
$opt['product_option_id'] = $product_option_id;
$old_option_id = $opt['option_id'];
cw_unset($opt, "option_id");
$opt = cw_addslashes($opt);
$option_id = cw_query_first_cell("SELECT option_id FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND name = '{$opt['name']}'");
if (empty($option_id)) {
$option_id = cw_array2insert("product_options_values", $opt);
} else {
cw_array2update("product_options_values", $opt, "option_id = '{$option_id}'");
}
$ids[$old_option_id] = $option_id;
}
# Update class option multilanguage data
db_query("DELETE FROM {$tables['product_options_values_lng']} WHERE option_id = '{$option_id}'");
foreach ($data['product_options_values_lng'] as $v) {
if (!isset($ids[$v['option_id']])) {
continue;
}
$v['option_id'] = $ids[$v['option_id']];
$v = cw_addslashes($v);
cw_array2insert("product_options_values_lng", $v, true);
}
# Detect and delete old product option class options
$ids = cw_query_column("SELECT option_id FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND option_id NOT IN ('" . implode("','", $ids) . "')");
if (!empty($ids)) {
db_query("DELETE FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND option_id IN ('" . implode("','", $ids) . "')");
db_query("DELETE FROM {$tables['product_options_values_lng']} WHERE option_id IN ('" . implode("','", $ids) . "')");
db_query("DELETE FROM {$tables['products_options_ex']} WHERE option_id IN ('" . implode("','", $ids) . "')");
}
}
示例5: on_sessions_delete
function on_sessions_delete($sess_id)
{
global $tables;
// delete bookmarks of expired non-registered sessions
$sess_ids = cw_query_column("SELECT b.sess_id \n\t\tFROM {$tables['bookmarks']} b \n\t\tLEFT JOIN {$tables['sessions_data']} sd ON sd.sess_id = LEFT( b.sess_id, LENGTH( sd.sess_id )) \n\t\tWHERE sd.sess_id IS NULL and b.customer_id=0");
if ($sess_ids) {
foreach ($sess_ids as $sess_id) {
db_query("delete from {$tables['bookmarks']} where sess_id='{$sess_id}'");
}
}
}
示例6: cw_web_get_layouts
function cw_web_get_layouts($layout, $like = false)
{
global $tables;
$layouts = cw_query_column("select layout_id from {$tables['layouts']} where layout" . ($like ? ' like ' : ' = ') . "'{$layout}'");
$return = array();
if ($layouts) {
foreach ($layouts as $layout_id) {
$return[] = cw_web_get_layout_inner("layout_id='{$layout_id}'");
}
}
return $return;
}
示例7: cw_warehouse_get_enabled_for_customer
function cw_warehouse_get_enabled_for_customer($customer_id)
{
global $tables;
static $cached;
if (!isset($cached)) {
$is_assigned = cw_query_column("select division_id from {$tables['customers_warehouses']} where customer_id='{$customer_id}'");
$is_enabled = cw_query_column("select division_id from {$tables['warehouse_divisions']} where enabled=1");
if ($is_assigned) {
$cached = array_intersect($is_assigned, $is_enabled);
} else {
$cached = $is_enabled;
}
}
return $cached;
}
示例8: cw_addons_get
function cw_addons_get($parent_addon = '')
{
global $current_language, $tables;
$addons = cw_query("select m.*, IFNULL(lng1.value, m.addon) as addon_lng, IFNULL(lng2.value, m.descr) as addon_descr_lng from {$tables['addons']} as m left join {$tables['languages']} as lng1 ON lng1.code = '{$current_language}' and lng1.name = CONCAT('addon_name_', m.addon) left join {$tables['languages']} as lng2 ON lng2.code = '{$current_language}' and lng2.name = CONCAT('addon_descr_', m.addon) where m.parent='{$parent_addon}' order by addon_lng");
$mod_options = cw_query_column("select {$tables['addons']}.addon from {$tables['addons']}, {$tables['config_categories']} where {$tables['addons']}.addon={$tables['config_categories']}.category group by {$tables['addons']}.addon", "addon");
foreach ($addons as $k => $v) {
// cw_get_langvar_by_name provides name and descr including tooltip
if ($v['addon'] != $v['addon_lng']) {
$addons[$k]['addon_lng'] = cw_get_langvar_by_name('addon_name_' . $v['addon']);
}
if ($v['descr'] != $v['addon_descr_lng']) {
$addons[$k]['addon_descr_lng'] = cw_get_langvar_by_name('addon_descr_' . $v['addon']);
}
if ($parent_id == 0) {
$addons[$k]['subaddons'] = cw_addons_get($v['addon']);
}
if (in_array($v['addon'], $mod_options)) {
$addons[$k]['options_url'] = true;
}
}
return $addons;
}
示例9: cw_common_tables_diff
function cw_common_tables_diff($conn, $except_of = '')
{
$comm_tabs = cw_common_tables_names($conn, $except_of);
$cv = $xc = '';
foreach ($comm_tabs as $k => $v) {
$c = cw_query_column("show create table {$v}", 1);
$x = cw_query_column("show create table {$k}", 1, $conn);
$cv .= $c[0] . "\n\n";
$xc .= $x[0] . "\n\n";
}
$h = fopen("./var/ctc_cv", "w");
fwrite($h, $cv);
fclose($h);
$h = fopen("./var/ctc_xc", "w");
fwrite($h, $xc);
fclose($h);
exec("diff -rabEBpd -U 2 ./var/ctc_xc ./var/ctc_cv > ./var/ctc.diff");
}
示例10: array
if ($action == 'delete_one_cat') {
$categories_to_delete = array($cat);
cw_header_location("index.php?target=categories&cat={$cat}&mode=delete");
}
$smarty->assign('js_tab', $js_tab);
$featured_types = array('featured_products', 'new_arrivals');
foreach ($featured_types as $tbl) {
$products = cw_query("SELECT " . $tables[$tbl] . ".*, {$tables['products']}.product from " . $tables[$tbl] . ", {$tables['products']} where " . $tables[$tbl] . ".product_id={$tables['products']}.product_id AND " . $tables[$tbl] . ".category_id='{$cat}' order by " . $tables[$tbl] . ".product_order");
$smarty->assign($tbl, $products);
}
$smarty->assign('main', 'categories');
if ($mode == 'delete' && $confirmed != "Y" && is_array($categories_to_delete)) {
$subcats = $ids = array();
foreach ($categories_to_delete as $val) {
$ids[] = $val;
$curr_subcats = cw_query_column("SELECT c.category_id FROM {$tables['categories']} as c, {$tables['categories_parents']} as cp WHERE c.category_id=cp.parent_id and cp.parent_id='{$val}'");
if ($curr_subcats) {
$ids = array_merge($ids, $curr_subcats);
}
}
$subcats = cw_query("SELECT category_id, category FROM {$tables['categories']} WHERE category_id in ('" . implode("', '", $ids) . "')");
if (is_array($subcats)) {
foreach ($subcats as $k => $v) {
# kronev, for the big amount of products - there are no any sense to display it
$subcats[$k]['products_count'] = cw_query_first_cell("SELECT count(*) FROM {$tables['products_categories']}, {$tables['products']} WHERE {$tables['products_categories']}.category_id='{$v['category_id']}' AND {$tables['products_categories']}.product_id={$tables['products']}.product_id AND {$tables['products_categories']}.main=1");
// $subcats[$k]['products_count'] = (is_array($subcats[$k]['products']) ? count($subcats[$k]['products']) : 0);
}
}
$smarty->assign('subcats', $subcats);
$smarty->assign('main', 'category/delete_confirmation');
} elseif ($mode == 'search') {
示例11: cw_user_get_usertypes
function cw_user_get_usertypes()
{
global $tables;
$ut = cw_query_column("SELECT distinct(usertype) FROM {$tables['customers']}");
$result = array();
foreach ($ut as $k => $v) {
$result[$v] = cw_get_langvar_by_name('lbl_user_' . $v, null, false, true);
if (empty($result[$v])) {
$result[$v] = $v . ' usertype';
}
}
return $result;
}
示例12: cw_load
<?php
cw_load('addons');
if ($action == 'update' && is_array($upd_addons)) {
db_query("update {$tables['addons']} set active='0' where status>'" . constant('ADDON_TYPE_CORE') . "'");
foreach ($upd_addons as $addon => $val) {
db_query("update {$tables['addons']} set active='1' where addon='{$addon}'");
}
$disabled = cw_query_column("select addon from {$tables['addons']} where active = 0");
db_query("update {$tables['addons']} set active=0 where parent in ('" . implode("', '", $disabled) . "')");
cw_header_location("index.php?target={$target}&mode=addons");
}
if ($action == 'ajax_update') {
db_query("update {$tables['addons']} set active=abs(active-1) where addon='{$addon}' and status>'" . constant('ADDON_TYPE_CORE') . "'");
$active = cw_query_first_cell("select active from {$tables['addons']} where addon='{$addon}'");
cw_add_ajax_block(array('id' => 'script', 'content' => '$("#' . $addon . '").removeClass("on").removeClass("off").addClass("' . ($active == 1 ? 'on' : 'off') . '");'));
cw_add_ajax_block(array('id' => 'script', 'content' => '$("[parent=' . $addon . ']").parent().removeClass("addon_locked")' . ($active == 1 ? '' : '.addClass("addon_locked")') . ';'));
}
$addon = $_GET['addon'];
if (!empty($addon) && $mode == 'addons') {
# kornev, TOFIX generally this should be removed
if (is_file($app_main_dir . '/addons/' . $addon . '/admin/settings.php')) {
cw_include('addons/' . $addon . '/admin/settings.php');
}
if ($REQUEST_METHOD == 'POST') {
cw_header_location("index.php?target={$target}&mode=addons&addon={$addon}");
}
$smarty->assign('addon', $addon);
$smarty->assign('addon_name', cw_get_langvar_by_name('addon_name_' . $addon));
$location[] = array(cw_get_langvar_by_name('lbl_addons'), 'index.php?target=' . $target);
$location[] = array($addon, '');
示例13: cw_salesman_get_commission
function cw_salesman_get_commission($products, $salesman, $membership_id, $doc_id, $warehouse, $applied_coupon = '', $applied_discount = '', $part = 100)
{
global $tables;
$salesman_commission_value = 0;
$salesman_plan = cw_query_first_cell($sql = "SELECT {$tables['salesman_commissions']}.plan_id FROM {$tables['salesman_commissions']}, {$tables['salesman_plans']}, {$tables['customers']} WHERE {$tables['salesman_commissions']}.plan_id={$tables['salesman_plans']}.plan_id AND {$tables['salesman_commissions']}.salesman_customer_id='{$salesman}' AND {$tables['customers']}.customer_id='{$salesman}' AND {$tables['customers']}.status='Y' AND {$tables['customers']}.status='Y' AND {$tables['salesman_plans']}.status=1");
if ($salesman_plan) {
$tmp = cw_query("SELECT * FROM {$tables['salesman_plans_commissions']} WHERE plan_id='{$salesman_plan}' and membership_id='" . $membership_id . "'");
$plan_info = array();
if ($tmp) {
foreach ($tmp as $v) {
$plan_info[$v['item_type'] . ($v['item_id'] > 0 ? $v['item_id'] : "")] = array("commission_type" => $v['commission_type'], "commission" => $v['commission']);
}
}
unset($tmp);
$products_hash = array();
foreach ($products as $k => $product) {
$percent_cost = $product['discounted_price'] / 100;
unset($to_salesman);
if ($plan_info["P" . $product['product_id']]) {
$to_salesman = $plan_info["P" . $product['product_id']]['commission'] * ($plan_info["P" . $product['product_id']]['commission_type'] == '$' ? $product['amount'] : $percent_cost);
}
#
# Check the categories commission rate
#
if (!isset($to_salesman)) {
$product_categories = cw_query_column("SELECT category_id FROM {$tables['products_categories']} WHERE product_id='{$product['product_id']}'");
foreach ($product_categories as $category_id) {
if (!isset($plan_info["C" . $category_id])) {
continue;
}
$tmp = $plan_info["C" . $category_id]['commission'] * ($plan_info["C" . $category_id]['commission_type'] == '$' ? $product['amount'] : $percent_cost);
if ($tmp > $to_salesman) {
$to_salesman = $tmp;
}
}
}
#
# Apply general value of the commission rate
#
if (!isset($to_salesman) && $plan_info['G']) {
$to_salesman = $plan_info['G']['commission'] * ($plan_info['G']['commission_type'] == '$' ? 1 : $percent_cost);
}
$salesman_commission_value += price_format($to_salesman);
$products_hash[$product['item_id']] = price_format($to_salesman);
}
# kornev, the comission can be calculated partially, if the order is paid partially
$salesman_commission_value = $salesman_commission_value * $part / 100;
# kornev, calculate the next levels only if we placed an order
# kornev, the level calculation has been changed. The comission is devided by the levels.
if ($salesman_commission_value && $doc_id) {
# kornev, if discount is taken from the salesman account
if (cw_is_salesman_coupon($applied_coupon)) {
$from_account = cw_query_first_cell("select from_account from {$tables['discount_coupons']} where coupon='{$applied_coupon}'");
if ($from_account) {
$salesman_commission_value -= $applied_discount;
}
//cw_get_salesman_discount($products, $applied_coupon, $membership_id, $warehouse);
}
$salesman_level = cw_get_affiliate_level($salesman);
$parents = array();
$parents[] = array('customer_id' => $salesman, 'level' => $salesman_level);
$__parents = cw_get_parents($salesman);
if (is_array($__parents)) {
$parents = array_merge($parents, $__parents);
}
$div_commission_value = $salesman_commission_value;
foreach ($parents as $v) {
$level = $v['level'];
if ($div_commission_value <= 0) {
continue;
}
$percent = cw_query_first_cell("SELECT commission FROM {$tables['salesman_tier_commissions']} WHERE level = '{$level}'");
$commission = price_format($div_commission_value * $percent / 100);
$div_commission_value -= $commission;
if ($commission > 0) {
db_query("INSERT INTO {$tables['salesman_payment']} (salesman_customer_id, doc_id, commissions, paid, affiliate, add_date) VALUES ('{$v['customer_id']}', '{$doc_id}', '{$commission}', 'N', '{$salesman}', '" . (isset($xaff_force_time) ? $xaff_force_time : time()) . "')");
foreach ($products_hash as $id => $c) {
$c = price_format($c * $percent / 100);
db_query("INSERT INTO {$tables['salesman_product_commissions']} (item_id, doc_id, product_commission, salesman_customer_id) VALUES ('{$id}', '{$doc_id}', '{$c}','{$v['customer_id']}')");
$products_hash[$id] -= $c;
}
}
}
}
}
return $salesman_commission_value;
}
示例14: cw_query_column
$discountbundles_pids = cw_query_column("SELECT objid FROM {$tables['bonuses']} b, {$tables['bonus_conditions']} bc WHERE b.pid='{$product_added}' AND b.bonusid=bc.bonusid AND bc.type='P'");
$pids_query['where'][] = $tables['products'] . ".productid IN ('" . implode($discountbundles_pids, "','") . "')";
$added_products = cw_search_products($pids_query, $userinfo['membershipid']);
} else {
$added_products[] = cw_select_product($product_added, $userinfo['membershipid']);
}
#cw_print_r($also_products);
$smarty->assign('product_added', $product_added);
$smarty->assign('added_products', $added_products);
$smarty->assign('also_products', $also_products);
unset($addons["Fast_Lane_Checkout"]);
include $xcart_dir . "/addons/Promotion_Suite/recently_viewed.php";
}
if ($mode == 'add' && !empty($productid) && $discountbundles == '1') {
$minimal_amount = cw_query_first_cell("SELECT min_amount FROM {$tables['products']} WHERE productid='{$productid}'");
$amount = max($amount, $minimal_amount);
$discountbundles_pids = cw_query_column("SELECT objid FROM {$tables['bonuses']} b, {$tables['bonus_conditions']} bc WHERE b.pid='{$productid}' AND b.bonusid=bc.bonusid AND bc.type='P' AND bc.objid!='{$productid}'");
foreach ($discountbundles_pids as $pid) {
#
# Add product to the cart
#
$add_product = array();
$add_product["productid"] = $pid;
$minimal_amount = cw_query_first_cell("SELECT min_amount FROM {$tables['products']} WHERE productid='{$pid}'");
$add_product["amount"] = max(1, $minimal_amount);
$add_product["product_options"] = "";
$add_product["special_offer"]["bundle_pid"] = $productid;
$result = cw_add_to_cart($cart, $add_product);
}
}
// CartWorks.com - Promotion Suite
示例15: cw_shipper
function cw_shipper($weight, $address, $debug = "N", $cart = false)
{
global $allowed_shipping_methods, $rates;
global $tables;
global $config;
$__intershipper_userinfo = $address;
$rates = array();
$intershipper_countries = array('IE' => 'IR', 'VA' => 'IT', 'FX' => 'FR', 'PR' => 'US');
#
# Intershipper depends on XML parser (EXPAT extension)
#
if (test_expat() == "") {
return;
}
if (empty($address)) {
if ($config['General']['apply_default_country'] == "Y" || $debug == "Y") {
$__intershipper_userinfo = cw_user_get_default_address();
} else {
return array();
}
}
$pounds = cw_weight_in_grams($weight) / 453;
$pounds = sprintf("%.2f", round((double) $pounds + 9.999999999999999E-12, 2));
if ($pounds < 0.1) {
$pounds = 0.1;
}
$servername = "www.intershipper.com";
$scriptname = "/Shipping/Intershipper/XML/v2.0/HTTP.jsp";
$username = $config['Shipping']['intershipper_username'];
$password = $config['Shipping']['intershipper_password'];
$delivery = $params['param00'];
$shipmethod = $params['param01'];
$CO = $config['Company']['country'];
$ZO = urlencode($config['Company']['zipcode']);
$CD = $__intershipper_userinfo['country'];
$ZD = urlencode($__intershipper_userinfo['zipcode']);
if (!empty($intershipper_countries[$CD])) {
$CD = $intershipper_countries[$CD];
}
if (!empty($intershipper_countries[$CO])) {
$CO = $intershipper_countries[$CO];
}
$__intershipper_userinfo['country'] = $CD;
$config['Company']['country'] = $CO;
$length = (double) $params['param02'];
$width = (double) $params['param03'];
$height = (double) $params['param04'];
$dunit = $params['param05'];
$packaging = $params['param06'];
$contents = $params['param07'];
$codvalue = (double) $params['param08'];
$insvalue = (double) $params['param09'];
$queryid = substr(uniqid(rand()), 0, 15);
$wunit = strtoupper(trim($config['General']['weight_symbol']));
if (strlen($wunit) > 2) {
$wunit = substr($wunit, 0, 2);
}
$allowed_shipping_methods = cw_query("SELECT * FROM {$tables['shipping']} WHERE active=1");
$carriers = cw_query_column("SELECT DISTINCT(code) FROM {$tables['shipping']} WHERE code<>'' AND intershipper_code!='' AND active=1");
if (!$carriers || !$username || !$password) {
return array();
}
$post[] = "Version=2.0.0.0";
$post[] = "ShipmentID=1";
$post[] = "QueryID=1";
$post[] = "Username={$username}";
$post[] = "Password={$password}";
$post[] = "TotalClasses=4";
$post[] = "ClassCode1=GND";
$post[] = "ClassCode2=1DY";
$post[] = "ClassCode3=2DY";
$post[] = "ClassCode4=3DY";
$post[] = "DeliveryType={$delivery}";
$post[] = "ShipMethod={$shipmethod}";
$post[] = "OriginationPostal={$ZO}";
$post[] = "OriginationCountry={$CO}";
$post[] = "DestinationPostal={$ZD}";
$post[] = "DestinationCountry={$CD}";
$post[] = "Currency=USD";
// Currently, supported only "USD". maxlen=3
$post[] = "TotalPackages=1";
$post[] = "BoxID1=box1";
$post[] = "Weight1={$pounds}";
$post[] = "WeightUnit1=LB";
$post[] = "Length1={$length}";
$post[] = "Width1={$width}";
$post[] = "Height1={$height}";
$post[] = "DimensionalUnit1={$dunit}";
// DimensionalUnit ::= CM | IN
$post[] = "Packaging1={$packaging}";
// Packaging ::= BOX | ENV | LTR | TUB
$post[] = "Contents1={$contents}";
$post[] = "Cod1={$codvalue}";
$post[] = "Insurance1={$insvalue}";
$post[] = "TotalCarriers=" . count($carriers);
foreach ($carriers as $k => $v) {
if ($v == 'CPC') {
$v = 'CAN';
}
$post[] = "CarrierCode" . ($k + 1) . "=" . $v;
//.........这里部分代码省略.........