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="data: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商品自定义销量(虚拟销量)实现方法的更多相关文章

  1. ECSHOP 商品字段增加新字段的方法

    结合ecshop后台“商品编辑”.“商品录入”来谈谈如何给ecshop商品增加一个新字段,假设我们将这个新字段命名为 new_add 1.首先要修改数据表结构,给表 ecs_goods 增加新字段:n ...

  2. ECSHOP商品属性调用到任意页面方法

    看到标题有的人觉得这个很复杂,其实这个没那么复杂,直接用下面的方法,就可以在ECSHOP的任意页面调用商品属性. 一)打开includes\lib_insert.php文件,在最后面增加一个函数: f ...

  3. ECSHOP 商品增加新字段的方法

    在ecshop二次开发工作中,经常碰到一些ECSHOP高级使用者问我,如何给商品增加一个新字段,来录入一些新的内容. 下面我们结合ecshop后台“商品编辑”.“商品录入”来谈谈如何给ecshop商品 ...

  4. ecshop 全站自定义title标题

    对于SEO来说,能让标题自定义的将会大大增加SEO效果,提高独立商城的流量,今天小编就收集从网上弄来ecshop全站自定义代码,很全哦! 1.Ecshop商品分类页如何实现自定义Title 最近发现很 ...

  5. Ecshop商品详情页显示当前会员等级价格

    会员登录状态下,在ECSHOP商品详情页的本店售价中显示当前登录会员对应的等级价格,在未登录状态下,则还默认显示原来的本店售价. 解决方法: 这个需要修改ECSHOP程序代码来实现. 打开文件 /in ...

  6. ubuntu apache2配置详解(含虚拟主机配置方法)

    ubuntu apache2配置详解(含虚拟主机配置方法) 在Windows下,Apache的配置文件通常只有一个,就是httpd.conf.但我在Ubuntu Linux上用apt-get inst ...

  7. 让ecshop用户名、手机号、email登陆方法

    让ecshop用户名.手机号.email登陆方法, 仅适用于没有做过任何平台整合的ECSHOP网站   修改文件:   1.includes/modules/integrates/ecshop.php ...

  8. 实现Ecshop商品跳到淘宝、京东等的购买链接

    今天简单的实现了一下ecshop商品导出到第三方的购买链接功能.大致思路是给商品添加一个buy_link的text字段,存为json结构,然后通过json解析输出到商品购买页面 1.添加字段 增加购买 ...

  9. ECSHOP 商品评论条件修改——购买过该商品且只能评价一次(购买多少次能评价多少次)

    下文转自http://bbs.ecshop.com/thread-1131529-1-1.html ECSHOP 商品评论条件修改,修改为购买过该商品多少次,就只能评价多少次.不需要修改数据库,原理简 ...

随机推荐

  1. 课程设计-基于SSM的在线课程教学系统代码-基于java的线上课程资源共享论坛系统

    注意:该项目只展示部分功能,如需了解,评论区咨询即可. 1.开发环境 开发语言:Java 后台框架:SSM 前端框架:vue 数据库:MySQL 设计模式:MVC 架构:B/S 源码类型: Web 编 ...

  2. .Net Core WebApi(三)--使用 IdentityServer4 4.1.1 踩坑记录

    目的:创建IdentityServer 并通过PostMan验证获取token 第一次配置如下 public class Config { public static IEnumerable<A ...

  3. 异步编程async体会

    namespace 异步编程{ class Program { static void Main(string[] args) { Console.WriteLine("mian this ...

  4. 六:使用Cookie进行会话管理

    1.存储客户端的状态 因为Http协议是无状态的,也就是说每个客户访问服务器端资源时,服务器并不知道该客户端是谁,所以需要会话技术识别客户端的状态.会话技术是帮助服务器 记住客户端状态 2.会话技术 ...

  5. qt 中的自定义pushbutton

  6. ArcGIS图层添加字段出现:“定义了过多字段”

    首先,我图层数据格式为mdb,也就是Access数据库 Access一个表最大支持255个字段,可是我的才添加第一个字段就出现"定义了过多字段"的错误 打开ArcMap添加字段也是 ...

  7. save tran tranName

    begin tran 语句将 @@Trancount加 1.Rollback tran将 @@Trancount递减到 0,但 Rollback tran savepoint_name 除外,它不影响 ...

  8. JAVA中直接用Jdbc就能操作数据库了,为什么还要用spring框架?

    不过随着业务的扩展,你就会发现jdbc建立一个连接居然要几百毫秒,而执行一个普通的SQL仅仅需要几毫秒. 这么重量级的资源建立了就释放了不合适,得找个容器存起来,谁要就来取,不用了就还给容器,毕竟容器 ...

  9. 高性能利器:CDN我建议你好好学一下!

    硬核干货分享,欢迎关注[Java补习课]成长的路上,我们一起前行 ! <高可用系列文章> 已收录在专栏,欢迎关注! CDN 概述 CDN 全称 Content Delivery Netwo ...

  10. JavaSE-Java基础面试题

    重载与重写的区别 重载:本类中,方法名相同,参数列表不同,(参数类型.参数顺序.参数个数),返回值类型可以不同,访问修饰符可不同 重写:子类中,方法名相同,参数不能改,返回值类型一致或其子类,访问权限 ...