本文整理汇总了PHP中formated_weight函数的典型用法代码示例。如果您正苦于以下问题:PHP formated_weight函数的具体用法?PHP formated_weight怎么用?PHP formated_weight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formated_weight函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cart_weight_price
/**
* 获得购物车中商品的总重量、总价格、总数量
*
* @access public
* @param int $type 类型:默认普通商品
* @return array
*/
function cart_weight_price($type = CART_GENERAL_GOODS)
{
$package_row['weight'] = 0;
$package_row['amount'] = 0;
$package_row['number'] = 0;
$packages_row['free_shipping'] = 1;
/* 获得购物车中非超值礼包商品的总重量 */
$sql = 'SELECT SUM(g.goods_weight * c.goods_number) AS weight, ' . 'SUM(c.goods_price * c.goods_number) AS amount, ' . 'SUM(c.goods_number) AS number ' . 'FROM ' . $this->pre . 'cart AS c ' . 'LEFT JOIN ' . $this->pre . 'goods AS g ON g.goods_id = c.goods_id ' . "WHERE c.session_id = '" . SESS_ID . "' " . "AND rec_type = '{$type}' AND g.is_shipping = 0";
$row = $this->row($sql);
$packages_row['weight'] = floatval($row['weight']) + $package_row['weight'];
$packages_row['amount'] = floatval($row['amount']) + $package_row['amount'];
$packages_row['number'] = intval($row['number']) + $package_row['number'];
/* 格式化重量 */
$packages_row['formated_weight'] = formated_weight($packages_row['weight']);
return $packages_row;
}
开发者ID:noikiy,项目名称:shop-3,代码行数:23,代码来源:OrderModel.class.php
示例2: cart_weight_price
/**
* 获得购物车中商品的总重量、总价格、总数量
*
* @access public
* @param int $type 类型:默认普通商品
* @return array
*/
function cart_weight_price($type = CART_GENERAL_GOODS)
{
$package_row['weight'] = 0;
$package_row['amount'] = 0;
$package_row['number'] = 0;
$packages_row['free_shipping'] = 1;
/* 计算超值礼包内商品的相关配送参数 */
$sql = 'SELECT goods_id, goods_number, goods_price FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE extension_code = 'package_buy' AND session_id = '" . SESS_ID . "'";
$row = $GLOBALS['db']->getAll($sql);
if ($row) {
$packages_row['free_shipping'] = 0;
$free_shipping_count = 0;
foreach ($row as $val) {
// 如果商品全为免运费商品,设置一个标识变量
$sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('package_goods') . ' AS pg, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE g.goods_id = pg.goods_id AND g.is_shipping = 0 AND pg.package_id = '" . $val['goods_id'] . "'";
$shipping_count = $GLOBALS['db']->getOne($sql);
if ($shipping_count > 0) {
// 循环计算每个超值礼包商品的重量和数量,注意一个礼包中可能包换若干个同一商品
$sql = 'SELECT SUM(g.goods_weight * pg.goods_number) AS weight, ' . 'SUM(pg.goods_number) AS number FROM ' . $GLOBALS['ecs']->table('package_goods') . ' AS pg, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE g.goods_id = pg.goods_id AND g.is_shipping = 0 AND pg.package_id = '" . $val['goods_id'] . "'";
$goods_row = $GLOBALS['db']->getRow($sql);
$package_row['weight'] += floatval($goods_row['weight']) * $val['goods_number'];
$package_row['amount'] += floatval($val['goods_price']) * $val['goods_number'];
$package_row['number'] += intval($goods_row['number']) * $val['goods_number'];
} else {
$free_shipping_count++;
}
}
$packages_row['free_shipping'] = $free_shipping_count == count($row) ? 1 : 0;
}
/* 获得购物车中非超值礼包商品的总重量 */
$sql = 'SELECT SUM(g.goods_weight * c.goods_number) AS weight, ' . 'SUM(c.goods_price * c.goods_number) AS amount, ' . 'SUM(c.goods_number) AS number ' . 'FROM ' . $GLOBALS['ecs']->table('cart') . ' AS c ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = c.goods_id ' . "WHERE c.session_id = '" . SESS_ID . "' " . "AND rec_type = '{$type}' AND g.is_shipping = 0 AND c.extension_code != 'package_buy'";
$row = $GLOBALS['db']->getRow($sql);
$packages_row['weight'] = floatval($row['weight']) + $package_row['weight'];
$packages_row['amount'] = floatval($row['amount']) + $package_row['amount'];
$packages_row['number'] = intval($row['number']) + $package_row['number'];
/* 格式化重量 */
$packages_row['formated_weight'] = formated_weight($packages_row['weight']);
return $packages_row;
}
开发者ID:dlpc,项目名称:ecshop,代码行数:46,代码来源:lib_order.php
示例3: cart_weight_price
/**
* 获得购物车中商品的总重量、总价格、总数量
*
* @access public
* @param int $type 类型:默认普通商品
* @return array
*/
function cart_weight_price($type = CART_GENERAL_GOODS)
{
/* 获得购物车中商品的总重量 */
$sql = 'SELECT SUM(g.goods_weight * c.goods_number) AS weight, ' . 'SUM(c.goods_price * c.goods_number) AS amount, ' . 'SUM(c.goods_number) AS number ' . 'FROM ' . $GLOBALS['ecs']->table('cart') . ' AS c ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = c.goods_id ' . "WHERE c.session_id = '" . SESS_ID . "' " . "AND rec_type = '{$type}'";
$row = $GLOBALS['db']->getRow($sql);
$row['weight'] = floatval($row['weight']);
$row['amount'] = floatval($row['amount']);
$row['number'] = intval($row['number']);
/* 格式化重量 */
$row['formated_weight'] = formated_weight($row['weight']);
return $row;
}
开发者ID:BGCX261,项目名称:zishashop-svn-to-git,代码行数:19,代码来源:lib_order.php
注:本文中的formated_weight函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论