Keep WooCommerce Logs for 7 Days
Makes WooCommerce delete its log entries (payment gateways, shipping, webhooks and more) after 7 days instead of 30, keeping the log table and folder small.
Opens WPIDE on
Code
// Days to keep WooCommerce logs.
$wpide_wc_log_days = 7;
add_filter( 'woocommerce_logger_days_to_retain_logs', function () use ( $wpide_wc_log_days ) {
return (int) $wpide_wc_log_days;
} );
Notes
Raise the number while you are debugging a payment or shipping problem.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.