本文整理汇总了PHP中card_fee函数的典型用法代码示例。如果您正苦于以下问题:PHP card_fee函数的具体用法?PHP card_fee怎么用?PHP card_fee使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了card_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);
//获取运费
//.........这里部分代码省略.........
示例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'] . ")";
//.........这里部分代码省略.........