4

I need to increase the expiration time of Woocommerce cart to 72 hours.

I've tried the solution suggested here: set wordpress woocommerce cart expiration

But I can't see any result :( Can anyone help me to get this working?

Thanks

-- Edit: Code snippet ---

add_filter('wc_session_expiring', 'filter_ExtendSessionExpiring' );
add_filter('wc_session_expiration' , 'filter_ExtendSessionExpired' );

function filter_ExtendSessionExpiring($seconds) {
    return (60 * 60 * 24 * 4) - (60 * 60);
}
function filter_ExtendSessionExpired($seconds) {
   return 60 * 60 * 24 * 4;
}
Community
  • 1
  • 1
SuPerGiu
  • 43
  • 1
  • 5
  • You can post code in your question. Which snippet did you try? – helgatheviking Dec 15 '16 at 16:01
  • Hi Helga!Thank you for your reply I've edited my question whit the snippet I have not used the "WoocommerceLicenseAPI" like suggested in original question, because it's not very clear to me and I get some errors... Really I don't understand how Woocommerce manage cart expiration period, can you help me to find some docs that explain this? – SuPerGiu Dec 16 '16 at 10:17

2 Answers2

5

The filter must return 72 hours, in seconds.

add_filter('wc_session_expiring', 'filter_ExtendSessionExpiring' );
add_filter('wc_session_expiration' , 'filter_ExtendSessionExpired' );

function filter_ExtendSessionExpiring($seconds) {
    return 60 * 60 * 71;
}
function filter_ExtendSessionExpired($seconds) {
   return 60 * 60 * 72;
}
helgatheviking
  • 25,596
  • 11
  • 95
  • 152
  • OK, thank you very much! I'll try this snippet ... Can I just add in the functions.php file of my theme, right? After that every 72 hours the cart of all users will be deleted? Did I get it right? :) – SuPerGiu Dec 18 '16 at 19:23
  • Hello, I did a little research and I was wondering if this Woocommerce feature is based on Wordpress Cron system ...? – SuPerGiu Dec 18 '16 at 20:51
-1

I had exactly this problem in a multi site set up and built a plugin to solve this. You can get the plugin here http://mtrl.co.uk/shop/product/woocommerce-cart-lifespan-settings-plugin/

Mark Williams
  • 1,240
  • 2
  • 13
  • 28