product_syncer->delete_by_batch_requests( $product_entries ); } /** * Schedule the job. * * @param array $args * * @throws JobException If no product is provided as argument. The exception will be logged by ActionScheduler. */ public function schedule( array $args = [] ) { $args = $args[0] ?? []; $id_map = ( new ProductIDMap( $args ) )->get(); if ( empty( $id_map ) ) { throw JobException::item_not_provided( 'Array of WooCommerce product IDs' ); } if ( did_action( 'woocommerce_gla_batch_retry_delete_products' ) ) { // Retry after one minute. $this->action_scheduler->schedule_single( gmdate( 'U' ) + 60, $this->get_process_item_hook(), [ $id_map ] ); } elseif ( $this->can_schedule( [ $id_map ] ) ) { $this->action_scheduler->schedule_immediate( $this->get_process_item_hook(), [ $id_map ] ); } } /** * Get an action hook to attach the job's start method to. * * @return StartHook */ public function get_start_hook(): StartHook { return new StartHook( 'woocommerce_gla_batch_retry_delete_products', 1 ); } }