Reputation: 79
I'm trying to add custom content (2 sentences) after the order table on the WooCommerce
customer emails notifications.
This for all non-USA orders. I tried to get this result by using the woocommerce_email_after_order_table
hook.
Here is my initial code but not sure how to make it work.
add_action( 'woocommerce_email_after_order_table', 'NoneUS_custom_content_email', 10, 4 );
function NoneUS_custom_content_email( $order, $sent_to_admin, $plain_text, $email ) {
if( ! ( 'customer_processing_order' == $email->id || 'customer_completed_order' == $email->id ) || 'customer_on_hold_order' == $email->id)) return;
if (strtolower($woocommerce->customer->get_shipping_country()) != 'US') { {
echo '<p><strong>Note:</strong> custom content.</p>';
}
}}
Upvotes: 1
Views: 482
Reputation: 29640
$woocommerce
is undefined in your attempt, You can obtain the necessary information via the $order
object
So you get:
function action_woocommerce_email_after_order_table( $order, $sent_to_admin, $plain_text, $email ) {
// Target certain email notifications
if ( in_array( $email->id, array( 'customer_on_hold_order', 'customer_processing_order', 'customer_completed_order' ) ) ) {
if ( $order->get_shipping_country() != 'US' ) {
echo '<p><strong>Note:</strong> custom content.</p>';
}
}
}
add_action( 'woocommerce_email_after_order_table', 'action_woocommerce_email_after_order_table', 10, 4 );
Upvotes: 2