当前位置: 首页>>代码示例>>PHP>>正文


PHP compute_discount_amount函数代码示例

本文整理汇总了PHP中compute_discount_amount函数的典型用法代码示例。如果您正苦于以下问题:PHP compute_discount_amount函数的具体用法?PHP compute_discount_amount怎么用?PHP compute_discount_amount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compute_discount_amount函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: order_fee


//.........这里部分代码省略.........
    /* 配送费用 */
    $shipping_cod_fee = NULL;
    if ($order['shipping_id'] > 0 && $total['real_goods_count'] > 0) {
        $region['country'] = $consignee['country'];
        $region['province'] = $consignee['province'];
        //$region['city']     = $consignee['city'];
        //$region['district'] = $consignee['district'];
        $shipping_info = shipping_area_info($order['shipping_id'], $region);
        if (!empty($shipping_info)) {
            if ($order['extension_code'] == 'group_buy') {
                $weight_price = cart_weight_price(CART_GROUP_BUY_GOODS);
            } else {
                $weight_price = cart_weight_price();
            }
            // 查看购物车中是否有免运费商品,若是则把运费赋为零 add by 2014-09-15 20:30*/
            //原来的是要全部商品都是免运费的才免运费:$sql = 'SELECT count(*) FROM ' . $ecs->table('cart') . " WHERE `session_id` = '" . SESS_ID. "' AND `extension_code` != 'package_buy' AND `is_shipping` = 0";
            $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE `session_id` = '" . SESS_ID . "' AND `extension_code` != 'package_buy' AND `is_shipping` = 1";
            $shipping_count = $GLOBALS['db']->getOne($sql);
            //获取运费
            $total['shipping_fee'] = ($shipping_count > 0 and $weight_price['free_shipping'] == 1) ? 0 : shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price['weight'], $total['goods_price'], $weight_price['number']);
            if (!empty($order['need_insure']) && $shipping_info['insure'] > 0) {
                $total['shipping_insure'] = shipping_insure_fee($shipping_info['shipping_code'], $total['goods_price'], $shipping_info['insure']);
            } else {
                $total['shipping_insure'] = 0;
            }
            if ($shipping_info['support_cod']) {
                $shipping_cod_fee = $shipping_info['pay_fee'];
            }
        }
    }
    $total['shipping_fee_formated'] = price_format($total['shipping_fee'], false);
    $total['shipping_insure_formated'] = price_format($total['shipping_insure'], false);
    // 购物车中的商品能享受红包支付的总额
    $bonus_amount = compute_discount_amount();
    // 红包和积分最多能支付的金额为商品总额
    $max_amount = $total['goods_price'] == 0 ? $total['goods_price'] : $total['goods_price'] - $bonus_amount;
    /* 计算订单总额 */
    if ($order['extension_code'] == 'group_buy' && $group_buy['deposit'] > 0) {
        $total['amount'] = $total['goods_price'];
    } 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);
            $total['amount'] -= $price = number_format($total['bonus_kill'], 2, '.', '');
            // 还需要支付的订单金额
        }
        $total['bonus'] = $use_bonus;
        $total['bonus_formated'] = price_format($total['bonus'], false);
        $total['amount'] -= $use_bonus;
        // 还需要支付的订单金额
        $max_amount -= $use_bonus;
        // 积分最多还能支付的金额
    }
    /* 余额 */
    $order['surplus'] = $order['surplus'] > 0 ? $order['surplus'] : 0;
    if ($total['amount'] > 0) {
        if (isset($order['surplus']) && $order['surplus'] > $total['amount']) {
            $order['surplus'] = $total['amount'];
            $total['amount'] = 0;
        } else {
            $total['amount'] -= floatval($order['surplus']);
        }
    } else {
开发者ID:dlpc,项目名称:ecshop,代码行数:67,代码来源:lib_order.php

示例2: foreach

     $smarty->display('order_done.dwt');
     exit;
 }
 /* 收货人信息 */
 foreach ($consignee as $key => $value) {
     $order[$key] = addslashes($value);
 }
 /* 订单中的总额 */
 $total = order_fee($order, $cart_goods, $consignee);
 $order['bonus'] = $total['bonus'];
 $order['goods_amount'] = $total['goods_price'];
 $order['discount'] = $total['discount'];
 $order['surplus'] = $total['surplus'];
 $order['tax'] = $total['tax'];
 // 购物车中的商品能享受抵扣券支付的总额
 $discount_amout = compute_discount_amount();
 // 抵扣券和积分最多能支付的金额为商品总额
 $temp_amout = $order['goods_amount'] - $discount_amout;
 if ($temp_amout <= 0) {
     $order['bonus_id'] = 0;
 }
 /* 配送方式 */
 if ($order['shipping_id'] > 0) {
     $shipping = shipping_info($order['shipping_id']);
     $order['shipping_name'] = addslashes($shipping['shipping_name']);
 }
 $order['shipping_fee'] = $total['shipping_fee'];
 $order['insure_fee'] = $total['shipping_insure'];
 /* 支付方式 */
 if ($order['pay_id'] > 0) {
     $payment = payment_info($order['pay_id']);
开发者ID:nanhuacrab,项目名称:ecshop,代码行数:31,代码来源:order.php

示例3: isset

 /* 代码增加_start  By  www.68ecshop.com */
 $order['best_time'] = isset($_POST['best_time']) ? trim($_POST['best_time']) : '';
 /* 代码增加_end  By  www.68ecshop.com */
 /*morestock_morecity 把配送方式的价钱算在里面*/
 $order['shipping_pay'][$ckey] = $_POST['pay_ship'][$ckey];
 /* 订单中的总额 */
 $total = order_fee($order, $cart_goods, $consignee);
 unset($order['shipping_pay'][$ckey]);
 //morestock_morecity 去掉这条信息以免影响下订单操作
 $order['bonus'] = $total['bonus'];
 $order['goods_amount'] = $total['goods_price'];
 $order['discount'] = $total['discount'];
 $order['surplus'] = $total['surplus'];
 $order['tax'] = $total['tax'];
 // 购物车中的商品能享受红包支付的总额
 $discount_amout = compute_discount_amount($ckey);
 // 红包和积分最多能支付的金额为商品总额
 $temp_amout = $order['goods_amount'] - $discount_amout;
 if ($temp_amout <= 0) {
     $order['bonus_id'] = 0;
 }
 /* 配送方式 */
 if ($order['shipping_id'] > 0) {
     $shipping = shipping_info($order['shipping_id']);
     $order['shipping_name'] = addslashes($shipping['shipping_name']);
     //如果是门店自提,订单需要做特殊标识
     if ($order['shipping_id'] == 4 || $order['shipping_name'] == '门店自提') {
         $order['is_pickup'] = $order['shipping_id'];
     }
 }
 $order['shipping_fee'] = $total['shipping_fee'];
开发者ID:moonlight-wang,项目名称:feilun,代码行数:31,代码来源:flow.php

示例4: order_fee


//.........这里部分代码省略.........
    }
    $total['shipping_fee_formated'] = price_format($total['shipping_fee'], false);
    $total['shipping_insure_formated'] = price_format($total['shipping_insure'], false);
    /* 代码增加_start  By  www.68ecshop.com */
    foreach ($goods as $val) {
        $sql_supp = "select g.supplier_id, IF(g.supplier_id='0', '本网站', s.supplier_name) AS supplier_name2 from " . $GLOBALS['ecs']->table('goods') . " AS g left join " . $GLOBALS['ecs']->table('supplier') . " AS s on g.supplier_id=s.supplier_id where g.goods_id='" . $val['goods_id'] . "' ";
        $row_supp = $GLOBALS['db']->getRow($sql_supp);
        $row_supp['supplier_id'] = $row_supp['supplier_id'] ? intval($row_supp['supplier_id']) : 0;
        $total['supplier_shipping'][$row_supp['supplier_id']]['supplier_name'] = $row_supp['supplier_name2'];
        $total['supplier_shipping'][$row_supp['supplier_id']]['goods_number'] += $val['goods_number'];
        $total['supplier_goodsnumber'][$row_supp['supplier_id']] += $val['goods_number'];
        $total['goods_price_supplier'][$row_supp['supplier_id']] += $val['goods_price'] * $val['goods_number'];
        if ($order['extension_code'] == 'group_buy') {
            $weight_price2 = cart_weight_price2(CART_GROUP_BUY_GOODS, $row_supp['supplier_id']);
        } else {
            $weight_price2 = cart_weight_price2(CART_GENERAL_GOODS, $row_supp['supplier_id']);
        }
        // 查看购物车中是否全为免运费商品,若是则把运费赋为零
        $sql_where = $_SESSION['user_id'] > 0 ? "c.user_id='" . $_SESSION['user_id'] . "' " : "c.session_id = '" . SESS_ID . "' AND c.user_id=0 ";
        $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('cart') . " AS c left join " . $GLOBALS['ecs']->table('goods') . " AS g on c.goods_id=g.goods_id WHERE g.supplier_id = '" . $row_supp['supplier_id'] . "' AND {$sql_where} AND c.extension_code != 'package_buy' AND c.is_shipping = 0 AND c.rec_id in (" . $_SESSION['sel_cartgoods'] . ")";
        //jx
        $shipping_count_supp = $GLOBALS['db']->getOne($sql);
        $total['supplier_shipping'][$row_supp['supplier_id']]['shipping_fee'] = ($shipping_count_supp == 0 and $weight_price2['free_shipping'] == 1) ? 0 : shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price2['weight'], $total['goods_price_supplier'][$row_supp['supplier_id']], $weight_price2['number']);
        $total['supplier_shipping'][$row_supp['supplier_id']]['formated_shipping_fee'] = price_format($total['supplier_shipping'][$row_supp['supplier_id']]['shipping_fee'], false);
    }
    krsort($total['supplier_shipping']);
    $total['shipping_fee'] = 0;
    foreach ($total['supplier_shipping'] as $supp_shipping) {
        $total['shipping_fee'] += $supp_shipping['shipping_fee'];
    }
    $total['shipping_fee_formated'] = price_format($total['shipping_fee'], false);
    /* 代码增加_end  By  www.68ecshop.com */
    // 购物车中的商品能享受红包支付的总额
    $bonus_amount = compute_discount_amount();
    // 红包和积分最多能支付的金额为商品总额
    $max_amount = $total['goods_price'] == 0 ? $total['goods_price'] : $total['goods_price'] - $bonus_amount;
    /* 计算订单总额 */
    if ($order['extension_code'] == 'group_buy' && $group_buy['deposit'] > 0) {
        $total['amount'] = $total['goods_price'];
    } 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);
            $total['amount'] -= $price = number_format($total['bonus_kill'], 2, '.', '');
            // 还需要支付的订单金额
        }
        $total['bonus'] = $use_bonus;
        $total['bonus_formated'] = price_format($total['bonus'], false);
        $total['amount'] -= $use_bonus;
        // 还需要支付的订单金额
        $max_amount -= $use_bonus;
        // 积分最多还能支付的金额
    }
    /* 余额 */
    $order['surplus'] = $order['surplus'] > 0 ? $order['surplus'] : 0;
    if ($total['amount'] > 0) {
        if (isset($order['surplus']) && $order['surplus'] > $total['amount']) {
            $order['surplus'] = $total['amount'];
            $total['amount'] = 0;
        } else {
            $total['amount'] -= floatval($order['surplus']);
        }
    } else {
开发者ID:seanguo166,项目名称:yinoos,代码行数:67,代码来源:lib_order.php

示例5: done


//.........这里部分代码省略.........
		
	
	    /* 订单中的商品 */
	    $cart_goods = cart_goods($flow_type);
	
	    if (empty($cart_goods))
	    {
	        $msg = rpcLang('flow.php', 'no_goods_in_cart');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    /* 检查商品总额是否达到最低限购金额 */
	    if ($flow_type == CART_GENERAL_GOODS && cart_amount(true, CART_GENERAL_GOODS) < $_CFG['min_goods_amount'])
	    {
			$msg = rpcLang('flow.php', 'goods_amount_not_enough');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    /* 收货人信息 */
	    foreach ($consignee as $key => $value)
	    {
	        $order[$key] = addslashes($value);
	    }
	
	    /* 订单中的总额 */
	    $total = order_fee($order, $cart_goods, $consignee);
	
	    $order['bonus']        = $total['bonus'];
	    $order['goods_amount'] = $total['goods_price'];
	    $order['discount']     = $total['discount'];
	    $order['surplus']      = $total['surplus'];
	    $order['tax']          = $total['tax'];
	    #购物车中的商品能享受红包支付的总额
	    $discount_amout = compute_discount_amount();
		#红包和积分最多能支付的金额为商品总额
	    $temp_amout = $order['goods_amount'] - $discount_amout;
		if ($temp_amout <= 0)
	    {
	        $order['bonus_id'] = 0;
	    }
	
	    /* 配送方式 */
	    if ($order['shipping_id'] > 0)
	    {
	        $shipping = shipping_info($order['shipping_id']);
	        $order['shipping_name'] = addslashes($shipping['shipping_name']);
	    }
	    $order['shipping_fee'] = $total['shipping_fee'];
	    $order['insure_fee']   = $total['shipping_insure'];
	
	    /* 支付方式 */
	    if ($order['pay_id'] > 0)
	    {
	        $payment = payment_info($order['pay_id']);
	        $order['pay_name'] = addslashes($payment['pay_name']);
	    }
	    $order['pay_fee'] = $total['pay_fee'];
	    $order['cod_fee'] = $total['cod_fee'];
	
	    /* 商品包装 */
	    if ($order['pack_id'] > 0)
	    {
	        $pack               = pack_info($order['pack_id']);
	        $order['pack_name'] = addslashes($pack['pack_name']);
	    }
	    $order['pack_fee'] = $total['pack_fee'];
开发者ID:noikiy,项目名称:mdwp,代码行数:67,代码来源:flow.action.php


注:本文中的compute_discount_amount函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。