分析ecshop赠品在购物车中出现
2009-11-10 09:22 来源:www.chinab4c.com 作者:ecshop专家
ecshop是一个非常灵活的电子商务系统,他可以在优惠活动中,为某个商品增加赠送礼品.不但可以设置价格,还可以免费赠送。
在购物的时候,如果你选择了某商品,而且该商品又设置了赠送礼品,那么在购物车的cart页面,将会通过以下程序调用赠品.看下面以下ecshop函数
function favourable_list($user_rank)
{
/* 购物车中已有的优惠活动及数量 */
$used_list = cart_favourable();
/* 当前用户可享受的优惠活动 */
$favourable_list = array();
$user_rank = ',' . $user_rank . ',';
$now = gmtime();
$sql = "SELECT * " .
"FROM " . $GLOBALS['ecs']->table('favourable_activity') .
" WHERE CONCAT(',', user_rank, ',') LIKE '%" . $user_rank . "%'" .
" AND start_time <= '$now' AND end_time >= '$now'" .
" AND act_type = '" . FAT_GOODS . "'" .
" ORDER BY sort_order";
$res = $GLOBALS['db']->query($sql);
while ($favourable = $GLOBALS['db']->fetchRow($res))
{
$favourable['start_time'] = local_date($GLOBALS['_CFG']['time_format'], $favourable['start_time']);
$favourable['end_time'] = local_date($GLOBALS['_CFG']['time_format'], $favourable['end_time']);
$favourable['formated_min_amount'] = price_format($favourable['min_amount'], false);
$favourable['formated_max_amount'] = price_format($favourable['max_amount'], false);
$favourable['gift'] = unserialize($favourable['gift']);
foreach ($favourable['gift'] as $key => $value)
{
$favourable['gift'][$key]['formated_price'] = price_format($value['price'], false);
$favourable['gift'][$key]['goods_thumb'] = $GLOBALS['db']-> getOne("select goods_thumb from ".$GLOBALS['ecs']->table('goods')." where goods_id = $value[id]");
}
$favourable['act_range_desc'] = act_range_desc($favourable);
$favourable['act_type_desc'] = sprintf($GLOBALS['_LANG']['fat_ext'][$favourable['act_type']], $favourable['act_type_ext']);
/* 是否能享受 */
$favourable['available'] = favourable_available($favourable);
if ($favourable['available'])
{
/* 是否尚未享受 */
$favourable['available'] = !favourable_used($favourable, $used_list);
}
$favourable_list[] = $favourable;
}
return $favourable_list;
}
其中的gift值就是赠品的数据信息.而在模板flow.dwt中。
!-- {foreach from=$favourable.gift item=gift} --><br />
<input type="checkbox" value="{$gift.id}" name="gift[]" />
<a href="goods.php?id={$gift.id}" target="_blank">{$gift.name}</a> [{$gift.formated_price}]
<!-- {/foreach} -->
就是循环显示赠品的相关信息.
相关文章:
来源:中国B4C电子商务
上海租车
最近更新
常用插件
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...