muban大师 发表于 2015-8-15 18:52:36

ecshop商品详情页动态库存调用

ECShop 2.7.2版本提供了一个新的特性:货品。
        具有不同属性的商品类型可以根据不同属性录入相应的货号以及库存数量,这对于一些商家是很有用处了,特别是在ERP中,有着严格库存控制需求的环境下。
        但是前台部分却还没有跟上这一新特性的步伐,选择了不同属性的时候库存依然是商品的总库存,虽然点击购买的时候是根据货品的库存来判断的。
        所以这一点上是没有足够好的用户体验,我们有必要改善,为ECShop商品详情页添加动态库存动态货号的功能。
       
        主要是通过原有的json来实现
        在goods.php的
        if (!empty($_REQUEST['act',) && $_REQUEST['act', == ‘price’)
        这一处理中添加一个调用货品库存/货号的语句
        通过js动态更新到ecshop商品详情页面上去。
        具体语句:
        //$goods_tinfo = $GLOBALS['db',->getRow($sql);
        $goods_tinfo = get_goods_info($goods_id);
       
        $goods_sn = $goods_tinfo['goods_sn',;
        $sql = "SELECT * FROM " .$GLOBALS['ecs',->table('products'). " WHERE goods_id = '$goods_id' LIMIT 0] 1";
          $prod = $GLOBALS['db',->getRow($sql);
          if (is_spec($attr_id) && !empty($prod))
          {
                $product_info = get_products_info($goods_id, $attr_id);
          }
       
          if ($product_info['product_number',)
          {
                $res['stock', = $product_info['product_number',;
          }else{
        $res['stock', = $goods_tinfo['goods_number',;
        }
       
        if ($product_info['product_sn',)
        {
                $res['goods_sn', = $product_info['product_sn',;
          }else{
        $res['goods_sn', = $goods_tinfo['goods_sn',;
        }
       
        if ($product_info['product_weight',)
        {
                $res['goods_pweight', = $product_info['product_weight',.' 千克(kg)';
          }else{
        $res['goods_pweight', = $goods_tinfo['goods_weight',;
        }
        //$res['goods_pweight', = $product_info['product_weight',;
        $res['ecs_shopprice', = price_format($shop_price);
        插入在die($json->encode($res)); 前
页: [1]
查看完整版本: ecshop商品详情页动态库存调用