轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 ECShop网店 查看主题

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

发布者: 觉醒的白河愁 | 发布时间: 2019-3-27 01:35| 查看数: 4072| 评论数: 1|帖子模式

商品自定义销量(虚拟销量)实现方法

1.在sq执行语句
  1. ALTER TABLE `ecs_goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'  
  2. 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');  
  3. 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中
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";
复制代码
修改为
  1. $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, " .   
  2.                     " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.                     " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.                     " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.                     " LIMIT " . $filter['start'] . ",$filter[page_size]";
复制代码


3./admin/templates/goods_list.htm,在
  1. {if $use_storage}  {$lang.goods_number}{$sort_goods_number}  {/if}
复制代码
后,添加
  1. {$lang.sales_volume_base}{$sort_sales_volume_base}
复制代码

  1. {if $use_storage}  {$goods.goods_number}  {/if}
复制代码
后,添加
  1. {$goods.sales_volume_base}
复制代码
4./admin/goods.php,在
  1. /**
  2. * 列表链接
  3. * @param   bool    $is_add         是否添加(插入)
  4. * @param   string  $extension_code 虚拟商品扩展代码,实体商品为空
  5. * @return  array('href' => $href, 'text' => $text)
  6. */  function list_link($is_add = true, $extension_code = '')
复制代码


前,添加
  1. /*------------------------------------------------------ */  //-- 修改商品虚拟销量  /*------------------------------------------------------ */  elseif ($_REQUEST['act'] == 'edit_sales_volume_base')  
  2. {  
  3.     check_authz_json('goods_manage');  
  4.   
  5.     $goods_id = intval($_POST['id']);  
  6.     $sales_volume_base = json_str_iconv(trim($_POST['val']));  
  7.   
  8.     if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id))  
  9.     {  
  10.         clear_cache_files();  
  11.         make_json_result(stripslashes($sales_volume_base));  
  12.     }  
  13. }
复制代码
5.goods.php,在
  1. $smarty->assign('categories',         get_categories_tree($goods['cat_id']));  // 分类树
复制代码
后,添加
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";0
复制代码
在末尾添加
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";1
复制代码


6.在/languages/zh_cn/admin/shop_config.php,中

/languages/zh_cn/admin/shop_config.php  
下,添加
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";2
复制代码

7./languages/zh_cn/admin/goods.php,中
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";3
复制代码
后,添加
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";4
复制代码
8./languages/zh_cn/common.php,中
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";5
复制代码


后,添加
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";6
复制代码


9./themes/default/goods.dwt,在
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";7
复制代码
后,添加
  1. $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, " .  
  2.             " (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".  
  3.             " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
  4.             " ORDER BY $filter[sort_by] $filter[sort_order] ".  
  5.             " LIMIT " . $filter['start'] . ",$filter[page_size]";8
复制代码


OK,完成!

最新评论

奋斗 发表于 2022-7-19 14:48
php连续签到打卡源码

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表