• Resolved bbceg

    (@bbceg)


    Hi,

    Hope you can help.

    I have opted to “Enable AJAX add to basket buttons on archives” in the woocommerce settings.

    However when clicking add to basket on a product archive a shaded background and spinner appear before the page reloads completely.

    If I disable the Stock Locations for Woocommerce plugin the ajax add to basket buttons work as expected and the page does not reload.

    What’s more, if I disable the ajax add to basket functionality I still see the shaded background and spinner and the process of adding products to the basket is therefore slower than it might be.

    Can this behaviour be disabled?

    • This topic was modified 2 years, 8 months ago by bbceg.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Fahad Mahmood

    (@fahadmahmood)

    @bbceg yes, we can make it optional but please record a video of your experience so I can reproduce this issue on my side.

    Thread Starter bbceg

    (@bbceg)

    Thanks @fahadmahmood

    Link available here:
    https://privnote.com/Ix5VZpHZ#ACfkVWEPQ

    Note how the buttons reset each time and the ‘View Basket’ links disappear.

    To reproduce simply navigate to an archive page with the ajax setting enabled in Woocommerce and click Add to Basket. If that’s not happening for you then perhaps something else is going on.

    If you have a filter to disable this behaviour that’s fine with me, I don’t need an option in the UI.

    Thanks.

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    @bbceg I didn’t get it yet. Can you please add your voice to this video? You are adding to the basket and both buttons are behaving same, please explain a little more. If you want me to test it with you, please use the urgent help option under the help tab on settings page.

    Thread Starter bbceg

    (@bbceg)

    @fahadmahmood

    There’s not too much to say but I will try and explain here ??

    I’m trying to prevent the whole page from reloading. You can tell this has happened in the video because the ‘View Basket’ links disappear from underneath the ‘Add to Basket’ buttons. With the plugin disabled the page does not reload and these links do not disappear.

    Perhaps you could show me what happens when you do the same in your install (both with the woocommerce ajax add to basket archive buttons enabled / disabled)?

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    I got it, actually this functionality was added for a client where his requirement was to reload the page after add to cart action.

    Comment the following lines for now:

    js/common.js line no. 86

    Thread Starter bbceg

    (@bbceg)

    Thanks @fahadmahmood your fast response is always appreciated.

    While this does prevent the page reloading I get left with an eternally spinning spinner! ?? Fortunately commenting out line no 83 sorts that:
    //$.blockUI({message:''});

    Incidentally, it looks like the plugin is attempting to check stock levels for the product at the location specified but I don’t think it will ever succeed in my case. This is because I’m managing the user’s selected location externally to your plugin – I ask the user for their location and set this via a cookie. I then do stock checks / display on the sever by hooking into the relevant Woocommerce filters and using your SlwStockAllocationHelper::getProductStockLocations function.

    Do let me know if you see any problems with this approach.

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    There should be another line something like this:

    document.location.reload();

    you need to comment it

    Thread Starter bbceg

    (@bbceg)

    @fahadmahmood Thanks I did that one, I just wanted to point out that I also had to comment out the blockUI line to prevent the overlay from appearing. In reality I can comment out the whole block from 83-89:

    // $.blockUI({message:''});
    // $.post($(this).prop('href'), {}, function(){ 
    // 	//document.location.href = slw_frontend.cart_url;
    // 	document.location.reload();
    	
    // });

    Thinking about it, with my use-case above in mind, I may even be able to get away with dequeuing the common.js file entirely.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Ajax add to basket broken (page reloads)’ is closed to new replies.