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. 漏洞复现|Dubbo反序列化漏洞CVE-2019-17564

    01漏洞描述 - Apache Dubbo支持多种协议,官方推荐使用Dubbo协议.Apache Dubbo HTTP协议中的一个反序列化漏洞(CVE-2019-17564),该漏洞的主要原因在于当A ...

  2. Dubbo系列讲解之扩展点实现原理分析【2万字分享】

    Apache Dubbo 是一款微服务开发框架,它提供了 RPC通信 与 微服务治理 两大关键能力.这意味着,使用 Dubbo 开发的微服务,将具备相互之间的远程发现与通信能力, 同时利用 Dubbo ...

  3. 谈谈ARM运行C程序的内部机制

    文章目录 一.代码 二.知识储备 1.ARM汇编指令 2.寄存器知识 三.代码解析 1.指令分析 第一条指令: 第二条指令: 第三条指令: 第四条指令: 第五.六条指令: 第七条指令: 第八.九.十条 ...

  4. cpu设计实践1

    本栏目将实现一个简单cpu(8-32位)的设计,使用xinlink spatan6平台

  5. IDE快捷键的使用

    ctrl+ait+l,整理代码 ctrl+atl+v,生成等号左边的类型和变量 shift+方向键,选择内容 ctrl+方向键,自己领悟.常常与shift同时使用 ctrl+alt+方向键,光标前进或 ...

  6. easyexcel-导入

    package com.meeno.framework.util.easyexcel.entity; import cn.afterturn.easypoi.excel.annotation.Exce ...

  7. spring cloud 项目

    ### 项目需求 客户端:针对普通用户,用户登录.用户退出.菜品订购.我的订单. 后台管理系统:针对管理员,管理员登录.管理员退出.添加菜品.查询菜品.修改菜品.删除菜品.订单处理.添加用户.查询用户 ...

  8. C# 二维码生成 ( QRCoder )

    二维码1.前言seaconch 最近在搞二维码方面的一些东西,所以接触了一些二维码相关,那么既然用过了就要有用过了的样子 其实关于二维码的文章真的多的数不胜数,有很多写的很认真,很好,但这就像是学习一 ...

  9. DQL,DML,DDL,DCL分别是什么?

    SQL语言共分为四大类:数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据控制语言DCL. 数据查询语言DQL数据查询语言DQL基本结构是由SELECT子句,FROM子句,WHERE子句 ...

  10. IDEA 创建Maven Web工程

    一.Maven环境搭建 二.Maven常用命令 mvn clean 清除生成的target文件 mvn install 生成target文件 mvn clean install 相当于先删除targe ...