关于让ecshop商品列表显示获赠消费积分

2016-09-11 20:39 来源:www.chinab4c.com 作者:ecshop专家

 1、打开category.php 找到 category_get_goods 函数 修改为

  1. function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
  2. {
  3. $display = $GLOBALS['display'];
  4. $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
  5. "g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')';
  6.  
  7. if ($brand > 0)
  8. {
  9. $where .= "AND g.brand_id=$brand ";
  10. }
  11.  
  12. if ($min > 0)
  13. {
  14. $where .= " AND g.shop_price >= $min ";
  15. }
  16.  
  17. if ($max > 0)
  18. {
  19. $where .= " AND g.shop_price <= $max ";
  20. }
  21.  
  22. /* 获得商品列表 */
  23. $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, IF(g.give_integral > -1, g.give_integral, g.shop_price) as integral, ' .
  24.  
  25.  
  26. "NULL.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
  27. 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
  28. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  29. 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
  30. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
  31. "WHERE $where $ext ORDER BY $sort $order";
  32. $res = $GLOBALS['db']->sel ectLimit($sql, $size, ($page - 1) * $size);
  33.  
  34. $arr = array();
  35. while ($row = $GLOBALS['db']->fetchRow($res))
  36. {
  37. $goods_id = $row['goods_id'];
  38. $sql2= "sel ect sum(goods_number) as count from ".$GLOBALS['ecs']->table('order_goods')."where goods_id ='".$goods_id."'";
  39. $buy_num = $GLOBALS['db']->getOne($sql2);
  40. if ($row['promote_price'] > 0)
  41. {
  42. $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
  43. }
  44. else
  45. {
  46. $promote_price = 0;
  47. }
  48.  
  49. /* 处理商品水印图片 */
  50. $watermark_img = '';
  51.  
  52. if ($promote_price != 0)
  53. {
  54. $watermark_img = "watermark_promote_small";
  55. }
  56. elseif ($row['is_new'] != 0)
  57. {
  58. $watermark_img = "watermark_new_small";
  59. }
  60. elseif ($row['is_best'] != 0)
  61. {
  62. $watermark_img = "watermark_best_small";
  63. }
  64. elseif ($row['is_hot'] != 0)
  65. {
  66. $watermark_img = 'watermark_hot_small';
  67. }
  68.  
  69. if ($watermark_img != '')
  70. {
  71. $arr[$row['goods_id']]['watermark_img'] = $watermark_img;
  72. }
  73.  
  74. $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
  75. if($display == 'grid')
  76. {
  77. $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
  78. }
  79. else
  80. {
  81. $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
  82. }
  83. $arr[$row['goods_id']]['count'] = $buy_num;
  84. $arr[$row['goods_id']]['name'] = $row['goods_name'];
  85. /* 修正积分:转换为可使用多少积分(原来是可以使用多少钱的积分) */
  86. $arr[$row['goods_id']]['integral'] = round($row['integral'],0);
  87.  
  88. $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
  89. $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
  90. $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
  91. $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
  92. $arr[$row['goods_id']]['type'] = $row['goods_type'];
  93. $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
  94. $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
  95. $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
  96. $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
  97. }
  98.  
  99. return $arr;
  100. }
复制代码


2、模板部分直接加

  1. {$goods.integral}积分
复制代码