您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop商品销量后台添加虚拟销量以及前台显示商品已销售销量
高季晨2024-01-16Ecshop商城教程已有人查阅
导读使用ECSHOP做网站时,有个苦恼,就是推广前期,商城销量很少,要是能够显示一个假的销量就好了。通过本教程就可以实现。教程开始1.在sq执行语句ALTER
使用ECSHOP做网站时,有个苦恼,就是推广前期,商城销量很少,要是能够显示一个假的销量就好了。
通过本教程就可以实现。
教程开始
1.在sq执行语句
ALTER TABLE `ecs_goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('7','show_goods_sales', 'select', '1,0', '', '1', '1');
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('3', 'show_sales_type', 'select', '1,0', '', '1', '1');
注意:如果你的数据表前缀不是‘ecs_’ 请自行修改
2./admin/includes/lib_goods.php中
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " . " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ". " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" . " ORDER BY $filter[sort_by] $filter[sort_order] ". " LIMIT " . $filter['start'] . ",$filter[page_size]";
修改为
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " . " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ". " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" . " ORDER BY $filter[sort_by] $filter[sort_order] ". " LIMIT " . $filter['start'] . ",$filter[page_size]";
3./admin/templates/goods_list.htm,在
{if $use_storage} <th><a href="javascript:listTable.sort('goods_number'); ">{$lang.goods_number}</a>{$sort_goods_number}</th> {/if}
后,添加
<th><a href="javascript:listTable.sort('sales_volume_base'); ">{$lang.sales_volume_base}</a>{$sort_sales_volume_base}</th>
在
{if $use_storage} <td align="right"><span onclick="listTable.edit(this, 'edit_goods_number', {$goods.goods_id})">{$goods.goods_number}</span></td> {/if}
后,添加
<td align="center"><span onclick="listTable.edit(this, 'edit_sales_volume_base', {$goods.goods_id})">{$goods.sales_volume_base}</span></td>
4./admin/goods.php,在
/** * 列表链接 * @param bool $is_add 是否添加(插入) * @param string $extension_code 虚拟商品扩展代码,实体商品为空 * @return array('href' => $href, 'text' => $text) */ function list_link($is_add = true, $extension_code = '')
前,添加
/*------------------------------------------------------ */ //-- 修改商品虚拟销量 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'edit_sales_volume_base') { check_authz_json('goods_manage'); $goods_id = intval($_POST['id']); $sales_volume_base = json_str_iconv(trim($_POST['val'])); if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id)) { clear_cache_files(); make_json_result(stripslashes($sales_volume_base)); } }
5.goods.php,在
$smarty->assign('categories', get_categories_tree($goods['cat_id'])); // 分类树
后,添加
$smarty->assign('sales_count', get_sales_count($goods_id));
在末尾添加
/* 商品累计销量带自定义_新增加 */ function get_sales_count($goods_id) { /* 查询该商品的自定义销量 */ $sales_base = $GLOBALS['db']->getOne('SELECT sales_volume_base FROM '.$GLOBALS['ecs']->table('goods').' WHERE goods_id = '.$goods_id); /* 查询该商品的实际销量 */ $sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' . 'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' . $GLOBALS['ecs']->table('order_goods') . ' AS g ' . "WHERE o.order_id = g.order_id " . "AND o.order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED)) . "AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) . " AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) . " AND g.goods_id = '$goods_id'"; $sales_count = $GLOBALS['db']->getOne($sql); /* 商品累计销量默认显示方式 */ if ($GLOBALS['_CFG']['show_sales_type']) { $row['sales_volume_total'] = $sales_count; //实际销量 } else { $row['sales_volume_total'] = $sales_base + $sales_count; //自定义销量+实际销量 } return ($row['sales_volume_total']); }
6.在/languages/zh_cn/admin/shop_config.php,中
/languages/zh_cn/admin/shop_config.php
下,添加
通过本教程就可以实现。
教程开始
1.在sq执行语句
ALTER TABLE `ecs_goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('7','show_goods_sales', 'select', '1,0', '', '1', '1');
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('3', 'show_sales_type', 'select', '1,0', '', '1', '1');
注意:如果你的数据表前缀不是‘ecs_’ 请自行修改
2./admin/includes/lib_goods.php中
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " . " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ". " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" . " ORDER BY $filter[sort_by] $filter[sort_order] ". " LIMIT " . $filter['start'] . ",$filter[page_size]";
修改为
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " . " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ". " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" . " ORDER BY $filter[sort_by] $filter[sort_order] ". " LIMIT " . $filter['start'] . ",$filter[page_size]";
3./admin/templates/goods_list.htm,在
{if $use_storage} <th><a href="javascript:listTable.sort('goods_number'); ">{$lang.goods_number}</a>{$sort_goods_number}</th> {/if}
后,添加
<th><a href="javascript:listTable.sort('sales_volume_base'); ">{$lang.sales_volume_base}</a>{$sort_sales_volume_base}</th>
在
{if $use_storage} <td align="right"><span onclick="listTable.edit(this, 'edit_goods_number', {$goods.goods_id})">{$goods.goods_number}</span></td> {/if}
后,添加
<td align="center"><span onclick="listTable.edit(this, 'edit_sales_volume_base', {$goods.goods_id})">{$goods.sales_volume_base}</span></td>
4./admin/goods.php,在
/** * 列表链接 * @param bool $is_add 是否添加(插入) * @param string $extension_code 虚拟商品扩展代码,实体商品为空 * @return array('href' => $href, 'text' => $text) */ function list_link($is_add = true, $extension_code = '')
前,添加
/*------------------------------------------------------ */ //-- 修改商品虚拟销量 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'edit_sales_volume_base') { check_authz_json('goods_manage'); $goods_id = intval($_POST['id']); $sales_volume_base = json_str_iconv(trim($_POST['val'])); if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id)) { clear_cache_files(); make_json_result(stripslashes($sales_volume_base)); } }
5.goods.php,在
$smarty->assign('categories', get_categories_tree($goods['cat_id'])); // 分类树
后,添加
$smarty->assign('sales_count', get_sales_count($goods_id));
在末尾添加
/* 商品累计销量带自定义_新增加 */ function get_sales_count($goods_id) { /* 查询该商品的自定义销量 */ $sales_base = $GLOBALS['db']->getOne('SELECT sales_volume_base FROM '.$GLOBALS['ecs']->table('goods').' WHERE goods_id = '.$goods_id); /* 查询该商品的实际销量 */ $sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' . 'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' . $GLOBALS['ecs']->table('order_goods') . ' AS g ' . "WHERE o.order_id = g.order_id " . "AND o.order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED)) . "AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) . " AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) . " AND g.goods_id = '$goods_id'"; $sales_count = $GLOBALS['db']->getOne($sql); /* 商品累计销量默认显示方式 */ if ($GLOBALS['_CFG']['show_sales_type']) { $row['sales_volume_total'] = $sales_count; //实际销量 } else { $row['sales_volume_total'] = $sales_base + $sales_count; //自定义销量+实际销量 } return ($row['sales_volume_total']); }
6.在/languages/zh_cn/admin/shop_config.php,中
/languages/zh_cn/admin/shop_config.php
下,添加
$_LANG['cfg_name']['show_goods_sales'] = '是否显示商品累计销量'; $_LANG['cfg_range']['show_goods_sales']['1'] = '显示'; $_LANG['cfg_range']['show_goods_sales']['0'] = '不显示'; $_LANG['cfg_name']['show_sales_type'] = '商品累计销量默认显示方式'; $_LANG['cfg_range']['show_sales_type'][1] = '真实显示'; $_LANG['cfg_range']['show_sales_type'][0] = '虚拟显示';
7./languages/zh_cn/admin/goods.php,中
$_LANG['goods_sn_exists'] = '您输入的货号已存在,请换一个';
后,添加
$_LANG['sales_volume_base'] = '虚拟销量';
8./languages/zh_cn/common.php,中
$_LANG['divided_into'] = '分成规则';
后,添加
$_LANG['sales_volume_total'] = '累计销量:'; $_LANG['pcs'] = '件';
9./themes/default/goods.dwt,在
<img src="images/stars{$goods.comment_rank}.gif" alt="comment rank {$goods.comment_rank}" /></dd>
后,添加
{if $cfg.show_goods_sales}
<dd style="width:48%; padding-left:7px;">
<strong>{$lang.sales_volume_total}</strong>
<font class="shop">
{$sales_count}
{if $goods.measure_unit}{$goods.measure_unit}{else}{$lang.pcs}{/if}</font>
</dd>
{/if}
OK,完成!
本文标签:
很赞哦! ()
图文教程
ecshop数据恢复提示ecs_sessions不存在的解决方法
ECSHOP网店程序在搬迁空间或恢复备份或更换域名后 ,或安装模板后,经常会出现以下错误提示:
ecshop会员注册登陆或指定会员等级才可以才能看到的内容
ECSHOP在首页或其它页面添加指定等级会员(如游客)才能看到的内容,有时我们希望在ECSHOP网站的首页,或者其它页面,添加一些内容,限制指定会员才能看到
ecshop商品详情页怎么显示收藏数量
众所周知,很新版的商品详情页, 已经能够显示购买数量、评论数量了,但是唯独没有显示收藏数量,也就是淘宝上的收 气,下面我们就把它显示出来。
ecshop商城安全优化ecshop防注入屏蔽SQL提示实例
代码号ECSHOP商城安全优化_ECSHOP防止ECSHOP注入,屏蔽SQL提示教程即把所有的错误输出屏蔽 这样很方便的就解决了注入问题。增加ECSHOP商城的安全系数!
相关源码
-
(PC+WAP)蓝色电子半导体电子设备网站pbootcms源码下载本模板基于PbootCMS内核开发,为半导体和电子科技行业设计,特别适合电子元器件、集成电路、半导体设备及相关技术产品展示。查看源码 -
(自适应响应式)宠物经验资讯咨询博客pbootcms网站源码下载除宠物资讯领域外,通过内容替换可快速适配宠物用品商城、宠物医疗咨询平台、宠物训练教程网站、动物保护组织官网、水族爱好者社区等垂直领域。查看源码 -
(自适应响应式)运动健身瑜伽俱乐部网站pbootcms源码下载为健身瑜伽俱乐部设计的响应式网站模板,采用PbootCMS内核开发,可快速搭建专业级企业官网。模板默认适配运动健身行业视觉风格,用户可通过替换图文内容灵活应用于其他服务行业。查看源码 -
(自适应html5)自媒体运营培训教程个人博客pbootcms模板本模板基于PbootCMS系统开发,特别适合自媒体运营培训、知识付费类网站使用。采用响应式设计,能够适配各类终端设备,为内容创作者提供专业的内容展示平台。查看源码 -
(自适应响应式)高端简繁双语HTML5金融资本咨询单页pbootcms模板采用响应式设计确保在各类手机端设备很好的呈现。该模板专注于金融咨询、资本管理等领域企业形象展示,通过结构化布局突出行业专业度与可信度,后台数据同步管理简化内容维护流程。查看源码 -
(自适应)互联网建站网络公司个人工作室网站模板基于PbootCMS内核开发,围绕「技术方案展示」「成功案例库」「服务流程说明」三大模块构建,支持PC与移动端数据实时同步。附带包含客户评价、行业解决方案的完整测试数据包查看源码
| 分享笔记 (共有 篇笔记) |
