Action Scheduler Handler
Apart from the default WordPress handler, the utilities package provides a CRON Events Handler for working with the famous Action Scheduler library of WooCommerce. You can read more about the library here.
This handler is not part of the WooCommerce Module simply because it's possible to use the Action Scheduler library outside of WooCommerce.
In order to work with it, you should register it with your CRON Events Service like this:
use DeepWebSolutions\Framework\Utilities\CronEvents\CronEventsService;
use DeepWebSolutions\Framework\Utilities\CronEvents\Handlers\ActionSchedulerCronEventsHandler;
$as_handler = new ActionSchedulerCronEventsHandler( 'my-handler-id' );
// you can register the handler in the constructor...
$cron_service = new CronEventsService( $my_plugin, $my_logging_service, $my_hooks_service, array( $as_handler ) );
// ...or alternatively you can also do this
$cron_service->register_handler( $as_handler );
// now to use it ... if you set your handler's ID to 'default', you can skip the last argument
$cron_service->schedule_single_event( 'my-hook', null, array(), 'my-handler-id' );
Copy link