Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
when both uc_aac and uc_ajax_cart are enabled - ajax_cart seems not to work.
when clicking the "add_to_cart" button - the product is added to the cart but not in ajax way, like if uc_ajax_cart isn't installed.
I solved the problem by commenting this code in uc_aac.js
// Update the add to cart form.
if (data.form) {
// var action = form.attr('action');
// $(form).after(data.form).next().attr('action', action).uc_aac_attach();
// form.remove();
}
but it caused this: when changing select attributes - prices do not rebuilt. Still thats better than non-ajax cart ))
Comment | File | Size | Author |
---|---|---|---|
#6 | uc_aac.js_.patch | 613 bytes | jm.federico |
#6 | uc_out_of_stock.js_.patch | 6.23 KB | jm.federico |
#6 | uc_ajax_cart.js_.patch | 631 bytes | jm.federico |
#7 | uc_aac.js_.patch | 382 bytes | jm.federico |
#7 | uc_ajax_cart.js_.patch | 894 bytes | jm.federico |
Comments
Comment #1
shtirluk CreditAttribution: shtirluk commentedAt least i found the better way:
each time after we update any attribute we myst bind click event to ajax_add_to_cart on product form submit button.
we do something like this:
// Update the add to cart form.
if (data.form) {
var action = form.attr('action');
$(form).after(data.form).next().attr('action', action).uc_aac_attach();
form.remove();
uc_ajax_cart_bindClick();
}
where uc_ajax_cart_bindClick() - is a function from ajax_cart module, containing main code:
function uc_ajax_cart_bindClick(){
$('input.ajax-submit-form, button.ajax-submit-form').bind('click',function(e){
var $form = jQuery(this).parents('form').eq(0);
var callbackID = $form.attr('id');
if ( $form.find('input[@name=uc-ajax-cart-callback]').length == 0 )
{
$form.append('')
}
var d = $form.formToArray();
var tagName = this.tagName ;
var button = jQuery(this);
if ( bText != false )
{
if ( tagName == "BUTTON" )
{
button.attr('oldTitle',button.html());
button.html(bText);
}
else
{
button.attr('oldTitle',button.attr("value"));
button.attr('value',bText);
}
}
button.addClass(bclass);
if ( disabled == 1 )
{
button.css({display : 'none'});
button.after('
');
}
$.post( Drupal.settings.basePath + 'cart/ajax/update',d,updateAjaxCart, 'json');
return false;
});
}
Comment #2
jantoine CreditAttribution: jantoine commentedHi shtirluk,
I don't believe this is not the correct way to handle this. The new uc_aac 6.x-2.x branch offers many ways for other modules to interact with it. The Ajax Cart module will need to leverage this ability to interact with the uc_aac module and perform the binding on it's own. I think this issue should be moved under the Ajax Cart module, but before I do that, I'll wait for a response in case I am missing something.
Cheers,
Antoine
Comment #3
jantoine CreditAttribution: jantoine commentedshtirluk,
Since I have not heard anything for over a month, I assume you have no disagreements with how this should be fixed, therefore I am moving this issue to the Ajax Cart module.
Cheers,
Antoine
Comment #4
l33roy CreditAttribution: l33roy commented#1 not a solution, because for example my code for ajax cart callback is:
So, how emplement your way of solution for me?
Comment #5
jm.federico CreditAttribution: jm.federico commentedChanging name to reflect change of project.
Comment #6
jm.federico CreditAttribution: jm.federico commentedPlease check comment #7 as I reviewed my patch, changed it to make use of
Explanation in next comment.
Ok, so I came up with a solution. This is a fix for the following problems:Using:
Ubercart ajax cart 6.x-1.0
Ubercart Ajax Attribute Calculations 6.x-2.0
Ubercart Out of stock Notification 6.x-1.4
Ubercart Ajax Attribute Calculations - uc_aac (http://drupal.org/project/uc_aac) is conflicting with this modules (Ubercart ajax cart - uc_ajax_cart) and with Ubercart Out of stock Notification - uc_out_of_stock (http://drupal.org/project/uc_out_of_stock).
The problem is that uc_aac creates a new form when you change an attribute, and this new form is not captured by any modules that relays on
jQuery(document).ready(function()
to capture forms without providing a function which can be called back when new forms are added to the page.How to fix it:
First I changed uc_ajax_cart.js and wrapped the init code into a function, which I callajaxCartInitCart
and I call it once the document is ready. Also, this new function gets a parameter which will be the selector for the form to modify. This way when I call it for the first time I call it like thisajaxCartInitCart('form.ajax-cart-submit-form');
giving a selector for every form on the page.I then modified uc_aac.js so that every-time a new form is added to the page, the function gets called like this:ajaxCartInitCart('#'+form.attr('id'));
This way I'm making sure that only the new form is checked by uc_ajax_cart. I also put a validation so that the function only gets called if it is defined already, which happens only if the other module is installed (and my patch applied)Same thing happened with uc_out_of_stock. I first wrapped the init code in two functions and then called them when needed.I'm posting patches so you can check what is going on and apply to your like.
I invite the developers of the 3 modules to commit this changes as there are plenty like me who really want them all working together.
Love to all!
Comment #7
jm.federico CreditAttribution: jm.federico commentedOk, so new PATCH, it is the same concept as in my previous post, BUT I now use
Which means that we need no validation for pre-existing modules and it just works! HURRAY for Drupal coding standards!
I contacted the developers of each module but just in case HELP ME SPREAD THE WORD. What I just did is actually how the modules should have been in the first place!
PLEASE COMIT THIS!
Comment #8
hanoiiHi Federico,
I am the maintainer of uc_out_of_stock.
Thanks for the patches, however, I feel this is not the way to go.
No module should rely on other module to work. If on each of these three modules you use functions from the others, you are forcing the users of each module to install the others.
We are aware of the incompatibility problems introduced by uc_aac 2.0 when removing the form. There's one way to fix this, at least partly, in a proper way which is being discussed on #697976: JS behavior of removing the form is a bit aggressive for other third-party modules..
And particulary in http://api.drupal.org/api/drupal/developer--topics--javascript_startup_g....
The idea is to use Drupal.behaviors instead of document ready, which is the recommended method for drupal and uc_aac should call Drupal.attachBehaviors(). I already tried some fixing around this and although this works, there's a few other isses because uc_aac and uc_out_of_stock both modifies the same form.
I will submit a patch there for uc_aac and eventually fix my own module to use the behaviors object as that's the way to go, although uc_aac with uc_out_of_stock will require more fixing.
Comment #9
jm.federico CreditAttribution: jm.federico commentedHi Hanoii
Actually my second patch works the way it should. No module relies on the others. What I did was actually making them all use the
Drupal hook.
You can update your module and it will work with no problem regardless of the others. My patch only changes the way your code is called. Now, what happens is that EVERY module should use this convention.
If you check my second patch for your module you'll see that I does not need any other module to be installed in order to work, it is right the opposite it makes it work with every module (that follows Drupal JS conventions).
This is true for the 3 patches I submit. Please check the second post and the patches.
Comment #10
hanoii@jm.federico: Ok, it seems that I missed you second post. Anyway, I don't see why the need for changing other than the behaviors part, (at least for now and for my module) and I fixed that yesterday on uc_out_of_stock.
uc_aac seems fine, except it should also use Drupal.behaviors besides Drupal.attachBehaviors(). see http://drupal.org/node/697976#comment-2605178 where I submitted a patch similar to yours but with that bit also fixed. There are still issues to be fixed between uc_aac and uc_out_of_stock but better to follow discussion on that on uc_aac issue queue.
And I don't use uc_ajax_cart to comment on it.
a.=
Comment #11
fredklopper CreditAttribution: fredklopper commentedHi Federico,
Maybe I'm missing something but: where can I find the file to be patched with uc_ajax_cart.js_.patch?
Thanks,
Fred
Comment #12
Erik Seifert CreditAttribution: Erik Seifert commentedWill be fixed in 2.0-BETA1. But you need still need
uc_aac.js_.patch from #7
I have contact the developer of uc_aac .
Comment #13
jm.federico CreditAttribution: jm.federico commented@fredklopper
Each patch is for a different module. The one you mention is located under modules/uc_ajax_cart/js/uc_ajax_cart.js
Hope this helps.
@erikseifert
Thanks
Federico
Comment #14
Erik Seifert CreditAttribution: Erik Seifert commentedFrom 2.0 - beta1 you only need to patch uc_aac module.
Comment #15
fredklopper CreditAttribution: fredklopper commented@Federico
Thanks, I was looking at the files in Ajax Cart 1.0 :-(
Fred
Comment #16
FranCarstens CreditAttribution: FranCarstens commentedWould it be difficult to get this to work with UC Attribute Stock Filter?
Comment #17
jday CreditAttribution: jday commented#7 patch failed for me:
File to patch: js/uc_ajax_cart.js
patching file js/uc_ajax_cart.js
Hunk #1 FAILED at 13.
Hunk #2 FAILED at 24.
2 out of 2 hunks FAILED -- saving rejects to file js/uc_ajax_cart.js.rej
Comment #18
tunicThis bug has been tested using Ubertcart Ajax Cart 2.0-beta5 with Ubercart Ajax Attribute Calculations 6.x-2.1 and seems to be not present.
#17 jday you don't need to patch module, it seems maintainers already patched the code. Please use Ubercart Ajax Attribute Calculations 6.x-2.1 and test.
I'm closing this bug, reopen it if problem presists.