ecshop详细页增加运费查询
2016-09-07 22:03 来源:www.chinab4c.com 作者:ecshop专家
大家在淘宝上看到产品到某某地 会出现相应的运费,若是ECSHOP,该如何增加该功能,chinab4c为大家分解!
1:flow.php增加以下代码 elseif ($_REQUEST['step'] == 'show_shipping1') {
include_once('includes/cls_json.php'); $json = new JSON; $result = array('error' => '', 'content' => '', 'need_insure' => 0); /*购买属性*/ $attr_id = isset($_REQUEST['attr']) ? explode(',', $_REQUEST['attr']) : array(); /*购买数量*/ $number = (isset($_REQUEST['number'])) ? intval($_REQUEST['number']) : 1; /*商品ID*/ $goods_id = (isset($_REQUEST['goods_id'])) ? intval($_REQUEST['goods_id']) : '0'; /*计算商品价格*/ $shop_price = get_final_price($goods_id, $number, true, $attr_id); $r = $db -> getRow("select * from ".$ecs->table('goods')." where goods_id = '$goods_id'"); /*取得商品总重量*/ $row['weight'] = floatval(($r['goods_weight']*$number)); /*取得商品总价格*/ $row['amount'] = floatval(($shop_price*$number)); /*购买数量*/ $row['number'] = intval($number);
/* 格式化重量 */ $row['formated_weight'] = formated_weight($row['weight']);
/*取得区域*/ $string = trim($_REQUEST['string']); $ar = explode(",",$string); $region = array($ar[0], $ar[1], $ar[2], $ar[3]); /*取得区域对应的配送方式*/ $shipping_list = available_shipping_list($region); $cart_weight_price =$row; $insure_disabled = true; $cod_disabled = true;
// 查看购物车中是否全为免运费商品,若是则把运费赋为零 $sql = 'SELECT count(*) FROM ' . $ecs->table('cart') . " WHERE `session_id` = '" . SESS_ID. "' AND `extension_code` != 'package_buy' AND `is_shipping` = 0"; $shipping_count = $db->getOne($sql);
foreach ($shipping_list AS $key => $val) { $shipping_cfg = unserialize_config($val['configure']); $shipping_fee = ($shipping_count == 0 AND $cart_weight_price['free_shipping'] == 1) ? 0 : shipping_fee($val['shipping_code'], unserialize($val['configure']), $cart_weight_price['weight'], $cart_weight_price['amount'], $cart_weight_price['number']);
$shipping_list[$key]['format_shipping_fee'] = price_format($shipping_fee, false); $shipping_list[$key]['shipping_fee'] = $shipping_fee; $shipping_list[$key]['free_money'] = price_format($shipping_cfg['free_money'], false); $shipping_list[$key]['insure_formated'] = strpos($val['insure'], '%') === false ? price_format($val['insure'], false) : $val['insure'];
/* 当前的配送方式是否支持保价 */ if ($val['shipping_id'] == $order['shipping_id']) { $insure_disabled = ($val['insure'] == 0); $cod_disabled = ($val['support_cod'] == 0); } } $smarty -> assign('list',$shipping_list); $result[content] = $smarty->fetch('library/goods_total.lbi'); //echo $json->encode($shipping_list); echo $json->encode($result); exit; }
(责任编辑:chinab4c) |
最近更新
常用插件
- ecshop最小购买数量控制插
ecshop最小购买数量控制插件,这个插件主要是为我们提供一个十分方便...
- ecshop2.7.2生成虚拟订单2.
以前我们开发过ecshop下的虚拟订单,就是客户在访问的时候,会自动生...
- ecshop2.7.1邮件发送插件
ecshop2.7.1邮件发送插件:该插件主要的开发思想是源于ecshop短信发送系统...
- ecshop没登陆情况下订单查
ecshop没登陆情况下订单查询插件,主要是针对ecshop在没有登陆的情况下...
- ecshop二次开发商品购买增
图片1香...