Automattic\WooCommerce\Internal\OrderWithdrawal
OrderWithdrawalFormProcessor::send_merchant_order_withdrawal_email
Send the merchant order withdrawal notification email.
Method of the class: OrderWithdrawalFormProcessor{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->send_merchant_order_withdrawal_email( $data, ?WC_Order $matched_order, $submitted_at ): bool;
- $data(array<string,string>) (required)
- Form data.
- ?WC_Order $matched_order(required)
- .
- $submitted_at(int) (required)
- Unix timestamp for the submission.
OrderWithdrawalFormProcessor::send_merchant_order_withdrawal_email() OrderWithdrawalFormProcessor::send merchant order withdrawal email code WC 11.1.2
private function send_merchant_order_withdrawal_email( array $data, ?WC_Order $matched_order, int $submitted_at ): bool {
$recipient = sanitize_email( (string) get_option( 'admin_email' ) );
if ( '' === $recipient || ! is_email( $recipient ) ) {
return false;
}
$subject = sprintf(
/* translators: %s: order number. */
__( 'Order withdrawal request for order %s', 'woocommerce' ),
$data[ self::FIELD_ORDER_NUMBER ]
);
$heading = __( 'Order withdrawal request received', 'woocommerce' );
$body = '<p>' . esc_html__( 'A customer submitted an order withdrawal request.', 'woocommerce' ) . '</p>';
if ( $matched_order instanceof WC_Order ) {
$body .= '<p>' . esc_html__( 'WooCommerce matched this request to an order and added an order note.', 'woocommerce' ) . '</p>';
} else {
$body .= '<p>' . esc_html__( 'WooCommerce could not match this request to an order automatically, so no order note was added.', 'woocommerce' ) . '</p>';
}
$body .= $this->get_email_details_html( $data, $submitted_at );
if ( $matched_order instanceof WC_Order ) {
$order_url = $matched_order->get_edit_order_url();
if ( $this->is_order_outside_withdrawal_window( $matched_order ) ) {
$body .= '<p>' . esc_html( $this->get_withdrawal_window_warning_message() ) . '</p>';
}
$body .= sprintf(
'<p>%s</p>',
sprintf(
/* translators: %d: order ID. */
esc_html__( 'Matched order ID: %d', 'woocommerce' ),
$matched_order->get_id()
)
);
if ( '' !== $order_url ) {
$body .= sprintf(
'<p><a href="%1$s">%2$s</a></p>',
esc_url( $order_url ),
esc_html__( 'View matched order', 'woocommerce' )
);
}
}
return wc_mail(
$recipient,
$subject,
$this->wrap_email_message( $heading, $body ),
$this->get_merchant_email_headers( $data )
);
}