Merge pull request #23754 from Spreeuw/patch-9
Plain text email: check if product exists before calling get_sku()
This commit is contained in:
commit
3936518e64
|
@ -12,7 +12,7 @@
|
||||||
*
|
*
|
||||||
* @see https://docs.woocommerce.com/document/template-structure/
|
* @see https://docs.woocommerce.com/document/template-structure/
|
||||||
* @package WooCommerce/Templates/Emails/Plain
|
* @package WooCommerce/Templates/Emails/Plain
|
||||||
* @version 3.2.0
|
* @version 3.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
@ -22,9 +22,17 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
foreach ( $items as $item_id => $item ) :
|
foreach ( $items as $item_id => $item ) :
|
||||||
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
|
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
|
$sku = '';
|
||||||
|
$purchase_note = '';
|
||||||
|
|
||||||
|
if ( is_object( $product ) ) {
|
||||||
|
$sku = $product->get_sku();
|
||||||
|
$purchase_note = $product->get_purchase_note();
|
||||||
|
}
|
||||||
|
|
||||||
echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false );
|
echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false );
|
||||||
if ( $show_sku && $product->get_sku() ) {
|
if ( $show_sku && $sku ) {
|
||||||
echo ' (#' . $product->get_sku() . ')';
|
echo ' (#' . $sku . ')';
|
||||||
}
|
}
|
||||||
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item );
|
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item );
|
||||||
echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n";
|
echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n";
|
||||||
|
@ -43,7 +51,7 @@ foreach ( $items as $item_id => $item ) :
|
||||||
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
|
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
|
||||||
}
|
}
|
||||||
// Note
|
// Note
|
||||||
if ( $show_purchase_note && is_object( $product ) && ( $purchase_note = $product->get_purchase_note() ) ) {
|
if ( $show_purchase_note && $purchase_note ) {
|
||||||
echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) );
|
echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) );
|
||||||
}
|
}
|
||||||
echo "\n\n";
|
echo "\n\n";
|
||||||
|
|
Loading…
Reference in New Issue