How to Extend Guest Wishlist Duration in YITH 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.
- Access your WordPress admin dashboard.
- Navigate to Appearance > Theme Editor.
- Select your active child theme from the dropdown on the right.
- Locate and click on the
functions.phpfile in the list of theme files. - 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
-
Yith Wishlist PDF templatehttps://wordpress.org/support/topic/yith-wishlist-pdf-template/
-
Get message when product return to shophttps://wordpress.org/support/topic/get-message-when-product-return-to-shop/
-
filter propertieshttps://wordpress.org/support/topic/filter-properties/
-
Wishlist / Favouritehttps://wordpress.org/support/topic/wishlist-favourite/
-
Notification for adding a Producthttps://wordpress.org/support/topic/notification-for-adding-a-product/
-
Own Wishlist Pagehttps://wordpress.org/support/topic/own-wishlist-page/
-
Data retrieve for mobile apphttps://wordpress.org/support/topic/data-retrieve-for-mobile-app/
-
Add a wishlist item from a formhttps://wordpress.org/support/topic/add-a-wishlist-item-from-a-form/
-
Product duplicats in wishlist after loginhttps://wordpress.org/support/topic/product-duplicats-in-wishlist-after-login/
-
YITH Wischlist Fly cart – (example Screenshot link)https://wordpress.org/support/topic/yith-wischlist-fly-cart-example-screenshot-link/
-
After remove item from cart add item to Wishlisthttps://wordpress.org/support/topic/after-remove-item-from-cart-add-item-to-wishlist/
-
Does sharing a wishlist allow others to purchase items and have them sent to me?https://wordpress.org/support/topic/does-sharing-a-wishlist-allow-others-to-purchase-items-and-have-them-sent-to-me/
-
Add to wishlist link in woocommerce templatehttps://wordpress.org/support/topic/add-to-wishlist-link-in-woocommerce-template/
-
Does Yith WooCommerce Wishlist support WPML or Polylang?https://wordpress.org/support/topic/does-yith-woocommerce-wishlist-support-wpml-or-polylang/
-
wishlist durationhttps://wordpress.org/support/topic/wishlist-duration/
-
I can’t integrate YITH WooCommerce Wishlist with wp formshttps://wordpress.org/support/topic/i-cant-integrate-yith-woocommerce-wishlist-with-wp-forms/
-
Do you have plans to support WC Bookings?https://wordpress.org/support/topic/do-you-have-plans-to-support-wc-bookings/
-
Get products on wishlist in PHPhttps://wordpress.org/support/topic/get-products-on-wishlist-in-php/
-
Query ID or other way to display ACF field in Wishlist pagehttps://wordpress.org/support/topic/query-id-or-other-way-to-display-acf-field-in-wishlist-page/
-
How to display Wishlist button in WP query?https://wordpress.org/support/topic/how-to-display-wishlist-button-in-wp-query/
-
URL link to Wishlisthttps://wordpress.org/support/topic/url-link-to-wishlist-2/
-
What are the parameters for the Shortcodehttps://wordpress.org/support/topic/what-are-the-parameters-for-the-shortcode-2/
-
Add a non woocommerce product to wishlist?https://wordpress.org/support/topic/add-a-non-woocommerce-product-to-wishlist/
-
Remembering customer add-on choice/selection in wishlisthttps://wordpress.org/support/topic/remembering-customer-add-on-choice-selection-in-wishlist/
-
How to enable Custom Product Typeshttps://wordpress.org/support/topic/how-to-enable-custom-product-types/
-
Total de Wishlist por usuariohttps://wordpress.org/support/topic/total-de-wishlist-por-usuario/
-
Seeing Wishlist Itemshttps://wordpress.org/support/topic/seeing-wishlist-items/
-
Adding “add_to_wishlist” datalayer eventhttps://wordpress.org/support/topic/adding-add_to_wishlist-datalayer-event/
-
Add To Wishlist button in Yith Quickviewhttps://wordpress.org/support/topic/add-to-wishlist-button-in-yith-quickview/
-
Share wishlist in social grouphttps://wordpress.org/support/topic/share-wishlist-in-social-group/
-
Add individual products from product bundle to wishlisthttps://wordpress.org/support/topic/add-individual-products-from-product-bundle-to-wishlist/
-
cost calculator estimation for logged in userhttps://wordpress.org/support/topic/cost-calculator-estimation-for-logged-in-user/