WC_Emails::backorder
Backorder notification email.
Method of the class: WC_Emails{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WC_Emails = new WC_Emails(); $WC_Emails->backorder( $args );
- $args(array) (required)
- Arguments.
WC_Emails::backorder() WC Emails::backorder code WC 10.5.0
public function backorder( $args ) {
$args = wp_parse_args(
$args,
array(
'product' => '',
'quantity' => '',
'order_id' => '',
)
);
$order = wc_get_order( $args['order_id'] );
if (
! $args['product'] ||
! is_object( $args['product'] ) ||
! $args['quantity'] ||
! $order
) {
return;
}
$stock_before = $args['quantity'] + $args['product']->get_stock_quantity();
$backordered_quantity = $args['quantity'] - max( 0, $stock_before );
$subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product backorder', 'woocommerce' ) );
/* translators: 1: backordered quantity 2: product name 3: order number */
$message = sprintf( __( '%1$s units of %2$s have been backordered in order #%3$s.', 'woocommerce' ), $backordered_quantity, html_entity_decode( wp_strip_all_tags( $args['product']->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ), $order->get_order_number() );
$this->add_email_sender_filters();
wp_mail(
/**
* Filter the recipient of the backorder notification email.
*
* @since 3.0.0
* @param string $recipient The recipient email address.
* @param array $args Arguments.
* @param null $null Unused.
*/
apply_filters( 'woocommerce_email_recipient_backorder', get_option( 'woocommerce_stock_email_recipient' ), $args, null ),
/**
* Filter the subject of the backorder notification email.
*
* @since 3.0.0
* @param string $subject The email subject.
* @param array $args Arguments.
* @param null $null Unused.
*/
apply_filters( 'woocommerce_email_subject_backorder', $subject, $args, null ),
/**
* Filter the content of the backorder notification email.
*
* @since 3.0.0
* @param string $message The email content.
* @param array $args Arguments.
* @param null $null Unused.
*/
apply_filters( 'woocommerce_email_content_backorder', $message, $args ),
/**
* Filter the headers of the backorder notification email.
*
* @since 3.0.0
* @param string $headers The email headers.
* @param array $args Arguments.
* @param null $null Unused.
*/
apply_filters( 'woocommerce_email_headers', '', 'backorder', $args, null ),
/**
* Filter the attachments of the backorder notification email.
*
* @since 3.0.0
* @param array $attachments The email attachments.
* @param array $args Arguments.
* @param null $null Unused.
*/
apply_filters( 'woocommerce_email_attachments', array(), 'backorder', $args, null )
);
$this->remove_email_sender_filters();
}