我的代码出了什么问题。我想在购物车中添加包含现有商品的新商品

时间:2017-01-27 10:39:30

标签: php

我的代码出了什么问题。我想在购物车中添加包含现有商品的新商品

<?php
if($_SESSION['shopping_cart']['item'])
 {
 $dish[0]= array('meal_type'=>$meal_type,'meal_package'=>$meal_package,'meal_time'=>$meal_time,'meal_plan_days'=>$meal_plan_days,'meal_dish_type'=>$meal_dish_type,'prefixed_qty'=>$prefixed_qty,'prefixed_date'=>$prefixed_date,'cart_plan'=>$cart_total,'product_rule'=>$product_rule);


    $_SESSION['shopping_cart']['item'] = $dish;
    $_SESSION['shopping_cart']['cart_total'] =  $cart_total*$prefixed_qty;

    }
    else
    {
        $item[]=array('meal_type'=>$meal_type,'meal_package'=>$meal_package,'meal_time'=>$meal_time,'meal_plan_days'=>$meal_plan_days,'meal_dish_type'=>$meal_dish_type,'prefixed_qty'=>$prefixed_qty,'prefixed_date'=>$prefixed_date,'cart_plan'=>$cart_total,'product_rule'=>$product_rule);

        $dish=array_push($dish,$item);

        $_SESSION['shopping_cart']['item'] = $dish;
    $_SESSION['shopping_cart']['cart_total'] =  $cart_total*$prefixed_qty;

    }

    ?>

1 个答案:

答案 0 :(得分:0)

试试这个

{{1}}