Back to Community

How to Extend Guest Wishlist Duration in YITH WooCommerce Wishlist

32 threads Sep 16, 2025 PluginYith woocommerce wishlist

Content

If you've noticed that items in your visitors' wishlists seem to disappear after a short time, you're not alone. A common question from store owners using the YITH WooCommerce Wishlist plugin is about the lifespan of wishlist items for users who aren't logged in.

Why Do Guest Wishlists Expire?

Unlike registered users whose wishlists are stored permanently in the database, the YITH WooCommerce Wishlist plugin saves guest users' wishlists using browser cookies. By their nature, cookies have a set expiration date. The default duration for these wishlist cookies is not publicly documented, but they will eventually be cleared from the user's browser.

The Solution: Custom Code Snippet

Fortunately, the plugin provides a filter hook that allows developers to customize the cookie's expiration time. You can control how long a guest's wishlist persists by adding a small code snippet to your site.

Warning: Always use a child theme when modifying theme files. This prevents your customizations from being overwritten during theme updates.

  1. Access your WordPress admin dashboard.
  2. Navigate to Appearance > Theme Editor.
  3. Select your active child theme from the dropdown on the right.
  4. Locate and click on the functions.php file in the list of theme files.
  5. Paste the following code at the very end of the file:
if ( ! function_exists( 'yith_wcwl_cookie_expiration_custom' ) ) {
    function yith_wcwl_cookie_expiration_custom() {
        $seconds = 60 * 60 * 24 * 30; // 30 days in seconds
        return $seconds;
    }
    add_filter( 'yith_wcwl_cookie_expiration', 'yith_wcwl_cookie_expiration_custom' );
}

This code sets the wishlist cookie to expire after 30 days. You can adjust the duration by changing the value of the $seconds variable. For example, to set it to 60 days, you would calculate 60 * 60 * 24 * 60.

Important Considerations

  • User Experience: Extending the duration improves the experience for returning guests, but it is still a temporary solution. The most reliable way for customers to keep their wishlists forever is to create an account on your site.
  • Clearing Cookies: Remember that users can clear their browser cookies at any time, which will permanently erase their guest wishlist regardless of this setting.
  • Testing: After adding the code, test the functionality by adding items to a wishlist in a private/incognito browser window and checking if they remain after closing and reopening the browser days later.

This approach provides a straightforward way to give your guest customers more time with their saved items, encouraging them to return and complete their purchases.

Related Support Threads Support