本文整理汇总了PHP中cart_weight_price函数的典型用法代码示例。如果您正苦于以下问题:PHP cart_weight_price函数的具体用法?PHP cart_weight_price怎么用?PHP cart_weight_price使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cart_weight_price函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: flow_order_info
*/
$order = flow_order_info();
$smarty->assign('order', $order);
$_LANG['shopping_money'] = '购物金额小计 %s';
$_LANG['than_market_price'] = '比市场价 %s 节省了 %s (%s)';
/*
* 计算订单的费用
*/
$total = order_fee($order, $cart_goods, $consignee);
$smarty->assign('shopping_money', sprintf($_LANG['shopping_money'], $total['formated_goods_price']));
$smarty->assign('market_price_desc', sprintf($_LANG['than_market_price'], $total['formated_market_price'], $total['formated_saving'], $total['save_rate']));
$smarty->assign('total', $total);
/* 取得配送列表 */
$region = array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district']);
$shipping_list = available_shipping_list($region);
$cart_weight_price = cart_weight_price($flow_type);
$insure_disabled = true;
$cod_disabled = true;
// 查看购物车中是否全为免运费商品,若是则把运费赋为零
$sql = 'SELECT count(*) FROM ' . $ecs->table('cart') . " WHERE `session_id` = '" . SESS_ID . "' AND `extension_code` != 'package_buy' AND `is_shipping` = 0";
$shipping_count = $db->getOne($sql);
foreach ($shipping_list as $key => $val) {
$shipping_cfg = unserialize_config($val['configure']);
$shipping_fee = ($shipping_count == 0 and $cart_weight_price['free_shipping'] == 1) ? 0 : shipping_fee($val['shipping_code'], unserialize($val['configure']), $cart_weight_price['weight'], $cart_weight_price['amount'], $cart_weight_price['number']);
$shipping_list[$key]['format_shipping_fee'] = price_format($shipping_fee, false);
$shipping_list[$key]['shipping_fee'] = $shipping_fee;
$shipping_list[$key]['free_money'] = price_format($shipping_cfg['free_money'], false);
$shipping_list[$key]['insure_formated'] = strpos($val['insure'], '%') === false ? price_format($val['insure'], false) : $val['insure'];
}
$smarty->assign('shipping_list', $shipping_list);
$smarty->assign('insure_disabled', $insure_disabled);
示例3: checkout
//.........这里部分代码省略.........
$smarty->assign('allow_edit_cart', 0);
}
else
{
$smarty->assign('allow_edit_cart', 1);
}
#取得购物流程设置
$smarty->assign('config', $_CFG);
*/
/*
* 取得订单信息
*/
$order = flow_order_info();
/* 计算折扣 */
if ($flow_type != CART_EXCHANGE_GOODS && $flow_type != CART_GROUP_BUY_GOODS)
{
$discount = compute_discount();
}
/*
* 计算订单的费用
*/
$total = order_fee($order, $cart_goods, $consignee);
#取得配送列表
$region = array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district']);
#快递方式集合
$shipping_list = available_shipping_list($region);
#购物车重量
$cart_weight_price = cart_weight_price($flow_type);
$insure_disabled = true;
$cod_disabled = true;
#查看购物车中是否全为免运费商品,若是则把运费赋为零s
$sql = 'SELECT count(*) FROM ' . $ecs->table('cart') . " WHERE `session_id` = '" . SESS_ID. "' AND `extension_code` != 'package_buy' AND `is_shipping` = 0";
$shipping_count = $db->getOne($sql);
foreach ($shipping_list AS $key => $val)
{
$shipping_cfg = unserialize_config($val['configure']);
$shipping_fee = ($shipping_count == 0 AND $cart_weight_price['free_shipping'] == 1) ? 0 : shipping_fee($val['shipping_code'], unserialize($val['configure']),
$cart_weight_price['weight'], $cart_weight_price['amount'], $cart_weight_price['number']);
$shipping_list[$key]['format_shipping_fee'] = price_format($shipping_fee, false);
$shipping_list[$key]['shipping_fee'] = $shipping_fee;
$shipping_list[$key]['free_money'] = price_format($shipping_cfg['free_money'], false);
$shipping_list[$key]['insure_formated'] = strpos($val['insure'], '%') === false ?
price_format($val['insure'], false) : $val['insure'];
#当前的配送方式是否支持保价
if ($val['shipping_id'] == $order['shipping_id'])
{
$insure_disabled = ($val['insure'] == 0);
$cod_disabled = ($val['support_cod'] == 0);
}
}
#取得支付列表
if ($order['shipping_id'] == 0)
{
$cod = true;
$cod_fee = 0;
}
else
示例4: 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'] . ")";
//.........这里部分代码省略.........
示例5: 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)
{
//echo "<pre>";print_r($consignee);echo "</pre>";exit;
$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']++;
}
/*K金的兑礼不计入总费用 bisc*/
if ($val['is_integral'] == 1) {
if ($val['cat_id'] != 4) {
$total['gifts_integral'] += $val['integral'] * $val['goods_number'];
} else {
$total['goods_integral'] += $val['goods_price'] * $val['goods_number'];
}
} else {
$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);
/* 折扣$NowDiscount */
$discount = compute_discount();
$total['discount'] = $discount['discount'];
$total['discount_formated'] = price_format($total['discount'], 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);
/* 配送费用 */
$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)) {
$weight_price = cart_weight_price();
if ($consignee['province'] == '502') {
$sql = "select shipping_fee from ecs_shipping_fee where locate(address,'" . $consignee['address'] . "') >0 ";
$fee = $GLOBALS['db']->getOne($sql);
$total['shipping_fee'] = $fee ? $fee : shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price['weight'], $total['goods_price']);
} else {
$total['shipping_fee'] = shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price['weight'], $total['goods_price']);
}
}
}
$total['shipping_fee_formated'] = price_format($total['shipping_fee'], false);
$total['shipping_insure_formated'] = price_format($total['shipping_insure'], false);
// 红包和积分最多能支付的金额为商品总额
$max_amount = $total['goods_price'];
/*储值卡金额*/
if (!empty($order['surplus'])) {
$total['surplus'] = $order['surplus'];
}
$total['surplus_formated'] = price_format($total['surplus'], false);
/* 计算订单总额 */
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);
// 实际减去的红包金额
$total['bonus'] = $use_bonus;
$total['bonus_formated'] = price_format($total['bonus'], false);
$total['amount'] -= $use_bonus;
// 还需要支付的订单金额
$max_amount -= $use_bonus;
// 积分最多还能支付的金额
//减去储值卡金额
$total['amount'] -= $order['surplus'];
}
/* 积分 */
$order['integral'] = $order['integral'] > 0 ? $order['integral'] : 0;
if ($total['amount'] > 0 && $max_amount > 0 && $order['integral'] > 0) {
$integral_money = value_of_integral($order['integral']);
$use_integral = min($total['amount'], $max_amount, $integral_money);
// 实际使用积分支付的金额
$total['integral_money'] = $use_integral;
//.........这里部分代码省略.........