I have an Ubercart site that relies heavily on attribute options. After updating Drupal core i'm having some problems getting the display price to update for anonymous users. Authenticated users work fine. 7.26 works fine.

If I am an anonymous user the first attribute option I select will not update the price, the ajax throbber goes like normal, but the display price remains unchanged. Add it to cart, price is correct. Select another option from a separate attribute on the same product and both attributes start calculating properly.

I was digging through what changed in the last few releases and thought the problem might be related to this:
https://drupal.org/node/2242663

Files: 
CommentFileSizeAuthor
#7 2265875-anonymous-ajax-fix.patch835 byteslongwave
PASSED: [[SimpleTest]]: [MySQL] 2,939 pass(es). View

Comments

TR’s picture

Version: 7.x-3.6 » 7.x-3.x-dev

I'll try to reproduce this. We don't actually use ajax_get_form() in Ubercart, so the exact situation in that change notice doesn't apply, but change notices are notoriously poor at describing all the impacts of a core change. I'll have to look into the original core issue and the patch that was applied in that issue to see if I can figure this out.

andsub’s picture

Thanks for your help. I did a fresh install today and was able to recreate the problem by enabling "Cache pages for anonymous users"

andsub’s picture

I was able to work around the problem by using the UC Add to Cart Block module to render the add to cart form. I can confirm that the problem I described affects both the stable and dev versions of ubercart.

strings6’s picture

Version: 7.x-3.x-dev » 7.x-3.8

Hello,

I'm having the same problem as the original poster with the latest version of Drupal (7.38) and the latest recommended version of Ubercart (7.x-3.8), but I do not want to use https://www.drupal.org/project/uc_add_to_cart_block, or turn off page caching for anonymous users, if I don't have to.

Here is an example page:
https://www.gandy.net/sweep-master-turf-brush-aluminum-deck-special-order

The first time you change "Sweep Master Hitch Packages", the price doesn't update. If you change the drop down again, even back to -Select-, it works fine from that point on. Any ideas, TR or longwave?

Thanks!

andsub’s picture

Yep, never did find a solution to this other than the workaround i mentioned. It affects all of my ubercart sites. I eventually just dropped ajax price calculations entirely and moved to doing it via javascript. It would be nice to see this resolved.

strings6’s picture

Is anyone going to look into this one for us?

longwave’s picture

Version: 7.x-3.8 » 7.x-3.x-dev
Status: Active » Needs review
FileSize
835 bytes
PASSED: [[SimpleTest]]: [MySQL] 2,939 pass(es). View

Please test the attached patch. Form state is no longer valid for Ajax callbacks coming from anonymous cached forms, so the product variant was not correctly calculated when the add to cart form was first rebuilt. I think this code could do with a further overhaul in general, but this seems to fix the issue for me.

strings6’s picture

Hello,

Thank you, longwave! The patch in #7 works for me.

Much appreciated.

longwave’s picture

@andsub: can you test this patch as well?

andsub’s picture

Yes, I tried the patch this morning and it has resolved the issue. Thanks longwave!

  • longwave committed fd95ac7 on 7.x-3.x
    Issue #2265875 by longwave: Drupal 7.27+ breaks attribute ajax display...
longwave’s picture

Version: 7.x-3.x-dev » 8.x-4.x-dev
Status: Needs review » Patch (to be ported)

Committed to 7.x-3.x, needs porting to 8.x-4.x.

TR’s picture

Issue tags: +beta blocker
allysin’s picture

Any update on the port to D8 for this patch?