ecshop 优惠活动显示图片的方法
修改function favourable_list($user_rank){}
全部内容为
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']); $i=0; foreach ($favourable['gift'] as $key => $value) { $favourable['gift'][$key]['formated_price'] = price_format($value['price'], false); $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods') . " WHERE is_on_sale = 1 AND goods_id = ".$value['id']; $is_sale = $GLOBALS['db']->getOne($sql); $goods_info = $GLOBALS['db']->getAll("SELECT * FROM " . $GLOBALS['ecs']->table('goods') . " WHERE is_on_sale = 1 AND goods_id = ".$value['id']); if(!$is_sale) { unset($favourable['gift'][$key]); } $favourable['gift'][$i]['goods_thumb'] = $goods_info[0]['goods_thumb']; $i++; } $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; }