商品详情页面的销售记录中如何包含配送区域?

2016-07-07 15:02 来源:www.chinab4c.com 作者:ecshop专家


给你一个思路,你可以看下发货单打印,看下里面的地区获取方式。

回答:
  1. function getsales_history($goods_id){

  2. $sql ='select f.c**ignee, f.order_sn, f.address, g.goods_number,f.add_time FROM '. $GLOBALS['ecs']->table('order_goods') .' as g,'. $GLOBALS['ecs']->table('order_info') .' as f where g.order_id = f.order_id and g.goods_id='.$goods_id;

  3. $res = $GLOBALS['db']->getAll($sql);

  4. $sales_history = array();

  5. foreach ($res AS $idx => $row){

  6. $order_id = $row['order_id'];

  7. $sql = "SELECT concat(IFNULL(c.region_name, ''), '', IFNULL(p.region_name, ''), " .
  8. "'', IFNULL(t.region_name, ''), '', IFNULL(d.region_name, '')) AS region " .
  9. "FROM " . $ecs->table('order_info') . " AS o " .
  10. "LEFT JOIN " . $ecs->table('region') . " AS c ON o.country = c.region_id " .
  11. "LEFT JOIN " . $ecs->table('region') . " AS p ON o.province = p.region_id " .
  12. "LEFT JOIN " . $ecs->table('region') . " AS t ON o.city = t.region_id " .
  13. "LEFT JOIN " . $ecs->table('region') . " AS d ON o.district = d.region_id " .
  14. "WHERE o.order_id = '$order_id'";


  15. $region = $db->getOne($sql);


  16. $sales_history[$idx]['address'] = $region . sub_str($row['c**ignee'], 1, false).'**'



  17. $sales_history[$idx]['order_sn'] = $row['order_sn'];

  18. $sales_history[$idx]['address'] = sub_str($row['address'], 10, false).'*******';

  19. $sales_history[$idx]['number'] = $row['goods_number'];

  20. // $sales_history[$idx]['add_time'] = local_date("Y-m-d", $row['add_time']);

  21. $sales_history[$idx]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);



  22. }

  23. return $sales_history;

  24. }
复制代码