If you use the YITH WooCommerce Wishlist plugin, you may notice some random issue with caching where the most common is the wish list being cached and not showing the correct products.

YITH WooCommerce Wishlist works with a cookie. The solution to avoid problems with caching is to create a must-use plugin for this. Just create a simple PHP file like this:

/**
* Plugin Name: AWD Prevent Caching if cookie
* Plugin URI: https://www.alentejowebdesign.nl
* Description: Prevent Caching if cookie
* Author: Fred van der Meijde
* Author URI: https://www.alentejowebdesign.nl
* Version: 1.0
*/

//
if( !defined( 'ABSPATH') ) exit();

isset( $_COOKIE['yith_wcwl_products'] ) && define( 'DONOTCACHEPAGE', true );

 

You can replace Plugin Name and Description to something else. You will see it when you go on WP dashboard/plugins under Must-use plugins. Don’t put closing PHP tag ?> at the end of file because it can make unwanted ‘white-scape’ in HTML code.

Then just upload it in wp-content/mu-plugins/ (Create this directory if it doesn’t exist). You can choice any filename.

Also, it’s possible to add more code there if you need it.



24/7 SUPPORT