• Resolved neilgee

    (@neilgee)


    Since the latest version of WP Super Cache I am finding a random issue with WooCommerce in that you can’t add a product to cart.

    No console errors.

    Clear the WP Super Cache and the cart adding process is fine for a period of time.

    By switching to an alternative cache plugin fixes the issue.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter neilgee

    (@neilgee)

    There is a reply from some one else on this which I got notified on – but for some reason it is not showing in this thread – it is as below:

    I’ve been having the same issue, and it’s random. I deactivated the plugin about 2 weeks ago when I realized that’s what was causing it, and then reactivated a few days later and it worked. Now it’s not letting me add products to the Woocommerce cart again, so I deactivated again…on all 20 sites I manage…a bit of a hassle.

    Plugin Support Erina (a11n)

    (@eri32s98)

    Hi @neilgee, sorry to hear about the issue. Were you able to test with just WooCommerce and WP Super Cache running? If the problem still happens then, could you activate the WordPress debug log and the WP Super Cache debug log, and see if any relevant info is there?

    Plugin Support Tamirat B. (a11n)

    (@tamirat22)

    Hello @neilgee,

    Do you have updates about that? We usually close inactive threads after one week of no activity, but we want to make sure we’re all set before marking it as solved. Thanks!

    Hi,

    I’m having the same issue. When a supercached page of a product loads I can’t add it to the cart. No errors. I’ve checked in local with only Woocommerce and WP Super Cache. Hoping this helps, the following text appears in the debug for that interaction:

    
    
    12:00:59 8668 / wpsc_is_rejected_cookie: found cookie: woocommerce_cart_hash
    12:00:59 8668 / Caching disabled because rejected cookie found.
    12:01:00 8668 /wp-cron.php?doing_wp_cron=1702987260.0208299160003662109375 wp_cache_postload: backend detected, not running
    12:01:25 8668 /product/sample-product-30ml wpsc_is_caching_user_disabled: false
    12:01:25 8668 /product/sample-product-30ml Supercache Late Init: add wp_cache_serve_cache_file to init
    12:01:25 8668 /product/sample-product-30ml Supercache Late Loader running on init
    12:01:25 8668 /product/sample-product-30ml ACCEPT: text/html
    12:01:25 8668 /product/sample-product-30ml wp_cache_get_cookies_values: return:
    12:01:25 8668 /product/sample-product-30ml supercache dir: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/product/sample-product-30ml/
    12:01:25 8668 /product/sample-product-30ml wp_cache_get_cookies_values: return:
    12:01:25 8668 /product/sample-product-30ml No wp-cache file exists. Must generate a new one.
    12:01:25 8668 /product/sample-product-30ml In WP Cache Phase 2
    12:01:25 8668 /product/sample-product-30ml Setting up WordPress actions
    12:01:25 8668 /product/sample-product-30ml Created output buffer
    12:01:25 8668 /product/sample-product-30ml wp_cache_get_cookies_values: return:
    12:01:25 8668 /product/sample-product-30ml wpcache_do_rebuild: doing rebuild for D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/product/sample-product-30ml/
    12:01:25 8668 /product/sample-product-30ml wpcache_do_rebuild: base file found: D:\my-path\dev.woocommerce\wp-content\cache\supercache\dev.woocommerce.lokala\product\sample-product-30ml/index-https.html
    12:01:25 8668 /product/sample-product-30ml wpcache_do_rebuild: base file found: D:\my-path\dev.woocommerce\wp-content\cache\supercache\dev.woocommerce.lokala\product\sample-product-30ml/index-https.html.gz
    12:01:25 8668 /product/sample-product-30ml Redirect detected. Caching disabled.
    12:01:25 8668 /product/sample-product-30ml wp_cache_maybe_dynamic: returned $buffer
    12:01:25 8668 /product/sample-product-30ml/ wpsc_is_caching_user_disabled: false
    12:01:25 8668 /product/sample-product-30ml/ Supercache Late Init: add wp_cache_serve_cache_file to init
    12:01:25 8668 /product/sample-product-30ml/ Supercache Late Loader running on init
    12:01:25 8668 /product/sample-product-30ml/ ACCEPT: text/html
    12:01:25 8668 /product/sample-product-30ml/ wp_cache_get_cookies_values: return:
    12:01:25 8668 /product/sample-product-30ml/ supercache dir: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/product/sample-product-30ml/
    12:01:25 8668 /product/sample-product-30ml/ wp_cache_get_cookies_values: return:
    12:01:25 8668 /product/sample-product-30ml/ Fetched gzip static page data from supercache file using PHP. File: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/product/sample-product-30ml/index-https.html.gz
    12:01:26 8668 /favicon.ico wpsc_is_caching_user_disabled: false
    12:01:26 8668 /favicon.ico Supercache Late Init: add wp_cache_serve_cache_file to init
    12:01:26 8668 /favicon.ico Supercache Late Loader running on init
    12:01:26 8668 /favicon.ico ACCEPT: text/html
    12:01:26 8668 /favicon.ico wp_cache_get_cookies_values: return:
    12:01:26 8668 /favicon.ico supercache dir: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/favicon.ico/
    12:01:26 8668 /favicon.ico No Super Cache file found for current URL: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/favicon.ico/index-https.html
    12:01:26 8668 /favicon.ico In WP Cache Phase 2
    12:01:26 8668 /favicon.ico Setting up WordPress actions
    12:01:26 8668 /favicon.ico Created output buffer
    12:01:26 8668 /favicon.ico wp_cache_get_cookies_values: return:
    12:01:26 8668 /favicon.ico wpcache_do_rebuild: doing rebuild for D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/favicon.ico/
    12:01:26 8668 /favicon.ico wpcache_do_rebuild: exiting as directory is not a directory: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/favicon.ico/
    12:01:26 8668 /favicon.ico Redirect detected. Caching disabled.
    12:01:26 8668 /favicon.ico wp_cache_maybe_dynamic: returned $buffer
    12:01:27 8668 /product/sample-product-30ml/ wpsc_is_caching_user_disabled: false
    12:01:27 8668 /product/sample-product-30ml/ Supercache Late Init: add wp_cache_serve_cache_file to init
    12:01:27 8668 /product/sample-product-30ml/ Supercache Late Loader running on init
    12:01:27 8668 /product/sample-product-30ml/ ACCEPT: text/html
    12:01:27 8668 /product/sample-product-30ml/ wp_cache_get_cookies_values: return:
    12:01:27 8668 /product/sample-product-30ml/ supercache dir: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/product/sample-product-30ml/
    12:01:27 8668 /product/sample-product-30ml/ wp_cache_get_cookies_values: return:
    12:01:27 8668 /product/sample-product-30ml/ Fetched static page data from supercache file using PHP. File: D:\my-path\dev.woocommerce\wp-content/cache/supercache/dev.woocommerce.lokala/product/sample-product-30ml/index-https.html
    Plugin Support Animesh Gaurav (a11n)

    (@bizanimesh)

    Hello @iurte – we are investigating this issue and will get back to you once we have an update.

    Also, from the next time, you can start your own thread, as per the forums welcome guide. ??

    @iurte @neilgee – Are you still using WP Super Cache? WooCommerce is supposed to disable caching on the shopping cart page, and it did that on my test site.

    The debug log shows that did not happen, so there’s something up.

    There’s a function called set_nocache_constants in woocommerce/includes/class-wc-cache-helper.php and that sets the DONOTCACHEPAGE constant. That function is called in various places in WooCommerce. Add the following to that function and then look in your error log or debug_log

    error_log( $_SERVER['REQUEST_URI'] . " not caching" );

    On a new install of WC, with default settings, /shop/ is not cached. When I add something to my cart, that’s not cached either.

    In the debug log viewer, uncheck “wp-json” in the exclude list and it will show you what happens when someone adds an item to their cart. That should say, “REST API detected. Caching disabled”. I would be very surprised if that wasn’t there.

    If it continues to be a problem, you could disable caching based on the cookies that WooCommerce uses. In the WP Super Cache advanced settings, go to the Rejected Cookies section and add the text “woocommerce” on one line. Make sure that caching is set to “simple caching”. That should help.

    Same issue. Here are a few data points:

    I can add a product to the cart from the category page, but not from the product page.

    If a product exists in the cart (i.e. added from the category page), then I can add a new product from a product page.

    “woocommerce” in the Rejected Cookies section did not help.

    If WP Super Cache caching is disabled, Woocommerce behaves normally.

    Edit:

    Unchecking “Late init” on the Advanced page seems to solve the issue.

    • This reply was modified 9 months, 1 week ago by omarfilip. Reason: Additional data point

    @omarfilip – interesting. Do you remember where you were told to enable late init? I wonder if WooCommerce added their own output buffer and it’s interfering with caching if “late init” is enabled.

    @donncha – I don’t. It may have been an errant click.

    Thanks. Good to know that solves it. As it’s a feature that has to be enabled, most site owners aren’t going to trip over it.

    This PR may fix the problem by checking if an output buffer is already active. Unfortunately, it disables caching for that page, but that’s preferable to a degraded user experience.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘WooCommerce cant add to Cart’ is closed to new replies.