Start and End Scheduled Sales on the Hour
Checks scheduled sale dates every hour instead of once a day at midnight, so sales that should start or end during the day do so close to on time.
Opens WPIDE on
Code
add_action( 'init', function () {
if ( ! wp_next_scheduled( 'wpide_hourly_scheduled_sales' ) ) {
wp_schedule_event( time() + 300, 'hourly', 'wpide_hourly_scheduled_sales' );
}
} );
add_action( 'wpide_hourly_scheduled_sales', function () {
if ( function_exists( 'wc_scheduled_sales' ) ) {
wc_scheduled_sales();
}
} );
Notes
WooCommerce sale dates are whole days, so this mainly helps sites where the midnight check runs late.
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.