WC_Email_New_Order::trigger()
Trigger the sending of this email.
Метод класса: WC_Email_New_Order{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$WC_Email_New_Order = new WC_Email_New_Order(); $WC_Email_New_Order->trigger( $order_id, $order );
- $order_id(int) (обязательный)
- The order ID.
- $order(WC_Order|false)
- Order object.
По умолчанию: false
Код WC_Email_New_Order::trigger() WC Email New Order::trigger WC 9.4.2
public function trigger( $order_id, $order = false ) { $this->setup_locale(); if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { $order = wc_get_order( $order_id ); } $email_already_sent = false; if ( is_a( $order, 'WC_Order' ) ) { $this->object = $order; $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); $this->placeholders['{order_number}'] = $this->object->get_order_number(); $email_already_sent = $order->get_new_order_email_sent(); } /** * Controls if new order emails can be resend multiple times. * * @since 5.0.0 * @param bool $allows Defaults to false. */ if ( $email_already_sent && ! apply_filters( 'woocommerce_new_order_email_allows_resend', false ) ) { return; } if ( $this->is_enabled() && $this->get_recipient() ) { $email_sent_successfully = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); if ( $email_sent_successfully ) { $order->update_meta_data( '_new_order_email_sent', 'true' ); $order->save(); } } $this->restore_locale(); }