Automattic\WooCommerce\Internal\StockNotifications\Emails

CustomerStockNotificationEmail::triggerpublicWC 1.0

Trigger the sending of this email.

Method of the class: CustomerStockNotificationEmail{}

No Hooks.

Returns

null. Nothing (null).

Usage

$CustomerStockNotificationEmail = new CustomerStockNotificationEmail();
$CustomerStockNotificationEmail->trigger( $notification );
$notification(Notification|int) (required)
The notification object or ID.

CustomerStockNotificationEmail::trigger() code WC 10.3.6

public function trigger( $notification ) {
	$this->setup_locale();

	if ( is_numeric( $notification ) ) {
		$notification = Factory::get_notification( $notification );
	}

	if ( ! $notification instanceof Notification ) {
		return;
	}

	$product = $notification->get_product();
	if ( ! $product || ! is_a( $product, 'WC_Product' ) ) {
		return;
	}

	$this->maybe_setup_notification_locale( $notification );
	$this->prepare_email( $notification );

	if ( $this->is_enabled() && $this->get_recipient() ) {

		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );

	}

	$this->maybe_restore_notification_locale( $notification );
	$this->restore_locale();
}