How to Add/Edit/Delete Association data only at a session level

I have a requirement where I need to provide a functionality to the user to Keep on adding/deleting/editing item on a particular entity but once the user click on submit only then selected items should be committed to that entity. Example Consider a shopping we site, where Table A has customer detail Table B has details of Items purchased Tables C has list of all available item    Step1:When the user opens the application, it will land on to shopping page in context of the customer and we will give them an option to select the category of item they want to shop. Step 2: After that once they click on show items button it will open a new pop up page that will display all the available items for the selected customer and these list of items will displayed from Table C. Step3: User will select items and click on proceed button and he will land on the shopping page which will show all the items selected from the table B. These selected items will be stored in the Table be in association with the Table. Step4. User may want to again select/remove few items and on shopping page when the user again clicks on show items button it will again display the list item items from the Table C but this time all the previously selected will be checked and user can select more item and deselect existing items. in the on click of Proceed button the step 3 will be repeated. Here, I do not want to commit these data because Step 2,3 and 4 can be repeated. I would like to commit the data in the Table B and corresponding association with Table A once user clicks on proceed to Payment option. In my approach it keeps on adding all the previously selected items as well  and I am not able to fix it. Any suggestion would be appreciated.
1 answers

I would solve this with a shopping-cart entity and a and a shopping-cart-item entity. 

ShoppingCart (customer, status, date, xxx)

ShoppingCartItem (amount)


Customer – ShoppingCart  (1:n)

ShoppingCart – ShoppingCartItem (1:n) 

Product – ShoppingCartItem (1:n)

Now in your step2 (after getting or creating a shoppingcart) select the products that are not yet in the shopping cart. You can do this by using a datasource microflow as long as you didnt commit anythig yet. Once the ShoppingCart & item would be commited you could also retrieve the selectable items using an xpath.

You could add an association from shoppingcart to session and delete behaviour. But then you have to make sure you remove the association when the customer does confirm his shoppingcart. Otherwise the shoppingcart would be removed during session cleanup.