ecshop中验证红包的两种方式

2009-11-03 09:53 来源:www.chinab4c.com 作者:ecshop专家

   ecshop电子商务系统,在购买的时候,提交订单的checkout动作中,可以有两种验证红包的方式。

   1:<select name="bonus" onchange="changeBonus(this.value)" id="ECS_BONUS" style="border:1px solid #ccc;">这种下拉的onchange方式.

   2:  {$lang.input_bonus_no}
                <input name="bonus_sn" type="text" class="inputBg" size="15" />
                <input name="validate_bonus" type="button" class="bnt_blue_1" value="{$lang.validate_bonus}" onclick="validateBonus(document.forms['theForm'].elements['bonus_sn'].value)" style="vertical-align:middle;" />

   这种就是输入红包编号,进行验证的。在flow.php中的change_bonus中,通过传递过来的红包编号

   $bonus = bonus_info(intval($_GET['bonus']));

        if ((!empty($bonus) && $bonus['user_id'] == $_SESSION['user_id']) || $_GET['bonus'] == 0)
        {
            $order['bonus_id'] = $_GET['bonus'];
        }
        else
        {
            $order['bonus_id'] = 0;
            $result['error'] = $_LANG['invalid_bonus'];
        }

       来取得红包的id.

       而在flow.php中的validate_bonus动作中,通过$bonus_sn = trim($_REQUEST['bonus_sn']);//红包编号    $bonus = bonus_info(0, $bonus_sn);//取得红包信息。通过计算红包的价格。
 

    if ((!empty($bonus) && $bonus['user_id'] == $_SESSION['user_id']) || $bonus_kill == 0)
        {
            $order['bonus_kill'] = $bonus['type_money'];
   //增加折扣红包类型
            $order['send_type'] = $bonus['send_type'];
          
        }
        else
        {
            $order['bonus_kill'] = 0;
            $result['error'] = $_LANG['invalid_bonus'];
        }

      把红包的价值传递给计费函数。

      他们都把$order变量传递给计算费用的函数order_fee()

      下面代码是通过下拉的红包ID来验证的

      /* 红包 */

    if (!empty($order['bonus_id']))
    {
        $bonus          = bonus_info($order['bonus_id']);
        //这里是用户折扣红包
        if($bonus['send_type'] == 5){
         $total['bonus'] = ((100-$bonus['type_money'])*$total['goods_price'])/100;
        }else{
          $total['bonus'] = $bonus['type_money'];
        }
    }
    $total['bonus_formated'] = price_format($total['bonus'], false);

   下面的代码是通过输入红包编号来验证的

    /* 线下红包 */
     if (!empty($order['bonus_kill']))
    {
        $bonus          = bonus_info(0,$order['bonus_kill']);
      
        if($order['send_type'] == 5){//折扣红包
         $total['bonus_kill'] = ((100-$order['bonus_kill'])*$total['goods_price'])/100;
        }else{
          $total['bonus_kill'] = $order['bonus_kill'];
        }
        $total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
    }

   相关文章:

   使用ecshop红包验证分析 

  ecshop团购倒计时放在首页 
    来源:中国B4C电子商务