您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop商品销量自定义虚拟销量已销售的实现方法
韦鲁郎2024-01-16Ecshop商城教程已有人查阅
导读ecshop商品自定义销量(虚拟销量)实现方法1.在sq执行语句ALTER TABLE `ecs_goods` ADD `sales_volume_bas
ecshop商品自定义销量(虚拟销量)实现方法
1.在sq执行语句
2./admin/includes/lib_goods.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') 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') 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} {$lang.goods_number}{$sort_goods_number} {/if}
后,添加
{$lang.sales_volume_base}{$sort_sales_volume_base}
在
{if $use_storage} {$goods.goods_number} {/if}
后,添加
{$goods.sales_volume_base}
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,在后,添加
{if $cfg.show_goods_sales}
{$lang.sales_volume_total}
{$sales_count}{if $goods.measure_unit}{$goods.measure_unit}{else}{$lang.pcs}{/if}
{/if}
OK,完成!
本文标签:
很赞哦! ()
图文教程
ecshop商城程序安装补丁的方法教程
各位朋友大家好,欢迎来到ECSHOP教程网系 列教程第三讲:系统ECSHOP补丁的安装方法!有很多客户都给ECSHOP教程网反馈:如何安装系统补丁?
ecshop发货查询中加入收货人收货地址发货时间配送方式
1、修改 index.php 的 index_get_invoice_query() 函数部分 将 $sql = 'SELECT o.order_sn,
ecshop支付插件开发教程
ecshop开发一个支付插件的方法(例如要新建一个为paytest-----支付测试)1.languages/zh_cn/payment/目录下新建一个paytest.php文件
ecshop会员注册实现注册自动发送邮件验证码
从数据库入手 用mysql管理工具找到 ecs_mail_templates 表插入一条 注册发送邮件的数据template_content 是邮件发邮件内容字段 根据自己的需要编辑不同的内容
相关源码
-
深蓝色风景摄影机构网站(自适应多端)pbootcms模板该模板基于PbootCMS内核开发,专为风景摄影机构、户外摄影企业设计,采用深蓝色主题传递专业与艺术感,全栈响应式架构确保PC、平板、手机端无缝适配PHP程序结合轻量级SQLite数据库也可以更换MySQL数据库查看源码 -
WordPress主题模板JustNews资讯博客类源码V5.2.2JustNews主题针对博客创作、自媒体运营及资讯发布类网站的需求而设计,提供专业的内容展示与管理方案。该主题集成前端用户中心功能,支持用户在前端界面发布和投稿文章,操作流程简洁高效。查看源码 -
宽屏自适应搬家家政快递物流公司网站模板该宽屏大气的响应式网站模板专为搬家公司、家政服务及物流快递企业设计,基于PbootCMS内核开发,通过自适应布局确保手机、PC等多终端体验一致,助力企业高效构建专业在线服务平台。查看源码 -
帝国CMS7.5小说推荐公众号导航带wap手机站+带采集工具本模板为小说导航类网站设计开发,基于帝国CMS7.5内核构建,针对小说阅读领域的分类聚合需求进行深度优化。通过智能分类系统和用户行为分析,实现小说资源的精准推荐与导航功能。查看源码 -
帝国cms7.5女性护肤搭配美妆潮流网站源码带数据4.5G本模板专为女性美容护肤行业设计,提供美容护肤、发型设计、女性健康、时尚化妆、娱乐新闻、服饰搭配等女性潮流资讯内容展示。采用帝国CMS7.5开发,同步生成电脑端和手机端,满足用户对美容时尚信息的获取需求。查看源码 -
(自适应)驾校培训学车活动免费pbootcms源码下载本模板基于PbootCMS内核开发,为驾校培训行业打造,具备完善的招生展示、课程预约、教练团队展示等功能模块。响应式设计适配各类移动终端,数据实时同步管理,助您高效开展线上业务。查看源码
| 分享笔记 (共有 篇笔记) |
