I'm running Ubercart 7.x-3.1 and rolled on the "Ajax-ify attribute option" patch #51 from here. It works and price gets updated. But I think I found a bug and the last message in that thread says to post new topics since its now rolled into UC itself.

I have multiple attributes on each item and they are all set as "radio buttons" with 3-5 options on each attribute. They all have a default value and are not "required".
If I start selecting multiple attributes (not multiple options in an attribute! but actual different attributes rapidly one after another) it seems like all of the attributes are getting selected and throbber is rotating on all of them. But once they actually finish only the last clicked attribute is selected and all others are set to the default value. Even if I individually selected different option for different attributes and am now changing multiple attributes to a different value it will still reset back to default.

Please let me know if you need additional information to reproduce.

Comments

longwave’s picture

I think this is a general issue with the way Drupal's core Ajax functionality works, unfortunately. Perhaps we can disable the attribute form while an Ajax request is in progress?

stewart.adam’s picture

Issue summary: View changes

I'm hitting this issue as well, but in my case it's that required attributes. If a user selects an option for a required attribute (in a select drop-down attribute type) and clicks Add to cart immediately, the form says that the attribute field was missing/is required because AJAX didn't have time to update the form with the user's selection.

I looked into writing a patch for this but hooking into '#ajax' on a form element would appear to be impractical at best... I've implemented this workaround for now, as the website's product pages don't have any other AJAX calls:

jQuery(document).ajaxStart(function() {
  jQuery('form[id^=uc-product-add-to-cart-form] *').addClass('form-disabled').filter(':input').attr('disabled', 'disabled');
  jQuery('form[id^=uc-product-add-to-cart-form] input[type=submit]').val('Loading...');
})

jQuery(document).ajaxComplete(function(event, xhr, settings) {
  /* executes whenever an AJAX request completes */
  jQuery('form[id^=uc-product-add-to-cart-form] *').removeClass('form-disabled').filter(':input').removeAttr('disabled');
  jQuery('form[id^=uc-product-add-to-cart-form] input[type=submit]').val('Add to cart');
});