當前位置: 首頁>>代碼示例>>PHP>>正文


PHP pack_fee函數代碼示例

本文整理匯總了PHP中pack_fee函數的典型用法代碼示例。如果您正苦於以下問題:PHP pack_fee函數的具體用法?PHP pack_fee怎麽用?PHP pack_fee使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了pack_fee函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: order_fee

/**
 * 獲得訂單中的費用信息
 *
 * @access  public
 * @param   array   $order
 * @param   array   $goods
 * @param   array   $consignee
 * @param   bool    $is_gb_deposit  是否團購保證金(如果是,應付款金額隻計算商品總額和支付費用,可以獲得的積分取 $gift_integral)
 * @return  array
 */
function order_fee($order, $goods, $consignee)
{
    /* 初始化訂單的擴展code */
    if (!isset($order['extension_code'])) {
        $order['extension_code'] = '';
    }
    if ($order['extension_code'] == 'group_buy') {
        $group_buy = group_buy_info($order['extension_id']);
    }
    $total = array('real_goods_count' => 0, 'gift_amount' => 0, 'goods_price' => 0, 'market_price' => 0, 'discount' => 0, 'pack_fee' => 0, 'card_fee' => 0, 'shipping_fee' => 0, 'shipping_insure' => 0, 'integral_money' => 0, 'bonus' => 0, 'surplus' => 0, 'cod_fee' => 0, 'pay_fee' => 0, 'tax' => 0);
    $weight = 0;
    /* 商品總價 */
    foreach ($goods as $val) {
        /* 統計實體商品的個數 */
        if ($val['is_real']) {
            $total['real_goods_count']++;
        }
        $total['goods_price'] += $val['goods_price'] * $val['goods_number'];
        $total['market_price'] += $val['market_price'] * $val['goods_number'];
    }
    $total['saving'] = $total['market_price'] - $total['goods_price'];
    $total['save_rate'] = $total['market_price'] ? round($total['saving'] * 100 / $total['market_price']) . '%' : 0;
    $total['goods_price_formated'] = price_format($total['goods_price'], false);
    $total['market_price_formated'] = price_format($total['market_price'], false);
    $total['saving_formated'] = price_format($total['saving'], false);
    /* 折扣 */
    if ($order['extension_code'] != 'group_buy') {
        $discount = compute_discount();
        $total['discount'] = $discount['discount'];
        if ($total['discount'] > $total['goods_price']) {
            $total['discount'] = $total['goods_price'];
        }
    }
    $total['discount_formated'] = price_format($total['discount'], false);
    /* 稅額 */
    if (!empty($order['need_inv']) && $order['inv_type'] != '') {
        /* 查稅率 */
        $rate = 0;
        foreach ($GLOBALS['_CFG']['invoice_type']['type'] as $key => $type) {
            if ($type == $order['inv_type']) {
                $rate = floatval($GLOBALS['_CFG']['invoice_type']['rate'][$key]) / 100;
                break;
            }
        }
        if ($rate > 0) {
            $total['tax'] = $rate * $total['goods_price'];
        }
    }
    $total['tax_formated'] = price_format($total['tax'], false);
    /* 包裝費用 */
    if (!empty($order['pack_id'])) {
        $total['pack_fee'] = pack_fee($order['pack_id'], $total['goods_price']);
    }
    $total['pack_fee_formated'] = price_format($total['pack_fee'], false);
    /* 賀卡費用 */
    if (!empty($order['card_id'])) {
        $total['card_fee'] = card_fee($order['card_id'], $total['goods_price']);
    }
    $total['card_fee_formated'] = price_format($total['card_fee'], false);
    /* 紅包 */
    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);
    }
    /* 配送費用 */
    $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);
            //獲取運費
//.........這裏部分代碼省略.........
開發者ID:dlpc,項目名稱:ecshop,代碼行數:101,代碼來源:lib_order.php

示例2: order_fee

/**
 * 獲得訂單中的費用信息
 *
 * @access  public
 * @param   array   $order
 * @param   array   $goods
 * @param   array   $consignee
 * @param   bool    $is_gb_deposit  是否團購保證金(如果是,應付款金額隻計算商品總額和支付費用,可以獲得的積分取 $gift_integral)
 * @return  array
 */
function order_fee($order, $goods, $consignee)
{
    /* 初始化訂單的擴展code */
    if (!isset($order['extension_code'])) {
        $order['extension_code'] = '';
    }
    if ($order['extension_code'] == 'group_buy') {
        $group_buy = group_buy_info($order['extension_id']);
    }
    $total = array('real_goods_count' => 0, 'gift_amount' => 0, 'goods_price' => 0, 'market_price' => 0, 'discount' => 0, 'pack_fee' => 0, 'card_fee' => 0, 'shipping_fee' => 0, 'shipping_insure' => 0, 'integral_money' => 0, 'bonus' => 0, 'surplus' => 0, 'cod_fee' => 0, 'pay_fee' => 0, 'tax' => 0);
    $weight = 0;
    /* 商品總價 */
    foreach ($goods as $val) {
        /* 統計實體商品的個數 */
        if ($val['is_real']) {
            $total['real_goods_count']++;
        }
        $total['goods_price'] += $val['goods_price'] * $val['goods_number'];
        $total['market_price'] += $val['market_price'] * $val['goods_number'];
    }
    $total['saving'] = $total['market_price'] - $total['goods_price'];
    $total['save_rate'] = $total['market_price'] ? round($total['saving'] * 100 / $total['market_price']) . '%' : 0;
    $total['goods_price_formated'] = price_format($total['goods_price'], false);
    $total['market_price_formated'] = price_format($total['market_price'], false);
    $total['saving_formated'] = price_format($total['saving'], false);
    /* 折扣 */
    if ($order['extension_code'] != 'group_buy') {
        $discount = compute_discount(isset($order['supplier_id']) ? $order['supplier_id'] : -1);
        $total['discount'] = $discount['discount'];
        if ($total['discount'] > $total['goods_price']) {
            $total['discount'] = $total['goods_price'];
        }
    }
    $total['discount_formated'] = price_format($total['discount'], false);
    /* 稅額 */
    if (!empty($order['need_inv']) && $order['inv_type'] != '') {
        /* 查稅率 */
        $rate = 0;
        foreach ($GLOBALS['_CFG']['invoice_type']['type'] as $key => $type) {
            if ($type == $order['inv_type']) {
                $rate = floatval($GLOBALS['_CFG']['invoice_type']['rate'][$key]) / 100;
                break;
            }
        }
        if ($rate > 0) {
            $total['tax'] = $rate * $total['goods_price'];
        }
    }
    $total['tax_formated'] = price_format($total['tax'], false);
    /* 包裝費用 */
    if (!empty($order['pack_id'])) {
        $total['pack_fee'] = pack_fee($order['pack_id'], $total['goods_price']);
    }
    $total['pack_fee_formated'] = price_format($total['pack_fee'], false);
    /* 賀卡費用 */
    if (!empty($order['card_id'])) {
        $total['card_fee'] = card_fee($order['card_id'], $total['goods_price']);
    }
    $total['card_fee_formated'] = price_format($total['card_fee'], false);
    /* 紅包 */
    $total['bonus'] = 0;
    if (!empty($order['bonus_id'])) {
        $bonus = bonus_info($order['bonus_id']);
        $total['bonus'] = $bonus['type_money'];
    }
    /* 線下紅包 */
    if (!empty($order['bonus_sn'])) {
        $bonus = bonus_info(0, $order['bonus_sn']);
        $total['bonus'] += $bonus['type_money'];
        //$total['bonus_kill'] = $order['bonus_kill'];
        //$total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
    }
    $total['bonus_formated'] = price_format($total['bonus'], false);
    /* 配送費用 */
    $shipping_cod_fee = NULL;
    $sql_where = $_SESSION['user_id'] > 0 ? "user_id='" . $_SESSION['user_id'] . "' " : "session_id = '" . SESS_ID . "' AND user_id=0 ";
    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();
            }
            // 查看購物車中是否全為免運費商品,若是則把運費賦為零
            $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE  {$sql_where} AND `extension_code` != 'package_buy' AND `is_shipping` = 0 AND rec_id in (" . $_SESSION['sel_cartgoods'] . ")";
//.........這裏部分代碼省略.........
開發者ID:seanguo166,項目名稱:yinoos,代碼行數:101,代碼來源:lib_order.php


注:本文中的pack_fee函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。