由于Woocommerce 3,您的实际代码有点过时。在以下内容中,您将在电子邮件主题中获得所有产品名称(coma分隔)。
add_filter(\'woocommerce_email_subject_new_order\', \'change_admin_email_subject\', 10, 2);
function change_admin_email_subject( $subject, $order ) {
$products_names = array();
foreach ( $order->get_items() as $item ) {
$products_names[] = $item->get_name();
}
return sprintf( \'[%s] New Customer Order (#%s) of %s from %s %s\',
wp_specialchars_decode(get_option(\'blogname\'), ENT_QUOTES),
$order->get_id(),
implode(\', \', $products_names),
$order->get_billing_first_name(),
$order->get_billing_last_name()
);
}