Jump to content

add items to a cart - POST, GET or GET + special code?


Recommended Posts

I'm refining my shopping cart right now. I have been using GET variable when adding an item to the cart. (as opposed to POST variables)
One reason I don't like POST for this purpose is that if the user refreshes the page, they get the annoying WARNING regarding POST data.

However, with the GET method, after an item has been added to the cart (?additem=1234), if the user refreshes the page, the item gets added again (if the item can be sold multiple times).

Some sites don't let items increment in a cart unless the user changes the item quantity in the cart and then updates the cart. Other sites let you click the add cart item again and the item increments by 1.

I've figured out a solution for this using a session switch. It's not hard to do, but I'm just curious as to what other's preferred method is for carts - if you have a cart on your site.

Anyone?
Well, I think I came up with an easy and elegant solution. I think this would work with POST as well as GET.
I'm going to continue using GET for the cart. However, when I'm done with my add item script, I will simply reload the page without the additem in the url. This way the page can be refreshed without adding another item. The back button will take you back to the item you were looking at. You can add the item again and it will increment. It works, I love it!
Yeah, that's a pretty typical strategy for avoiding data reloads in general. Even if their browser pops up and warns them they're about to reload POST data, half your users will click OK anyway. Plus the message is annoying, best you keep them from getting it.
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.