LOT of ways to do this
SIMPLE way.
Assuming you can create, open, write, append & delete records from a file.
(Indexed Random Access files are easier to work with once set up, flat text files are easier for beginner)
Since number of items in each "Cart" is small, this will work.
ASSUMING front end is written & you're at Add to Cart Stage
Can't get into CODE-I'll give you steps.
You'll need to set up a text file containing nothing but a number-any number-say 100
This will be the cart numbers, call it cartnumber.txt
When someone "Adds (First Item) to Cart"
Open cartnumber.txt
Fetch number from there & assign to variable. We'll use cartNo
Increment by one
Write NEW number BACK TO cartnumber.txt
(Don't Append, ONLY KEEP ONE RECORD in file, the NEXT cart)
Unlock & close cartnumber.txt
With 100 now in cartNo
Open new file (APPEND) - call it cart100.txt - This will hold books for THIS transaction.
(100 comes from cartNo & also be Order Number.)
Data for First Item will be line 1 in the file.
Next will be line 2, etc.
(Random files let you access by UPC/ISBN code, or anything else, - we'll keep it simple)
Click "View Cart"
Open cart100.txt
* Step through file, one line (record) at a time, suck out data & display the 4 items on screen.
* Stash all records into an array in memory - items[]
After adding four items, I decide I don't want second one.
Click "Remove From Cart"
* Empty Array Item Items[2]
* Open cart100.txt toWRITE Erasing Contents
* Write only array items containing data (test for empty records & skip) to now empty cart100.txt
Display new cart contents & flush array.
YES ITS CUMBERSOME-ITEMS WITH AN * could be eliminated using indexed files.
When done, you'll have a text file, cart100.txt to build the total & invoice.
AFTER CHECKOUT, delete cart100.
NOT most elegant/efficient but simple.
Good Luck
Egg