How to extend WooCommerce cart session duration (and control cart expiration vs stock hold)

Cart abandonment emails are only effective if customers can return to a still-active cart. When carts expire too quickly, it creates a frustrating experience and reduces conversion opportunities.

In this case, a WooCommerce store found that customers returning from abandoned cart emails after a couple of days were seeing empty carts. The solution involved extending the WooCommerce session duration while keeping inventory hold times short and controlled.

Issue Background

A customer reported:

  • Clicking an abandoned cart email after ~2 days
  • Their cart was already empty
  • Expected items to still be saved

The business goal:

  • Extend cart persistence to at least 7 days
  • Allow customers to return and complete purchases

At the same time:

  • Inventory should not be reserved for that full duration
  • Users should see stock warnings if items become unavailable

Diagnosis

1. WooCommerce default session duration

  • Guest cart sessions last about 48 hours by default
  • Carts are cleared after expiration

2. Cart session vs stock hold are separate

  • Cart session: controls how long items stay in cart
  • Hold stock: controls temporary inventory reservation

These systems operate independently.

3. Session expiration is fixed

  • Expiration is set when the session starts
  • Adding items does not reset the timer

Resolution Steps

1. Extend session duration

add_filter('wc_session_expiration', function() {
    return 60 * 60 * 24 * 7;
});

add_filter('wc_session_expiring', function() {
    return 60 * 60 * 24 * 7 - 60 * 60;
});

This extends cart persistence to 7 days.

2. Adjust hold stock setting

  • Updated hold stock from 240 minutes to 120 minutes

This ensures inventory is not locked unnecessarily.

3. Test session behavior

  • Use incognito or clear cookies
  • Confirm new session expiration applies

4. Validate user experience

  • Cart persists for multiple days
  • Stock updates correctly if unavailable

5. Optional: sliding expiration

  • Implement logic to extend sessions on activity
  • Improves experience for active users

Final Outcome

  • Cart persistence extended to 7 days
  • Abandoned cart recovery improved
  • Inventory remains accurate and available

Key Takeaway

WooCommerce cart sessions and stock hold are separate systems and should be configured independently.

  • Extend session duration for better UX
  • Keep stock hold short
  • Understand session behavior

If you need help optimizing WooCommerce cart behavior or checkout performance, Freshy can help:

Contact Freshy