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
Comments
Comment #1
tr commentedI'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.
Comment #2
peternickol commentedThanks for your help. I did a fresh install today and was able to recreate the problem by enabling "Cache pages for anonymous users"
Comment #3
peternickol commentedI 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.
Comment #4
strings6 commentedHello,
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!
Comment #5
peternickol commentedYep, 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.
Comment #6
strings6 commentedIs anyone going to look into this one for us?
Comment #7
longwavePlease 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.
Comment #8
strings6 commentedHello,
Thank you, longwave! The patch in #7 works for me.
Much appreciated.
Comment #9
longwave@andsub: can you test this patch as well?
Comment #10
peternickol commentedYes, I tried the patch this morning and it has resolved the issue. Thanks longwave!
Comment #12
longwaveCommitted to 7.x-3.x, needs porting to 8.x-4.x.
Comment #13
tr commentedComment #14
allysin commentedAny update on the port to D8 for this patch?