WC_Email::send_if_recipient
Send the email when a recipient is available, regardless of the enabled setting.
This helper is intended for manually-triggered emails (e.g. invoice resend, POS receipts) that intentionally bypass the enabled/disabled check. It fires woocommerce_email_skipped reason {@see WC_Email::SKIP_REASON_NO_RECIPIENT} when no recipient is available so the outcome is still observable via the EmailLogger, and otherwise delegates to send().
Метод класса: WC_Email{}
Хуки из метода
Возвращает
bool. Whether the email was sent successfully.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->send_if_recipient(): bool;
Список изменений
| С версии 10.9.0 | Введена. |
Код WC_Email::send_if_recipient() WC Email::send if recipient WC 11.2.1
protected function send_if_recipient(): bool {
$recipient = $this->get_recipient();
if ( ! $recipient ) {
/**
* Fires when a transactional email is not sent for a reason other than being disabled.
*
* This action is documented in includes/emails/class-wc-email.php
*
* @since 10.9.0
*/
do_action( 'woocommerce_email_skipped', self::SKIP_REASON_NO_RECIPIENT, $this->id, $this );
return false;
}
return $this->send(
$recipient,
$this->get_subject(),
$this->get_content(),
$this->get_headers(),
$this->get_attachments()
);
}