服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > ecshop教程 >

ecshop详细页增加运费查询

时间:2011-07-23 19:46来源:未知 作者:最模板 点击:
大家在淘宝上看到产品到某某地 会出现相应的运费,若是ECSHOP,该如何增加该功能,最模板为大家分解! 1:flow.php增加以下代码 elseif ($_REQUEST['step'] == 'show_shipping1') { include_once('includes

 大家在淘宝上看到产品到某某地 会出现相应的运费,若是ECSHOP,该如何增加该功能,最模板为大家分解!

 

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;

}

 

 

(责任编辑:最模板)

顶一下
(7)
63.6%
踩一下
(4)
36.4%
------分隔线----------------------------