10 replies [Last post]
j0sh's picture
Offline
Joined: 03/12/2008
Juice: 59
Was this information Helpful?

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?

j0sh's picture
Offline
Joined: 03/12/2008
Juice: 59
Re: add to cart doesn't work!

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?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: add to cart doesn't work!

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.

j0sh's picture
Offline
Joined: 03/12/2008
Juice: 59
Re: Re: Re: add to cart doesn't work!

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

please check now

tnx

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: add to cart doesn't work!

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

j0sh's picture
Offline
Joined: 03/12/2008
Juice: 59
Re: Re: Re: Re: Re: add to cart doesn't work!

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

Tanjerine's picture
Offline
Bug FinderInternationalizationizerNot KulvikThe other woman.
Joined: 08/31/2007
Juice: 235
same thing happening here.

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

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: same thing happening here.

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.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Just use links to the

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

--
Help directly fund development: Donate via PayPal!

Tanjerine's picture
Offline
Bug FinderInternationalizationizerNot KulvikThe other woman.
Joined: 08/31/2007
Juice: 235
Re: Just use links to the

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

zaraza's picture
Offline
Joined: 01/14/2009
Juice: 2
random product

Flower Shop. Product = name, price and photo(big photo in lightBox)
It's not good to sent buyer to product_node... we can see all we want to see in views.

May be some one know how to solve this problem?