Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 06 March 2006 - 11:19 PM

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?

#2 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 07 March 2006 - 01:49 AM

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!

#3 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 07 March 2006 - 04:02 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users