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

ecshop商品销量自定义虚拟销量已销售的实现方法

韦鲁郎2024-01-16Ecshop商城教程已有人查阅

导读ecshop商品自定义销量(虚拟销量)实现方法1.在sq执行语句ALTER TABLE `ecs_goods` ADD `sales_volume_bas

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') 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,完成!

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)门窗定制门业带视频功能pbootcms模板下载本模板采用PbootCMS内核开发,为门窗制造、定制安装企业打造,通过可视化后台管理系统快速构建品牌官网。自适应设计确保在手机、平板、电脑等设备上均能获得优质浏览体验查看源码
  • (自适应)科技产品设备技术作品pbootcms网站模板带下载和招聘基于PbootCMS内核开发的高端科技企业模板,采用响应式布局技术,适配各类移动终端设备。模板设计聚焦科技行业特性,通过模块化结构实现企业形象展示、技术成果发布与人才招募等核心需求查看源码
  • (自适应响应式)运动健身瑜伽俱乐部网站pbootcms源码下载为健身瑜伽俱乐部设计的响应式网站模板,采用PbootCMS内核开发,可快速搭建专业级企业官网。模板默认适配运动健身行业视觉风格,用户可通过替换图文内容灵活应用于其他服务行业。查看源码
  • (自适应响应式)高端网站建设设计公司互联网营销网站pbootcms模板本模板基于PbootCMS内核开发,为网站建设公司和互联网营销企业量身打造。采用响应式设计,适配各种移动设备,提供统一的后台管理体验查看源码
  • 帝国cms7.5奇闻异事末解之谜模板免费下载带数据本模板基于帝国CMS7.5系统开发,为神秘现象、未解之谜类主题网站设计。包含完整的PC端、移动端及百度MIP站同步生成功能,内置火车头采集规则模块,可快速采集目标站内容资源。整体设计风格神秘大气,符合主题定位。查看源码
  • 自适应恒温恒湿机空调机械设备营销型网站模板(自适应手机版)响应式营销型恒温恒湿机环境设备类网站pbootcms模板 蓝色营销型空调设备网站源码下载PbootCMS内核开发的网站模板,该模板适用于营查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐