使用ecshop红包验证分析
2009-10-26 15:20 来源:www.chinab4c.com 作者:ecshop专家
ecshop红包的使用,有着非常的讲究,其实他的计算原则也非常复杂.而且,当你通过红包去抵消一定的购买金额的时候,牵涉到的计算流程也是非常烦琐的,ecshop的红包分好几类型。下面分析,如何进行ecshop红包验证的.
1:flow.php中.
$_REQUEST['step'] == '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['bonus_type_sn'] = $bonus['send_type'];//把他的红包的类型传递进去
//$result['b'] = $order['bonus_type_sn'];
}
这里是处理红包,并且传递给订单进行总金额计算的.
2:includes\lib_order.php中,函数order_fee($order, $goods, $consignee)是用来验证订单金额的.
/* 红包 */
if (!empty($order['bonus_id']))
{
$bonus = bonus_info($order['bonus_id']);
$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']);
$total['bonus_kill'] = $order['bonus_kill'];
$total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
}
上面是取得红包的值,进行优惠计算.
else
{
$total['amount'] = $total['goods_price'] - $total['discount'] + $total['tax'] + $total['pack_fee'] + $total['card_fee'] +
$total['shipping_fee'] + $total['shipping_insure'] + $total['cod_fee'];
// 减去红包金额
$use_bonus = min($total['bonus'], $max_amount); // 实际减去的红包金额
if(isset($total['bonus_kill']))
{
$use_bonus_kill = min($total['bonus_kill'], $max_amount);
if($order['bonus_type_sn'] == 5){
$sub = ($total['goods_price'] * $total['bonus_kill'])/100;//这里进行折扣的计算
$total['amount'] -= $price = number_format($sub, 2, '.', ''); // 还需要支付的订单金额
}else{
$total['amount'] -= $price = number_format($total['bonus_kill'], 2, '.', ''); // 还需要支付的订单金额
}
}
通过价格的重新统计。来重新调整价格的格式.从而达到了折扣的计算。
相关文章:
来源:中国B4C电子商务
最近更新
常用插件
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...