zoukankan      html  css  js  c++  java
  • php购物车处理逻辑

     1 <?php
     2 /**
     3  * 我的购物车
     4  */
     5 
     6 include 'init.php';
     7 
     8 $TEMPLATE['type'] = 'cart';
     9 $TEMPLATE['pageTitle'] = '我的购物车';
    10 
    11 $carts_list = $goods_list = array();
    12 foreach ($_COOKIE as $k => $v) {
    13     if (strpos($k, 'mycarts_') === 0) {
    14         $aid = intval($v);
    15         $goods_id = intval(str_replace('mycarts_', '', $k));
    16         $goods_list[$goods_id] = $aid;
    17     }
    18 }
    19 
    20 $active_model = new modelActive();
    21 $goods_model = new modelGoods();
    22 
    23 foreach ($goods_list as $goods_id => $aid) {
    24     $goods_info = $goods_model->get($goods_id);
    25     $active_info = $active_model->get($aid);
    26     if ($goods_info && $active_info
    27         && $goods_info['active_id'] == $aid
    28         && $goods_info['sys_status'] === '1'
    29         && $active_info['sys_status'] === '1'
    30         && $active_info['time_begin'] < $now
    31         && $active_info['time_end'] > $now
    32     ) {
    33         // 验证数据的正确性
    34         $carts_list[$aid]['active'] = $active_info;
    35         $carts_list[$aid]['goods'][] = $goods_info;
    36     }
    37 }
    38 
    39 $TEMPLATE['carts_list'] = $carts_list;
    40 
    41 include TEMPLATE_PATH . '/cart.php';

    转载于tongpan.com


  • 相关阅读:
    负环判断模版
    计蒜客NOIP2017提高组模拟赛(四)day1
    NOIP2014-10-30模拟赛
    树链剖分模版
    2014-10-30NOIP复习题1
    NOIP2014-5-17模拟赛
    NOIP2014-5-10模拟赛
    NOIP2014-3-15模拟赛
    HDU1556Color the ball
    HDU1166敌兵布阵
  • 原文地址:https://www.cnblogs.com/sakura10032/p/9994144.html
Copyright © 2011-2022 走看看