4

I have a wordpress website that allows non logged-in customers to order with the code below

global $woocommerce;
$woocommerce->session->set_customer_session_cookie(true);

The issue that I am facing right now is that the products left unordered are left in cart because all non-logged-in custumers share the same woocommerce session.

I am thinking of setting an expiry time to the session or the cart so that it can clear products in cart.

The code that I saw in: Woocommerce Set Cart Expiration Interval returns 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;
}

Do you know how can I make the filter return every 15 minutes?

Any idea is appreciated. Thanks...

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
redshot
  • 2,930
  • 3
  • 31
  • 68

2 Answers2

3

Add the following to your themes functions.php file

add_filter('wc_session_expiring', 28800);
add_filter('wc_session_expiration' , 28800);

28800 is 8 hours in seconds so replace this with 900

djcritch
  • 31
  • 2
2

If this code you linked is working just change the time calculation: 60 * 15.

Dor Perez
  • 96
  • 5