Jump to content

Modify or delete multiple items from a session


dragon_sa

Recommended Posts

I have the following session variables for each item in a cart, which gets updated each time an item is added from the catalog

		// Register the session variables
	$_SESSION['ses_basket_items']=$ses_basket_items;
	$_SESSION['ses_basket_name']=$ses_basket_name;
	$_SESSION['ses_basket_amount']=$ses_basket_amount;
	$_SESSION['ses_basket_price']=$ses_basket_price;
	$_SESSION['ses_basket_stockcode']=$ses_basket_stockcode;
	$_SESSION['ses_basket_image']=$ses_basket_image;
	$_SESSION['ses_basket_size']=$ses_basket_size;
	$_SESSION['ses_basket_sizechoice']=$ses_basket_sizechoice;
	$_SESSION['ses_basket_id']=$ses_basket_id;

I have a current cart page which loops through the sessions and displays them in a form.

 

I have a check box for each item with the name="remove[]" and the value is the itemID which is the $ses_basket_id of item in the session.

 

I have a select box with name="size[]" and the value is the users selected size for each item in the session which is $ses_basket_size

 

Finnally I have a quantity text box with name="quantity[]" and the value is the users quantity value selected which is $ses_basket_amount.

 

After all the looping through the products displaying each item in a row I have an update cart submit button name="change" outside the loop.

 

What I want to know is how do I setup to perform each of these actions for each item in the session, how do I create the foreach loops for each array to delete or modify the correct items in the session if they are modified.

 

I have the code to perform each task but dont know how to loop it through for each item in the session affecting only the correct session items.

 

so if I have 3 items in the session for example, and I want to change the size of item 1, remove item 2 and change item 3 for quantity 1 to quantity 3 with only the 1 form and change button for all items and actions?

 

Hope that makes sense any help with this would be appreciated.

Link to comment
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.