威尼斯娱乐

ecshop二次开发

ecshop二次开发

威尼斯娱乐 资讯中心 ecshop二次开发 ECSHOP商品快速购物功能,快速购买插件

ECSHOP商品快速购物功能,快速购买插件

时间:2020-12-21
功能实现在商品详细页面将商品快速购买后显示订单号,方便快捷的完成商品的购买流程支撑配送方式与支付方式后台可以设置订单状态1.把order_quick.php放到ecshop系统的目录下。2.把order.lbi放到模板我文件的library..
功能实现在商品详细页面将商品快速购买后显示订单号,方便快捷的完成商品的购买流程
支撑配送方式与支付方式
后台可以设置订单状态



 

1.把order_quick.php放到ecshop系统的目录下。


2.把order.lbi放到模板我文件的library目录下。

3.在把模板目录下的goods.dwt,适当的位置引用库order.lbi
大概可以看到雏形了,不过样式上还得自己修改。

 

 

其中order_quick.php文件的内容:

 


define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
require(ROOT_PATH . 'includes/lib_order.php');
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/shopping_flow.php');


//-- PROCESSOR

if ($_GET['act'] == 'order')
{
   
    //-- 添加商品到购物车
   
    include_once('includes/cls_json.php');
    $_POST['goods'] = json_str_iconv($_POST['goods']);
 
    if (!empty($_REQUEST['goods_id']) && empty($_POST['goods']))
    {
        if (!is_numeric($_REQUEST['goods_id']) || intval($_REQUEST['goods_id']) <= 0)
        {
            ecs_header("Location:./n");
        }
        $goods_id = intval($_REQUEST['goods_id']);
        exit;
    }

    $result = array('error' => 0, 'message' => '', 'content' => '', 'goods_id' => '');
    $json  = new JSON;
  $goods = $json->decode($_POST['goods']);
  
  
   
  $spec_arr     = $goods->spec_arr;
  $goods_id     = $goods->goods_id;
  $number       = $goods->number;
  $country      = $goods->country;
  $province     = $goods->province;
  $city         = $goods->city;
  $consignee    = $goods->consignee;
  $email        = $goods->email;
  $address       = $goods->address;
  $zipcode      = $goods->zipcode;
  $tel         = $goods->tel;
  $mobile      = $goods->mobile;
  $sign_building   = $goods->sign_building;
  $best_time      = $goods->best_time;
  $postscript     = $goods->postscript;
  $shipping_add   = $goods->shipping;
  $fee     = $goods->fee;
  $payment_add    = $goods->payment;


  
  
  $sql = "SELECT goods_number,goods_name,goods_sn,market_price,shop_price "." FROM " .$GLOBALS['ecs']->table('goods'). " WHERE goods_id = ".$goods_id;
  $row = $GLOBALS['db']->getRow($sql);
    if ($goods->number > $row['goods_number'])
    {
        $result['error']    = ERR_OUT_OF_STOCK;
        $result['goods_id'] = $goods->goods_id;
    $result['error']    = 2;
        $result['message']  = $_LANG['shortage'];
    die($json->encode($result));
    }
    else
    {
  
  //  $spec_price             = spec_price($spec);
   $goods_price            = get_final_price($goods_id, 1, true, $spec_arr);
   $goods_amount           = $goods_price*$number;
  //  $goods['market_price'] += $spec_price;
   $goods_attr             = get_goods_attr_info($spec_arr);
   $goods_attr_id          = join(',', $spec_arr);
   $order = array(
     'order_sn'      => get_order_sn(),
     'order_status'  => 0,
     'pay_status'    => 0,
     'user_id'       => 0,
     'consignee'     => $consignee,
     'country'       => $country,
     'province'      => $province,
     'city'          => $city,
     'email'         => $email,
     'address'       => $address,
     'zipcode'       => $zipcode,
     'tel'           => $tel,
     'mobile'        => $mobile,
     'sign_building' => $sign_building,
     'best_time'     => $best_time,     
     'add_time'      => gmtime(),
     'goods_amount'  => $goods_amount,
     'goods_id'      => $goods_id,  //
     'goods_name'    => $row['goods_name'],
     'goods_sn'      => $row['goods_sn'],
     'goods_number'  => $number,
     'market_price'  => $row['market_price'],
     'goods_price'   => $goods_price,
     'goods_attr'    => $goods_attr,
     'postscript'    => $postscript  
     );     
  
    $order['order_sn'] = get_order_sn(); //获取新订单号
    $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), $order, 'INSERT');
    
    while ($error_no == 1062); //如果是订单号重复则重新提交数据
    $new_order_id = $db->insert_id();
   $order['order_id'] = $new_order_id;   
  $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_goods'), $order, 'INSERT');
  $sql="select pay_fee,pay_id,pay_name from " . $GLOBALS['ecs']->table('payment') . " where pay_id=".$payment_add;
  
  //配送方式
  $sql = 'SELECT s.shipping_id,s.shipping_code, s.shipping_name, ' .
                's.shipping_desc, s.insure, s.support_cod, a.configure ' .
            'FROM ' . $GLOBALS['ecs']->table('shipping') . ' AS s, ' .
                $GLOBALS['ecs']->table('shipping_area') . ' AS a, ' .
                $GLOBALS['ecs']->table('area_region') . ' AS r ' .
            "WHERE s.shipping_id = '$shipping_add' " .
            'AND r.shipping_area_id = a.shipping_area_id AND a.shipping_id = s.shipping_id AND s.enabled = 1';
      $row = $GLOBALS['db']->getRow($sql);

  if (!empty($row))
  { 
   $s_config['shipping_id']=$shipping_add;
   $s_config['fee']=$fee;
   $sql="select shipping_name from " . $GLOBALS['ecs']->table('shipping') . " where shipping_id=".$shipping_add;
   $s_config['shipping_name']=$GLOBALS['db']->getOne($sql);
   $shipping_config = unserialize_config($row['configure']);
   if (isset($shipping_config['pay_fee']))
   {
    if (strpos($shipping_config['pay_fee'], '%') !== false)
    {
     $row['pay_fee'] = floatval($shipping_config['pay_fee']) . '%';
    }
    else
    {
      $row['pay_fee'] = floatval($shipping_config['pay_fee']);
    }
   }
   else
   {
    $row['pay_fee'] = 0.00;
   }
   $s_config['pay_fee']=$row['pay_fee'];
  }
  $sql="update " . $GLOBALS['ecs']->table('order_info') . " set shipping_name='" . $s_config['shipping_name'] . "' , shipping_id =" . $s_config['shipping_id'] . "  , shipping_fee=". $s_config['fee'] . " where order_sn=".$order['order_sn'];
  $res = $GLOBALS['db']->query($sql);
  //支付方式
  $sql="select * from " . $GLOBALS['ecs']->table('payment') . " where pay_id=".$payment_add;
  $p_ment=$GLOBALS['db']->getRow($sql);
  $p_ment_row['pay_fee']  = $p_ment['pay_fee'];
  $p_ment_row['pay_id']  = $p_ment['pay_id'];
  $p_ment_row['pay_name']     = $p_ment['pay_name'];
  $sql="select shipping_fee,goods_amount from " . $GLOBALS['ecs']->table('order_info') . " where order_sn=".$order['order_sn'];
  $p_info=$GLOBALS['db']->getRow($sql);
  $p_info_row['shipping_fee'] = $p_info['shipping_fee'];
  $p_info_row['goods_amount'] = $p_info['goods_amount'];
  if(mb_substr($p_ment['pay_fee'],-1,1)=='%')
  {
   $pay_fee_bai=mb_substr($p_ment['pay_fee'],0,-1);
   $p_ment_row['pay_fee']=round(($p_info_row['shipping_fee']+$p_info_row['goods_amount'])*(($pay_fee_bai+0.023)/100),2); 
  }
  else
  {$p_ment_row['pay_fee']=$p_ment_row['pay_fee'];}
  $sql="update " . $GLOBALS['ecs']->table('order_info') . " set pay_id=" . $p_ment_row['pay_id'] . " , pay_name ='" . $p_ment_row['pay_name'] . "'     , pay_fee=". $p_ment_row['pay_fee'] . " , goods_amount =".$p_info_row['goods_amount'] . " where order_sn=".$order['order_sn'];
  $res = $GLOBALS['db']->query($sql);
  
本文网址:/news/1062.html
0
QQ在线客服在线客服
用手机扫描二维码 关闭
二维码
XML 地图 | Sitemap 地图