Set WooCommerce cart expiration Set WooCommerce cart expiration wordpress wordpress

Set WooCommerce cart expiration


From what I can see, WooCommerce 2.0.20 has a scheduled maintenance job that runs twice/day that will remove any cart sessions from the WordPress options table. The default expiration time is set to 48 hours from the time the user first created the cart. I'm guessing your standard WordPress scheduling routines (and server cron/at jobs) will need to be running properly for this to execute.

AFAIK there is no way to adjust the 48 hour rule via settings. You could write a filter in your theme or in an "adjacent" plugin.

Here are some code fragments from a new "WooCommerce Extend Cart Timeout" plugin I built on my site:

Inside my WoocommerceLicenseAPI class:

if ( ! class_exists( 'WoocommerceLicenseAPI' ) ) {add_filter('wc_session_expiring'   , array('WoocommerceLicenseAPI',       'filter_ExtendSessionExpiring') );add_filter('wc_session_expiration' , array('WoocommerceLicenseAPI', 'filter_ExtendSessionExpired') );{static function filter_ExtendSessionExpiring($seconds) {    return (60 * 60 * 24 * 8) - (60 * 60);}static function filter_ExtendSessionExpired($seconds) {    return 60 * 60 * 24 * 8;}

HTH