Automattic\WooCommerce\Internal\AbandonedCartRecovery
Scheduler::handle_scheduled_send
Dispatch the recovery email when the scheduled AS action fires.
Resolve the email lazily through the mailer, re-check the automation opt-in, and delegate the actual send to trigger(), which keeps every send-time gate in one place.
Method of the class: Scheduler{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Scheduler = new Scheduler(); $Scheduler->handle_scheduled_send( $order_id ): void;
- $order_id(int) (required)
- Order id the AS action was scheduled with.
Scheduler::handle_scheduled_send() Scheduler::handle scheduled send code WC 11.0.0
public function handle_scheduled_send( int $order_id ): void {
$email = $this->get_email();
if ( null === $email ) {
return;
}
if ( ! $email->is_automated() ) {
return;
}
$dispatched = $email->trigger( $order_id );
if ( ! $dispatched ) {
return;
}
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
return;
}
$order->add_order_note(
__( 'Abandoned cart recovery email sent automatically.', 'woocommerce' ),
0,
false,
array( 'note_group' => OrderNoteGroup::EMAIL_NOTIFICATION )
);
}