• hello

    I have a problem with the edd add to cart button. It works fine for a period like one, two or three days and sometimes for just some hours, and then it stops working and I have just a turning circle, anything happens when you click the button. please take a look at this video to understand more:

    To resolve this problem, I must go to the wp rocket plugin and clear the cache manually, then the add to cart button works again. please see this video that shows how the button works after clearing the cache.

    I have this problem for a long time but it took 3 or 4 days to stop working but now it happens every day that’s why I’m here to find the cause and resolve it with your help.

    I tried many browsers, in incognito, with desktop, mobile… cleared browser cache… the only thing who resolve temporary the problem is to go to wp rocket plugin and clear the cache.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 16 through 30 (of 36 total)
  • Thread Starter emyabdel

    (@emyabdel)

    I never tried to run the site without WP Rocket deactivated and test if the button works without problems because the site is working now, I will try this later.

    To verify the WP Rocket configuration, I took screenshots of all my settings.
    I use also Autoptimise plugin to cache JavaScript and I did the same for its settings (took screenshots).

    Please download the file that contains settings images from this link and tell me if there’s something wrong. Thanks so much

    https://drive.google.com/uc?id=118yRLD-sZhH5Vy3jb79b7x816ciHovFi

    Thread Starter emyabdel

    (@emyabdel)

    Last update after test:

    I disabled wp rocket and edd button worked well so it’s a wp rocket problem.

    • This reply was modified 4 years, 5 months ago by emyabdel.

    Hi @emyabdel

    Thanks for the update.

    Just one thing to confirm that have you tried this with WP Rocket.
    define( 'EDD_USE_PHP_SESSIONS', false );

    Please refer below documentation link. May this help.
    https://docs.easydigitaldownloads.com/article/501-edd-use-php-sessions

    Any feedback from WP Rocket plugin team?

    Thread Starter emyabdel

    (@emyabdel)

    I never tried this before.

    So I added this in wp-config.php:
    define( ‘EDD_USE_PHP_SESSIONS’, false );
    just before:
    /* That’s all, stop editing! Happy publishing. */

    I set again lifespan to 30 to test if the add to cart will crash or not.

    I will contact wp rocket team if I don’t find a solution here, but I feel that this one is the solution.

    Waiting the result

    Thread Starter emyabdel

    (@emyabdel)

    My feeling was wrong and I still have this problem. I will look at the wp rocket support side. Pratik Jain Thank you very much for your help and if one day I find a solution I will try to post it here.

    Hi,

    I have had the same problem with WP Super Cache (+ Autoptimize) for some time.

    When you click the button Add to Cart, the loading icon keeps on turning forever and does not add the product to the cart.

    Until I clear the cache, then everything works fine.

    I have already tried
    define( 'EDD_USE_PHP_SESSIONS', false );
    but nothing changes.

    Thanks for your help!

    Florian maybe check the browser console for JS errors and/ or test with JS optimization off in Autoptimize, you might have to exclude some JS from being optimized?

    frank (ao dev)

    Thread Starter emyabdel

    (@emyabdel)

    Florian Bansac: I thought that I’m the only one who has this problem.

    Like Optimizing Matters said, I disabled autoptimize js optimization, make it just with wp rocket, and set lifespan to 30.

    I will try and give feedback.

    What JS to exclude exactly from being optimized?

    Well you could start with excluding wp-content/plugins/easy-digital-downloads/ (making sure all JS optimization is off in WP Rocket to avoid conflicts). If it does not work, do check the browser console for JS errors and report back here?

    Thread Starter emyabdel

    (@emyabdel)

    Ok I will test and report back here, Thanks.
    PS: The solution should be found with JS optimizations on in wp rocket, if it’s off it’s bad for site speed, so I can’t turn them off forever.

    • This reply was modified 4 years, 4 months ago by emyabdel.

    Well, the JS optimization is disabled for now, will see if the problem happens again.
    But it’s not a great situation to downgrade other plugins. Is there a specific JS script that I can include in the exclusion list?

    Autoptimize proposes this option:

    A comma-separated list of scripts you want to exclude from being optimized, for example 'whatever.js, another.js' (without the quotes) to exclude those scripts from being aggregated by Autoptimize. Important: excluded non-minified files are still minified by Autoptimize unless that option under "misc" is disabled.

    Anyway, I still have another longer-standing problem with the EDD cart (with EDD cart widget and WP Cart Menu) not updating on the home page when downloads are added/removed. (…On the Home Page only, even though I have double-checks for the home page option ON in the WP Super Cache options.)

    Thanks for your help!

    Actually, on second check, disabling the JS optimization in Autoptimize makes the behavior of the cart widget worse: pages do not reload anymore when downloads are removed.

    Reenabling the JS optimization for now.

    Will keep on checking if downloads buttons are ineffective and clear cache if yes.

    + I still have the problem of the cart not updating on the Home page when adding/removing downloads, and some archive pages too (single posts and downloads pages seem to work OK)

    Very suboptimal though.

    Any help welcome!

    Hi @floarchi @optimizingmatters @emyabdel

    I think it is not JS issue or error so excluding JS will not help here. I think the issue is nonce (security).

    Let me explain with some screen shot.
    https://prntscr.com/tcjvk2

    I know it is a developer term but I try my best to explain this. As you can see there is a “data-nonce” attribute. This is a WordPress nonce security (Security Salt).

    EDD uses this to validate the request. This nonce is automatically created and change after some time.

    So I think that when cache plugin caches the page then visitor can see the cached version. The nonce is old and it can not validate the request for add to cart.

    I hope this will help you to understand the issue more clearly.

    ———–

    While checking the code I found that in EDD we can disable the AJAX. But it will change the behavior of cart page. EDD will not use AJAX on any of its functionality.

    Please try below code

    function __edd_is_ajax_disabled( $ajax ) {
    	return true;
    }
    add_filter( 'edd_is_ajax_disabled', '__edd_is_ajax_disabled' );

    I know you will not not like the cart behavior without AJAX. So I have applied a little tweak on above function so it will only disable the AJAX on single product page. It means on click of button.

    function __edd_is_ajax_disabled( $ajax ) {
    
    	if( is_singular('download') ) {
    		return true;
    	}
    
    	return $ajax;
    }
    add_filter( 'edd_is_ajax_disabled', '__edd_is_ajax_disabled' );

    Note : Please check with any of the above code snippet. You need to put this code to your theme / child theme functions.php file

    I hope this will work.

    Hi Pratik,

    Thanks for the support, but disabling the AJAX is not a good idea.

    People who click on the button don’t see any result… the product may be added to the cart, but if you don’t see it, it looks like it doesn’t work. And no one would ever buy anything from a website that looks broken.

    + it doesn’t solve my home page cart problem not being updated.

    Thread Starter emyabdel

    (@emyabdel)

    Thanks for all the solutions. For me, I will go step by step, I disabled js from autoptimize yesterday night and the button is still working until now. While it stops working I will try the next solution and give feedback.

Viewing 15 replies - 16 through 30 (of 36 total)
  • The topic ‘problem with add to cart button’ is closed to new replies.