Forum Moderators: coopster
I invoke the script to add or remove an item like this:
?addItem=someItemNumber
?removeItem=someItemNumber
If a customer were to add one item, and then refresh the page (in the address bar you would see?addItem=someItemNumber) it will keep adding 1 additional item each time they reload.
Now assuming they have > 1 of the same ItemNumber in the cart, if they remove 1 from the cart, and refresh the page, they will again continue to remove an item.
Any idea how to make the browser ignore those commands based on the person reloading or going back in their browser?
The only thing I can think of, and I don't know how to do it, is to (after the initial first action of adding/removing to and from the cart) is to clear the query string from the address bar but I don't know hot to do this.........
any ideas or solutions to fix my problem would be greatly appreciated :)
Thanks for the idea though. Maybe someone can elaborate on a similar way that could work?
p.s. sorry for not mentioning my code structure
Would it really matter if the user kept removing an item which isn't there anyway?
This is probably very naive of me, but wouldn't most net savvy users realise that it isn't a good idea to refresh such a page, and if they do, maybe to not do it again? I guess as long as they don't do any real damage it doesn't worry me.
I have a page like this but it is in a pop up window, which I hope might at least discourage users from refreshing the page, as they can't see a refresh button in front of them, rather, I encourage them to 'close this window'.
My 2 cents,
Helen.
?removeItem=someItemNumber
Ignore requests for items not in basket.
?addItem=someItemNumber
Do not keep adding one to the customers quantity. If the item is already in the basket and the customer has added another one, do not add a separate line or increment the quantity but leave the line alone; give them instructions at the top of the basket showing them how to change the quantity via the basket quantity box and clicking 'ok' or 'update' or whatever you have. (Highlighting the relevant boxes that need to be adjusted and clicked on will also help new internet users.)
jamie: after some reluctance I carefully rearranged my code and function calls to make the header trick work and that did it.
Helen: a solution was necessary here, because by going back, or refreshing (which some people do unfortunately) they could add or remove items unintentionally.
PCInk: Thanks for your reply as well, my problem is solved but I should probably consider putting in a quantity box so customers can change their quantities.
Currently I insert one record for each session and for each item. So if a person wants 3 widgets, there would be three entries in the database. I guess, I may have another little problem :)
Currently I insert one record for each session and for each item. So if a person wants 3 widgets, there would be three entries in the database. I guess, I may have another little problem
I set mine up like that originally and I have to admit I got in a muddle with it. I now have two tables, one for each user with the cookie id, and the other with each product entry, with the relevant cookie id for each one. This works better for me.