So basically in WooCommerce, I would like to reset coupon 'usage_limit' and 'usage_limit_per_user', after an hour of interval periodically. But, I'm unable to do that.
I tried the following:
add_action( 'save_post', $this,'reset_usage_limit' );
function reset_usage_limit() {
add_action( 'init', 'custom_delete_coupon_meta_function' );
wp_schedule_single_event( time() + 60, 'init', array( $coupon_id ) );
}
function custom_delete_coupon_meta_function( $coupon_id ) {
delete_post_meta( $coupon_id, 'usage_limit' );
delete_post_meta( $coupon_id, 'usage_limit_per_user' );
}
But it doesn't work.
Here, just to test if it is working or not, I have set the schedule time to 60 seconds.
Any help will be appreciated.