John Davidson

php - Allow re-sending New Order Notification in WooCommerce 5+

0 comments
Message:


I've been using the following snippet without any issues. For no reason that I can think of it stopped being triggered today.


Could it perhaps be written better?


add_action('woocommerce_order_status_completed', 'email_completed_order_admin_notification', 10, 2 );
function email_completed_order_admin_notification( $order_id, $order ) {
WC()->mailer()->get_emails()['WC_Email_New_Order']->trigger( $order_id );
}



My Answer:
It looks like the code you provided should work fine for triggering the New Order notification email when an order is marked as completed. However, there could be other factors at play that are preventing the email from being sent.

Here are a few things you can check:

1. Make sure that the email notification is enabled in WooCommerce settings. Go to WooCommerce > Settings > Emails and check that the New Order notification is enabled.

2. Check if there are any other plugins or custom code that may be interfering with the email sending process. Disable any other plugins temporarily to see if the issue persists.

3. Verify that the order status is indeed being changed to completed when you expect it to trigger the email. You can add some debugging code to log the order status and see if it is being changed correctly.

If none of these steps resolve the issue, you may need to further investigate the WooCommerce email system or reach out to WooCommerce support for assistance.

Rate this post

3 of 5 based on 3963 votes

Comments




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