John Davidson

php - Add custom content to certain WooCommerce email notifications for all non-USA orders

0 comments
Message:


I'm trying to add custom content (2 sentences) after the order table on the WooCommerce



  • On-Hold

  • Processing Order

  • Order Completed


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>';
}
}}


My Answer:
>id || 'customer_on-hold_order' == $email->id || 'customer_completed_order' == $email->id ) ) {
return;
}

if( 'US' == $order->get_shipping_country() ) {
return;
}

echo '

Your custom content here

';
}

Rate this post

3 of 5 based on 8264 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us