Support » Plugin: W3 Total Cache » Breaks WooCommerce “Return to shop” button

  • Resolved taisho

    (@taisho)


    I’m sure it’s W3 Total Cache, because if I deactivate only this plugin, it works. Also I had no such problem with WP Fastest Cache installed (I switched plugins for test, I think that responses are slightly faster and more stable with W3 Total Cache).

    It happens on removal of the last remaining item in cart (cart page), I only tested not logged user. Text lands outside of black button (“Wróć do sklepu”), making it a black rectangle. If I refresh this cached page, all appears correctly. Is this plugin supposed to work with cart, checkout and my account page cached (assuming that pages for logged in users are NOT cached in my settings)? WooCommerce docs claim that these pages don’t need to be excluded:

    https://docs.woocommerce.com/document/configuring-caching-plugins/

    So why is my cart cached actually and not acting properly?

    • This topic was modified 8 months, 3 weeks ago by taisho.
    • This topic was modified 8 months, 3 weeks ago by taisho.

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,

    Yes, WooCommerce should set DONOTCACHEPAGE constant to their pages.
    However, can you try to exclude that page from being cached in Performance>Page Cache, Advanced sub-box, “Never Cache following pages:”
    i.e.
    /cart/
    /shop/
    /checkout/
    Alternatively, disable Minify in Perofrmance>General settings (if enabled) and see if the issue persists.

    Thanks for fast answer, I tested both localized and English directory names in pattern as posted above, saved settings & purged cache, opened new incognito session and problem persisted. Why is there shop in your post instead of my account, as in WooCommerce docs by the way?

    I don’t have W3 Total Cache minification enabled, but since you mentioned it, I opened Autoptimize settings and unchecked the following:

    Also optimize shop cart/ checkout? ============>
    By default Autoptimize is also active on your shop’s cart/ checkout, uncheck not to optimize those.

    Then purged caches, it worked. Considering that deactivation of W3 Total Cache also resolves issue while leaving Autoptimize going, there is a conflict between Autoptimize and W3 Total Cache.

    Update: I further checked that it’s specifically Autoptimize’s “Optimize HTML code” what causes conflict, because if I uncheck it and only have JS and CSS files optimized, Autoptimize works together with W3 Total Cache even with “Also optimize shop cart/ checkout?” checked. I use Cloudflare and have this extension configured within W3 Total Cache. Hopefully this helps.

    • This reply was modified 8 months, 3 weeks ago by taisho.
    • This reply was modified 8 months, 3 weeks ago by taisho.
    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,

    Can you please check your Cloudflare settings, and see if Minify JS, Minify CSS and Minify HTML is enabled?

    They are all off, I’ve always used Autoptimize for this purpose.

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,

    There’s an error on this page and I think that’s the cause of your issues. Please check the screenshot.
    There’s a duplicate function declaration

    Thanks for looking at the website. Unfortunately the reason for this button issue is plugin conflict which I described earlier, caused by Autoptimize’s “Optimize HTML code” which makes W3 Total Cache cache pages it’s not supposed to.

    The website I provided is personal unreleased website for tests and development. It had some HTML and JS errors because I’m in the process of converting part of functions.php code to plugins. I’m sorry for this mess, I moved my testing page to /staging directory and now under link which I provided before, you can see clean version without errors or white screens of death when I change something, which still has button issue. I purged all caches.

    • This reply was modified 8 months, 3 weeks ago by taisho.
    • This reply was modified 8 months, 3 weeks ago by taisho.
    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello @taisho,

    Thank you for your feedback. It appears that the issue indeed is in W3 Total Cache. What happens is that W3 Total Cache HTML minifier removes the quotes around href in
    <a class="button wc-backward" href=https://parymet.pl/> but it should not do this in this case because the trailing slash makes HTML believe it’s a tag closing slash.
    This will be fixed in a future release, but for now as a workaround, add the following In wp-content/plugins/w3-total-cache/lib/Minify/Minify/HTML.php replacing lines 346 and 347 with
    $m[2] = preg_replace( '/([a-z0-9]=)\'([^"\'\\s=]+[^"\'\\s=\\/])\'(\\s(?!\\/)|>)/i', '$1$2$3', $m[2] );

    $m[2] = preg_replace( '/([a-z0-9]=)"([^"\'\\s=]+[^"\'\\s=\\/])"(\\s(?!\\/)|>)/i', '$1$2$3', $m[2] );

    Many thanks, after change it works perfectly!

    Hello, it’s been 2 versions since this issue wasn’t addressed in plugin updates. Can I expect a solution to be included in the core with the next release?

    Kind Regards

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Breaks WooCommerce “Return to shop” button’ is closed to new replies.