Jump to content

Recommended Posts

Hello,

 

I have created a shopping cart by which a customer can successfully add products to it one by one. I have also enabled the customer to save the order. My problem is that I then need the customer to be able to amend the order (putting the product/s back into the shopping cart). My problem is as follows:

if (isset($_GET['action'])){
$action = $_GET['action'];
}
else {
$action ="";
}

switch ($action) {
case 'multi':
	if ($cart) {
	$cart .= ','.$_GET['ProductID'].':'.$_GET['SizeID'];

	} else {

	$cart .= ','.$_GET['ProductID'].':'.$_GET['SizeID'];	

	}
case 'add':
	if ($cart) {

		$cart .= ','.$_GET['ProductID'].':'.$_GET['SizeID'];
                    

	} else {
		$cart = $_GET['ProductID'].':'.$_GET['SizeID'];
	}
	break;

 

The 'action' that is passed through is "multi" and I pass through the productID and SizeID as expected. The correct information and right amount of products are displayed in the shopping cart. However i recieve an undefined index problem in the switch case "add". Why does it access the else statement in the add switch case when the action i passed through was "multi". In any case how do I stop it from accessing the "add" switch case if "multi" action is passed through??

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/156918-switch-case-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.