ecshop二次开发商品下架购买处理

2010-03-16 10:51 来源:www.chinab4c.com 作者:admin

      ecshop在早期的版本当中,ecshop商品下架购买的问题十分严重,我们通过ecshop二次开发购物车,可以在购物车里面将购买到的商品自动移出购物车,这样方便ecshop修改后的运营和销售.下面是ecshop修改后的购物车处理下架商品程序.

1:includes/lib_order.php的get_cart_goods()函数
$row['is_on_saled'] = $GLOBALS['db']->getOne("select is_on_sale from ".$GLOBALS['ecs']->table('goods')."  where goods_id = '".$row['goods_id']."'");


2:flow.dwt
{if $goods.is_on_saled eq '0'}<img src="images/s.jpg" width="20" height="20">{else}{$goods.subtotal}{/if}

3:includes/lib_order.php cart_goods
 $arr[$key]['is_on_sale'] = $GLOBALS['db']->getOne("select is_on_sale from ".$GLOBALS['ecs']->table('goods')."  where goods_id = '".$value['goods_id']."'");

4:flow.php done
unset($_SESSION['count1']);


5:flow.php checkout

 /* 对商品信息赋值 */
    $cart_goods = cart_goods($flow_type); // 取得商品列表,计算合计
 $_SESSION['count1'] = 0;
 if($cart_goods){
  foreach($cart_goods as $k => $v){
   if($v['is_on_sale'] == 0){
    $_SESSION['count1'] = 1;
   }
  }
 }

 if($_SESSION['count1']){
  $smarty-> assign('count',$_SESSION['count1']);
  $cart_goods = cart_goods($flow_type); // 取得商品列表,计算合计
  
  if($cart_goods){
   foreach($cart_goods as $k => $v){
    if($v['is_on_sale'] == 0){
     $db -> query("delete from ".$ecs->table('cart')." where session_id = '" . SESS_ID . "' and goods_id = '".$v['goods_id']."' AND rec_type = '$flow_type'");
    }
   }
  }

 }


5:flow.dwt checkout
  {if $count}
    <tr>
     <td colspan="7"><font color="red">下架了的商品,将自动移出了购物车!</font></td>
    </tr>
    {/if}

来源:中国B4C电子商务