【ecshop教程】ECTouch商品详情页显示销量为0的修复方法
ECTouch商品详情页显示销量为0,一般原因可能是订单没有全部完成,也就是订单需要用户收货确认,才能算一笔销量。
如果这点满足,且还是没有出来,则就是代码的问题了。
找到文件 mobile/include/apps/default/common/function.php 搜索函数 get_goods_count
主要代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /** * 获取商品销量总数 * * @access public * @param integer $goods_id * @return integer */ function get_goods_count( $goods_id ) { /* 统计时间段 */ $period = C( 'top10_time' ); $ext = '' ; if ( $period == 1) { // 一年 $ext = "AND o.add_time >'" . local_strtotime('-1 years ') . "' "; } elseif ( $period == 2) { // 半年 $ext = "AND o.add_time > '" . local_strtotime('-6 months ') . "' "; } elseif ( $period == 3) { // 三个月 $ext = " AND o.add_time > '" . local_strtotime('-3 months ') . "' "; } elseif ( $period == 4) { // 一个月 $ext = " AND o . add_time > '" . local_strtotime(' - 1 months ') . "' "; } /* 查询该商品销量 */ $sql = 'SELECT IFNULL(SUM(g.goods_number), 0) as count ' . 'FROM ' . M()->pre . 'order_info AS o, ' . M()->pre . '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'" ; $result = M()->getRow( $sql ); return $result [ 'count' ]; } |
然后就可以在商品详情页,调用这个方法。
例如:mobile/include/apps/default/controller/GoodsController.class.php
1 | $this ->assign( 'sales_count' , model( 'GoodsBase' )->get_sales_count( $this ->goods_id)); |
版权声明:本文来源于互联网,如有侵权,请联系下方邮箱,一个工作日删除!