最新公告
  • 欢迎您光临三优资源网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • 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’ 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=”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,完成!
    /* 商品累计销量默认显示方式 */
        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’]);
    }
    改成
    $row[‘sales_volume_total’] =  $sales_base + $sales_count; //自定义销量+实际销量
    return ($row[‘sales_volume_total’]);
    这样才显示得出来
    1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!3165260857@qq.com
    2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
    3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
    4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有站币奖励和额外收入!


    三优资源网 » ecshop后台添加虚拟销量以及前台显示销量

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    三优资源网
    一个高级程序员模板开发平台

    发表评论

    • 232会员总数(位)
    • 1267资源总数(个)
    • 1本周发布(个)
    • 0 今日发布(个)
    • 1485稳定运行(天)

    提供最优质的资源集合

    立即查看 了解详情