0

I want to set 3 hours as expiration so I've tried with this filter but for me it doesn't work

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 * 3;
}
static function filter_ExtendSessionExpired($seconds) {
    return 60 * 60 * 3;
}
Md. Rezwanul Haque
  • 2,882
  • 7
  • 28
  • 45
dave
  • 3
  • 3
  • Where is class `WoocommerceLicenseAPI` ? `wc_session_expiring` and `wc_session_expiration` are the right filters. You just need to make sure this block of code is being run/instantiated. – helgatheviking Jul 27 '17 at 17:17

1 Answers1

-1

The WooCommerce cron for expiring cart sessions only runs every 12 hours, so you need to change this to hourly if you want user carts to expiry after less than 12 hours. I built this plugin that does this and gives a simple interface to change the expiration http://mtrl.co.uk/shop/product/woocommerce-cart-expiration/

Mark Williams
  • 1,240
  • 2
  • 13
  • 28
  • 1
    In a [previous answer](https://stackoverflow.com/a/46076862/1324), you said you built (as opposed to "found") this plugin. Please be clear when linking to your own work. – Paul Roub Nov 09 '17 at 15:21