add to cart doesn't work!

Posts: 14
Joined: 03/12/2008

hi all
i'm developing an ecommerce (http://www.rc-modelmania.com/dev/) but only in home page if i click on "Aggiungi al carrello" (add to cart) button sometimes form submit doesn't work... do you know why?

Posts: 14
Joined: 03/12/2008

that happen only if i choose a random order in the home page block...
i don't know why... probably random order interfere with token form creation?

Posts: 3744
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I couldn't reproduce the bug in my quick test, but the random order shouldn't interfere with anything... the forms should be independent of the rest of the page's source.

Posts: 14
Joined: 03/12/2008

i changed the order to random now... and often i can't add products to cart from the home page

please check now

tnx

Posts: 3744
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Very weird... looking at the source, do you notice any differences in the HTML? I don't think the form token should be a problem, and the form ID seems to be getting generated properly. Puzzled

Posts: 14
Joined: 03/12/2008

the html source of the forms is identic for home page and categories' pages
this is very strange... i don't know in which way random order create this bug

Posts: 80
Joined: 08/31/2007
Bug FinderInternationalizationizerNot KulvikThe other woman.

i can confirm a similar bug. in fact i was just about to ask the same question. my setup is i'm using views with the bonus pack and i'm creating a page that shows a random set of products (with an add to cart/buy button) underneath each product. when they sort criteria is set to anything else other than random the buy button works and redirects to the cart with the item added in. but when it's set to random sorting, the buy button works just once then never again. Sad

the form's HTML seems then same. the tokens seem to be generated properly. so im also at a loss. Sad

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

Oooh, sneaky. I think I figured out the problem. The random order is a big part of the problem, but it would work just fine if you were displaying every product in your catalog at once.

When forms are submitted, the data in them is sent to whatever URL is in the action attribute of the <form> tag. In Drupal, this is nearly always the same page the form is on. So, when the Add to Cart button is clicked, the page is reloaded. On the random order views, you don't necessarily have the same products on the page that you did when you clicked. The Form API's security measures notice that the POST data don't match the form anymore, so nothing happens. Usually, this kind of thing throws an error, but this isn't a usual kind of bug.

If you're going to use the random sorting, I recommend not using any forms in the View. Just use links to the product page.

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Just use links to the product page.

Or Cart links. Thats what we use on our catalogue page. That way we avoid the Add to Cart form items altogether.

http://www.rifftrax.com/rifftrax

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 80
Joined: 08/31/2007
Bug FinderInternationalizationizerNot KulvikThe other woman.

yeah, that's what i ended up doing. Smiling