大家在淘寶上看到產品到某某地 會出現相應的運費,若是ECSHOP,該如何增加該功能,A5為大家分解!
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;
}
新聞熱點
疑難解答