WC_Emails::low_stock()publicWC 1.0

Low stock notification email.

Метод класса: WC_Emails{}

Возвращает

null. Ничего (null).

Использование

$WC_Emails = new WC_Emails();
$WC_Emails->low_stock( $product );
$product(WC_Product) (обязательный)
Product instance.

Код WC_Emails::low_stock() WC 8.7.0

public function low_stock( $product ) {
	if ( 'no' === get_option( 'woocommerce_notify_low_stock', 'yes' ) ) {
		return;
	}

	/**
	 * Determine if the current product should trigger a low stock notification
	 *
	 * @param int $product_id - The low stock product id
	 *
	 * @since 4.7.0
	 */
	if ( false === apply_filters( 'woocommerce_should_send_low_stock_notification', true, $product->get_id() ) ) {
		return;
	}

	$subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product low in stock', 'woocommerce' ) );
	$message = sprintf(
		/* translators: 1: product name 2: items in stock */
		__( '%1$s is low in stock. There are %2$d left.', 'woocommerce' ),
		html_entity_decode( wp_strip_all_tags( $product->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ),
		html_entity_decode( wp_strip_all_tags( $product->get_stock_quantity() ) )
	);

	wp_mail(
		apply_filters( 'woocommerce_email_recipient_low_stock', get_option( 'woocommerce_stock_email_recipient' ), $product, null ),
		apply_filters( 'woocommerce_email_subject_low_stock', $subject, $product, null ),
		apply_filters( 'woocommerce_email_content_low_stock', $message, $product ),
		apply_filters( 'woocommerce_email_headers', '', 'low_stock', $product, null ),
		apply_filters( 'woocommerce_email_attachments', array(), 'low_stock', $product, null )
	);
}