わかりました、これには問題があります。オプションの色などで商品をカートに追加しようとしていますが、うまくいきません。「カートに入れる」を押すだけでは毎回カウントされますが、色を変更するとうまくいきません。助けて、男も女も!しばらくの間、これに取り組んできました。
if(isset($_POST['submit'])){
$id = $_POST['id'];
$sleeve = $_POST['sleeve'];
$colour = $_POST['colour'];
$size = $_POST['size'];
$action = $_POST['action'];
$quantity = 1;
}
if(!isset($_SESSION['cart'][$id])){
$_SESSION['cart'][$id] = array($id, $colour, $size, $quantity);
}
else{
if(isset($_SESSION['cart'][$id])){ // if the session as already been set then..
while(list($key, $value) = each($_SESSION['cart'])){ // while loop to chech to content of the session..
if($value[0] == $id && $value[1] == $colour && $value[2] == $size){ // checking to see if the session content is the same..
$quantity = $value[3] +=1;
$_SESSION['cart'][$id] = array($id, $colour, $size, $quantity); // if it is the same then add this..
}// if is ==
else{
$quantity +=1;
$_SESSION['cart'][$id][] = array($id, $colour, $size, $quantity); // is session is not the same do this..
}//else if it is not ==
}// while
}// if isset
}// else isset session