您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop二次开发秒杀、限时折扣、 等功能实现方法
幻灵2025-01-14 22:40:12ecshop商城教程已有10人查阅
导读1,先在后台admin/templates 中找goods_info.htm文件到促销部分,改为一个下拉列表的分别是促销,限时,秒杀,值分别是1,2,3
1,先在后台admin/templates 中找goods_info.htm文件到促销部分,改为一个下拉列表的分别是促销,限时,秒杀,值分别是1,2,3
这样,代码如下:
其中对时间选择框进行了重新设置为显示小时和分钟。
2,把admin下的goods.php 改一句话,注释部分是原先的代码
3、把下面的方法复制到你需要调用的页面:(方法中的sql条件WHERE is_promote = '2'是控制调用促销/限时/秒杀的)
4、在下面这句代码下加入调用的代码;
这样,代码如下:
<!-- 限时抢购开始 liangfang edit-->
<tr>
<td class="label"><label for="is_promote">
<input type="checkbox" id="is_promote_switch" name="is_promote_switch" value="1" {if $goods.is_promote}checked="checked"{/if} onclick="handlePromote(this.checked);" /> 是否参加促销</label>
<select name="is_promote" id="is_promote">
<option value="1" {if $goods.is_promote eq 1}selected="selected"{/if} >{$lang.lab_promote_price}</option>
<option value="2" {if $goods.is_promote eq 2}selected="selected"{/if} >限时价:</option>
<option value="3" {if $goods.is_promote eq 3}selected="selected"{/if} >秒杀价:</option>
</select></td>
<td id="promote_3"><input type="text" id="promote_1" name="promote_price" value="{$goods.promote_price}" size="20" /></td>
</tr>
<tr id="promote_4">
<td class="label" id="promote_5">{$lang.lab_promote_date}</td>
<td id="promote_6">
<input name="promote_start_date" type="text" id="promote_start_date" size="15" value='{$goods.promote_start_date}' readonly="readonly" /><input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('promote_start_date', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_select}" class="button"/> - <input name="promote_end_date" type="text" id="promote_end_date" size="15" value='{$goods.promote_end_date}' readonly="readonly" /><input name="selbtn2" type="button" id="selbtn2" onclick="return showCalendar('promote_end_date', '%Y-%m-%d %H:%M', '24', false, 'selbtn2');" value="{$lang.btn_select}" class="button"/>
</td>
</tr>
<!-- 限时抢购结束-->
2,把admin下的goods.php 改一句话,注释部分是原先的代码
$is_promote = empty($promote_price) ? 0 : $_POST['is_promote'];//liangfang edit
// $is_promote = empty($promote_price) ? 0 : 1;
/**
* 获得分类下的秒杀-限时折扣
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods_zhekou($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
$display = $GLOBALS['display'];
$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')';
if ($brand > 0)
{
$where .= "AND g.brand_id=$brand ";
}
if ($min > 0)
{
$where .= " AND g.shop_price >= $min ";
}
if ($max > 0)
{
$where .= " AND g.shop_price <= $max ";
}
/* 获得商品列表 */
$now_time = gmtime();
$sql = "SELECT g.goods_id,g.goods_thumb,g.goods_name,g.shop_price,g.promote_price,g.promote_start_date,g.promote_end_date FROM "
.$GLOBALS['ecs']->table('goods'). ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
" WHERE is_promote = '2' and promote_start_date <= '$now_time' and promote_end_date >= '$now_time' and is_on_sale = 1 and is_alone_sale = 1 and is_delete = 0 order by promote_start_date ";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
}
/* 处理商品水印图片 */
$watermark_img = '';
if ($promote_price != 0)
{
$watermark_img = "watermark_promote_small";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new_small";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best_small";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
}
if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
$arr[$row['goods_id']]['keywords'] = $row['keywords'];
}
return $arr;
}
/**
* 获得分类下的 捡耙活
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods_clear($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
$display = $GLOBALS['display'];
$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')';
if ($brand > 0)
{
$where .= "AND g.brand_id=$brand ";
}
if ($min > 0)
{
$where .= " AND g.shop_price >= $min ";
}
if ($max > 0)
{
$where .= " AND g.shop_price <= $max ";
}
/* 获得商品列表 */
$now_time = gmtime();
$sql = "SELECT g.goods_id,g.goods_thumb,g.goods_name,g.shop_price,g.promote_price,g.promote_start_date,g.promote_end_date FROM "
.$GLOBALS['ecs']->table('goods'). ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
" WHERE is_promote = '3' and promote_start_date <= '$now_time' and promote_end_date >= '$now_time' and is_on_sale = 1 and is_alone_sale = 1 and is_delete = 0 order by promote_start_date ";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
}
/* 处理商品水印图片 */
$watermark_img = '';
if ($promote_price != 0)
{
$watermark_img = "watermark_promote_small";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new_small";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best_small";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
}
if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
$arr[$row['goods_id']]['keywords'] = $row['keywords'];
}
return $arr;
}
/**
* 获得分类下的爆款促销
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods_cuxiao($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
{
$display = $GLOBALS['display'];
$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')';
if ($brand > 0)
{
$where .= "AND g.brand_id=$brand ";
}
if ($min > 0)
{
$where .= " AND g.shop_price >= $min ";
}
if ($max > 0)
{
$where .= " AND g.shop_price <= $max ";
}
/* 获得商品列表 */
$now_time = gmtime();
$sql = "SELECT g.goods_id,g.goods_thumb,g.goods_name,g.shop_price,g.promote_price,g.promote_start_date,g.promote_end_date FROM "
.$GLOBALS['ecs']->table('goods'). ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
" WHERE is_promote = '1' and promote_start_date <= '$now_time' and promote_end_date >= '$now_time' and is_on_sale = 1 and is_alone_sale = 1 and is_delete = 0 order by promote_start_date ";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
}
/* 处理商品水印图片 */
$watermark_img = '';
if ($promote_price != 0)
{
$watermark_img = "watermark_promote_small";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new_small";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best_small";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
}
if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
$arr[$row['goods_id']]['keywords'] = $row['keywords'];
}
return $arr;
}
$smarty->assign('goods_list', $goodslist);
/** 捡耙活商品列表**/
$goodslist_clear = category_get_goods_clear($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order);
if($display == 'grid')
{
if(count($goodslist_clear) % 2 != 0)
{
$goodslist_clear[] = array();
}
}
$smarty->assign('goodslist_clear', $goodslist_clear);
/** 捡耙活商品列表**/
/**爆款促销列表**/
$goodslist_cx = category_get_goods_cuxiao($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order);
if($display == 'grid')
{
if(count($goodslist_cx) % 2 != 0)
{
$goodslist_cx[] = array();
}
}
$smarty->assign('goodslist_cx', $goodslist_cx);
/**爆款促销列表**/
/**限时折扣列表**/
$goodslist_zhekou = category_get_goods_zhekou($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order);
if($display == 'grid')
{
if(count($goodslist_zhekou) % 2 != 0)
{
$goodslist_zhekou[] = array();
}
}
$smarty->assign('goodslist_zhekou', $goodslist_zhekou);
/**限时折扣列表**/
本文标签:
声明:本文由代码号注册/游客用户【幻灵】供稿发布,本站不对用户发布的ecshop二次开发秒杀、限时折扣、 等功能实现方法信息内容原创度和真实性等负责。如内容侵犯您的版权或其他权益,请留言并加以说明。站长审查之后若情况属实会及时为您删除。同时遵循 CC 4.0 BY-SA 版权协议,尊重和保护作者的劳动成果,转载请标明出处链接和本声明内容。本文作者:幻灵» https://www.ebingou.cn/dmh/13625.html
很赞哦! (0)
下一篇:ecshop去版权修改方法教程
暂无内容 |
暂无内容 |
相关文章
暂无内容 |
暂无内容 |
随机图文
ecshop订单查询订单提示介绍
订单查询 从后台 订单管理->订单查询 进入。对于一个访问量很大的系统,每天进出的订单很多,所以订单查询并不可少,ecshop首页商品怎么实现随机排序
首页ecshop商品随机排序的三种方法都是修改inlcudes/lib_goods.php这个文件1 精品推荐 新品上架 热卖商品 促销商品 团购商品 拍卖商品 6类随机排序的调整方法ecshop模板的修改方法
ecshop模板如何修改?很多人在问这个问题,今天就以图解的方式给大家详细说下。相信学完之后,你会很清楚如何修改ecshop模板,不管你是初学者还是程序高手。ecshop退款订单过程逻辑分析
ecshop退款订单原理分析,最近在深入研究ecshop订单结构的时候,发现ecshop退款流程还是非常复杂的,也存在一定的漏洞,ecshop的退款覆盖了退款,退货,定单设置为退款状态,但是在ecsh
留言与评论 (共有 0 条评论) |