ecshop购买流程简化

2010-07-17 12:18 来源:www.chinab4c.com 作者:admin

       ecshop购买流程,其实是非常复杂的,也非常的让人感觉很烦琐.为了让ecshop购买流程得到进一步的简化。我们可以通过对ecshop的flow.php程序进行改进.这样就能方便的让ecshop支持购买流程的优化

  1:flow.php加以下代码

         }elseif ($_REQUEST['step'] == 'list_shipping')

  include_once('includes/cls_json.php');

    $json = new JSON;
    $result = array('error' => '', 'content' => '', 'need_insure' => 0);
 /* 取得配送列表 */
 $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
  $string = trim($_REQUEST['string']);
 $ar = explode(",",$string);
    $region            = array($ar[0], $ar[1], $ar[2], $ar[3]);
    $_SESSION['flow_consignee'] = array();
 $consignee['country'] = $ar[0];
    $consignee['province']= $ar[1];
    $consignee['city']= $ar[2];
    $consignee['district']= $ar[3];
 $_SESSION['flow_consignee'] = stripslashes_deep($consignee);

    $cart_goods = cart_goods($flow_type); // 取得商品列表,计算合计
 $order = flow_order_info();
    $smarty->assign('order', $order);

    /* 计算折扣 */
    if ($flow_type != CART_EXCHANGE_GOODS && $flow_type != CART_GROUP_BUY_GOODS)
    {
        $discount = compute_discount();
        $smarty->assign('discount', $discount['discount']);
        $favour_name = empty($discount['name']) ? '' : join(',', $discount['name']);
        $smarty->assign('your_discount', sprintf($_LANG['your_discount'], $favour_name, price_format($discount['discount'])));
    }

    /*
     * 计算订单的费用
     */
    $total = order_fee($order, $cart_goods, $consignee);
    $smarty->assign('total', $total);

   
    $shipping_list     = available_shipping_list($region);
    $cart_weight_price = cart_weight_price($flow_type);
    $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('shipping_list',   $shipping_list);
    $smarty->assign('insure_disabled', $insure_disabled);
    $smarty->assign('cod_disabled',    $cod_disabled);
 $result[content] = $smarty->fetch('library/shipping.lbi');
 
 echo $json->encode($result);
    exit;
}

    2:flow.dwt里面把consignee.lbi内容拿过来.

  3:flow.php中增加下拉

   include_once('includes/lib_transaction.php');
  /* 取得购物类型 */
        $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;

        /*
         * 收货人信息填写界面
         */

     

        /* 取得国家列表、商店所在国家、商店所在国家的省列表 */
        $smarty->assign('country_list',       get_regions());
        $smarty->assign('shop_country',       $_CFG['shop_country']);
        $smarty->assign('shop_province_list', get_regions(1, $_CFG['shop_country']));

       通过以上程序的修改,可以达到对ecshop购买流程简单化.

  来源:http://www.chinab4c.com