The Finder module creates a nice search view for Ubercart shopping cart. But the "Add To Cart" buttons that appear next to the product image doesn't update the shopping cart. It does cause the page to refresh, but nothing else appears to happen. Am I missing something? Do I need to change the Product View?

Comments

danielb’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

I don't use ubercart so I can't tell you. I doubt Finder is doing something wrong, but if you find that it is, let me know what that is.

Old Man’s picture

I don't know much about PHP, just hacking the code as I need to fix things. But I am wondering if I need to print the URL that goes with the button field? I'll post on Ubercart site to see if I get any hits.

Old Man’s picture

You are right - it is the Views in Ubercart causing the problem. If I try adding a product directly from the Ubercart Product View, I get teh same result. So this has nothing to do with Finder.

danielb’s picture

Title: Add To Cart buttons in Ubercart view created with Finder won't add to shopping cart » Add To Cart in View won't work
Project: Finder » Ubercart
Version: 6.x-1.7 » 6.x-2.x-dev
Component: Finder Views » User Interface
Status: Postponed (maintainer needs more info) » Active

OK I'll move this to the ubercart issues.

meba’s picture

I can confirm this issue, however not with views, but with ApacheSolr. I am testing solr + ubercart and created an add to cart button in solr results.

The problem seems to be in the fact that validate/submit handler for add to cart is NEVER called, therefore it doesn't work.

I found out that if I do sometihng like:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
 if (preg_match("/uc_product_add_to_cart_form/", $form_id)) {
      $form['#action'] = '/?q=node/4';
  }
}

and click add to cart in results on node !4!, it works. It does not when clicking on node 3. Seems the button only works if the page that loads after clicking the button contains that product.

Old Man’s picture

I created a Views search that works well, and the Add To Cart button behaves properly. The only problem with this is that the Search function is too specific in that it will only search for the exact term typed into the argument. Too bad that Views Search doesn't include "starts with" or "contains in" arguments.

myregistration’s picture

subscribing

sagar ramgade’s picture

Hi,
I was facing the same problem with add to cart button not adding the product to the cart on a custom form (http://deccan.iksuladev.com/product-help). I managed to get it working by adding a hook_form_alter state below :
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if (preg_match("/uc_product_add_to_cart_form/", $form_id)) {
$form['#action'] = url('node/' . $form['nid']['#value']);
}
}

torgospizza’s picture

Status: Active » Postponed (maintainer needs more info)

#8: I don't think that's the same issue.

Also, I don't think necessarily "Add to Cart Buttons don't work" is accurate. We are using Views here: http://rifftrax.com/rifftrax and there are no problems; however if I turn caching on in the View itself, then the forms break.

To others reporting this issue, can you provide your Views versions and what other Ubercart-related modules (or custom code) you're running?

tr’s picture

Sounds to me like the same problem that Views random has with *every* form, not just Ubercart forms. See #391534: Fails to add to cart when using views global:random display.

So my question would be, does Finder work properly with other forms?

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Due to lack of follow-up, I'm going to assume this issue is settled.

krisrobinson’s picture

I had this problem, but as in #9 it was when caching on the view itself was enabled, the addtocart form broke.

stoob’s picture

I can confirm that caching will break the 'add to cart' buttons on a page display View that lists multiple products. Turn cache off completely on this view.

jawi’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Assigned: Unassigned » jawi
Priority: Normal » Major

Is their a sollution to get the add-to-cart button to work in a catalog view with caching on?

torgospizza’s picture

Version: 7.x-3.x-dev » 6.x-2.x-dev
Assigned: jawi » Unassigned
Priority: Major » Normal

You should open a new issue for that instead of re-opening a ticket that's been closed for months.

jawi’s picture

reopening issue

the status is still the same as in http://drupal.org/node/1777452

fabio84’s picture

Issue summary: View changes

I'm not sure if I had the same issue of the original poster, as I don't have the Finder module, but I have to thank Sagar Ramgade for his code at comment #8 because it solved my issue and made me understand why the add to cart button sometimes worked and sometimes not. It works even with Drupal 7

In fact my view did not show always the same products, and apparently the form works only if it is submitted to a page that loads the form, so when the same page with the view is reloaded after the form submission it may not load the same form for the same product making submission fail.

Probably if the finder view doesn't show always the same products this is the same issue cited at comment #10 : #391534: Fails to add to cart when using views global:random display

I think Ubercart could be fixed making the add to cart form always submitting to the product page, where the add to cart form should be always loaded.

millionleaves’s picture

I was experiencing this issue too. This comment on the issue mentioned in #10 provided the solution for me, which is to use Views Random Seed to generate/regenerate a random selection for the view after a specified time. It's not perfect since it's possible that the view could be regenerated between someone loading the view and clicking the Add to Cart button, but you can reduce the likelihood of this happening by increasing the seed. In my case, I'm happy regenerating the view once a day.

https://www.drupal.org/node/391534#comment-5553016