您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop商品自定义商品促销图标

樊辰博2024-01-01Ecshop商城教程已有人查阅

导读大家是不是在一些商城的产品列表中,产品价格的左侧或右侧看到“新品”“精品”“热销”“促销”“疯抢价”等,这些小图标在整个列表中,除了简单的标示外

大家是不是在一些商城的产品列表中,产品价格的左侧或右侧看到“新品”“精品”“热销”“促销”“疯抢价”等,这些小图标在整个列表中,除了简单的标示外,实际上也对用户的吸引度起着不小的作用哦,默认的似乎还不够满足我们的需要,带大家一起来制作一个简易的图标效果吧,仅供大家参考哦。
还是以数据库修改为妙,这样做起来会比较快哦。首先我们在商品数据表:ecs_goods中,添加一个新的字段为:goods_icon,不懂的朋友直接运行下面这句:
ALTER TABLE ecs_goods ADD goods_icon char(50) NOT NULL DEFAULT '';
后台运行前,请先自行备份好原数据库。
然后在根目录中找到admin文件夹,修改里面的两个文件如下:
Admin/goods.php
Admin/templets/goods_info.html
1.在goods_info.html中添加一段代码如下:
<tr>
<td class="label"><font color="red"> * 疯抢价小图标:</font></td>
<td>
<input type="radio" name="goods_icon" value="fengqiang" size="30" />疯抢
<input type="radio" name="goods_icon" value="chuxiao" size="30" />促销
<input type="radio" name="goods_icon" value="zhengchang" size="30" checked="checked" />正常
</td>
</tr>
2.在goods.php中找到约
836行,在里面增加一句:
Goods_icon 和'$_POST[goods_icon]'
然后往下搜索数据库里的其中一个字段,比如“is_best”,看下分别在哪些位置出现,我们相应的在那里把新加入的字段加上,应该是有831行左右,850行左右,914行左右三处,修改后点击保存即可。
修改后的代码参考:处:
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, seo_title, suppliers_id, goods_icon)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral','$_POST[seo_title]', '$suppliers_id', '$_POST[goods_icon]')";
}
第2处:
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral, seo_title, goods_icon)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral','$_POST[seo_title]', '$_POST[goods_icon]')";
}
第3处:
$sql .= "keywords = '$_POST[keywords]', " .
"goods_brief = '$_POST[goods_brief]', " .
"seller_note = '$_POST[seller_note]', " .
"goods_weight = '$goods_weight'," .
"goods_number = '$goods_number', " .
"warn_number = '$warn_number', " .
"integral = '$_POST[integral]', " .
"give_integral = '$give_integral', " .
"rank_integral = '$rank_integral', " .
"seo_title='$_POST[seo_title]'," .
"goods_icon='$_POST[goods_icon]'," .
"is_best = '$is_best', " .
"is_new = '$is_new', " .
"is_hot = '$is_hot', " .
"is_on_sale = '$is_on_sale', " .
"is_alone_sale = '$is_alone_sale', " .
"is_shipping = '$is_shipping', " .
"goods_desc = '$_POST[goods_desc]', " .
"last_update = '". gmtime() ."', ".
"goods_type = '$goods_type' " .
"WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
这时候我们到后台选择其中一个商品,进行修改,看看数据库里能否正常接收到值,如果正常,说明前面的操作OK。下面是显示环节了,还需要修改include/lib_goods.php 文件,找到 527行和1586行左右,在代码最开始分别增加我们新的变量,参考代码如下:
处:
$sql = 'SELECT g.goods_icon,g.goods_id,g.cat_id,c.parent_id,g.goods_name, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
第2处:
// 增加疯抢价图标 2013-6-26
$goods[$idx]['goods_icon']   = $row['goods_icon'];
OK,解决了这里,基本上就是调用了。在首页模板或库文件中,可以这样判断调用:
<p class="jq" title="{$goods.goods_icon}">
{if $goods.goods_icon eq 'fengqiang'}
<em style="width:41px;margin-top:2px;height:14px;background:url(themes/default/images/fengqiangjiaicon.jpg) 0 0 no-repeat; display:inline-block; float:left;"></em>
{/if}
{if $goods.goods_icon eq 'chuxiao'}
<em style="width:41px;margin-top:2px;height:14px;background:url(themes/default/images/chuxiaoicon.jpg) 0 0 no-repeat; display:inline-block; float:left;"></em>
{/if}
{if $goods.goods_icon eq 'zhengchang'}
<em style="width:41px;margin-top:2px;height:14px;display:inline-block; float:left;"></em>
{/if}
<b style="float:left;display:inline-block; padding-left:3px; padding-right:3px; height:18px;line-height:18px;">{$goods.shop_price}</b><span  style="float:left;display:inline-block; height:18px; line-height:18px;">{$goods.market_price}</span>
</p>
本文只是提供代码实现参考,样式需要大家自行处理哦。

本文标签:

很赞哦! ()

相关源码

  • 自适应黑色建筑装饰设计公司个人工作室pbootcms模板基于PbootCMS内核开发的黑金风格模板,为建筑装饰、工程设计类企业打造,采用‌开源架构‌,支持跨行业快速适配,核心优势如下: 查看源码
  • 帝国cms7.5大型游戏资讯门户网站源码免费下载本模板基于帝国CMS7.5内核开发,为大型游戏资讯门户网站设计。模板自带响应式手机版,适配多种终端设备。内容架构针对游戏行业特点优化,支持游戏资讯、评测、攻略等内容类型的发布与管理。查看源码
  • (PC+WAP)红色家装设计智能家居家具建材pbootcms网站源码下载本模板基于PbootCMS系统开发,为智能家居、家装设计及家具建材行业设计。采用现代化布局风格,突出家居设计行业特色,适合展示各类家居产品、设计方案和建材信息。查看源码
  • (PC+WAP)蓝色电子半导体电子设备网站pbootcms源码下载本模板基于PbootCMS内核开发,为半导体和电子科技行业设计,特别适合电子元器件、集成电路、半导体设备及相关技术产品展示。查看源码
  • 蓝色工业机械五金设备pbootcms模板源码下载(PC+WAP)为机械制造与五金设备企业设计的响应式网站模板,基于PbootCMS内核开发。采用蓝色工业风格强化行业属性,宽屏布局突出设备细节展示,支持PC与WAP端自适应查看源码
  • (自适应)品牌策划网络设计作品公司个人pbootcms网站源码下载本款基于PbootCMS开发的网站模板专为品牌策划、设计公司打造,特别适合展示创意作品、设计案例和企业服务。模板采用现代化设计风格查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐