how to make order details email sent automatically
-
How to send order details email automatically because the default setting is manual sending? and how to achieve it without using another plugin because I just want to do the task automatically?
- This topic was modified 3 months, 1 week ago by sigmakicks.
-
Hello sigmakicks,
Thank you for contacting Woo support.
WooCommerce automatically sends an email for new orders to the customers.
This email includes all the details about the order placed
You can find detailed information in this guide.If you are facing an issue where an email is not sent, could you share more details about it?
– Which email are you referring to? Sharing a screenshot of it would be helpful.
– What steps do you follow to send it manually? Sharing a screenshot of it would be helpful.Once I have more information, I will be happy to help you further. ??
Best regards.
order detail emails are not sent automatically and have to be sent manually. -> “You send this email manually from the “Edit Order” screen to?share invoice details and a payment link?with customers” (https://woocommerce.com/wp-content/uploads/2024/05/woocommerce-email-notifications_ea0bea.png?strip=all&w=704)
is there a way to make it automatically sent without using any plugin?Hello sigmakicks,
Thank you for clarification.
WooCommerce does not have an option to send these emails automatically.
You will either need a plugin or custom code to automate this action.Please let me know if you have any other questions. ??
Best regards.
so i tried to solve this through custom code and call https://woocommerce.github.io/code-reference/classes/WC-Email-Customer-Invoice.html class. the email get sent but it missed some details like product detail, shipping method, and shipping address. is there something that i’ve been missing in my code?
here is the email that has been sent by my custom code https://ibb.co.com/SrbQCr5, and here is the email that has been sent manually through edit order page https://ibb.co.com/Chpg1t2. here is my code
function send_custom_order_details_email($order_id) {
if (!$order_id) {
return;
}
// Log for debugging
error_log('Attempting to send order details email. Order ID: ' . $order_id);
// Get the order object
$order = wc_get_order($order_id);
if (!$order) {
error_log('Failed to get order object for Order ID: ' . $order_id);
return;
}
// Initialize WooCommerce emails
$mailer = WC()->mailer();
// Get the "Customer Processing Order" email template
$email = $mailer->get_emails()['WC_Email_Customer_Invoice'];
if (!$email) {
error_log('Failed to get Customer Processing Order email template');
return;
}
// Trigger the email
$email->trigger($order_id);
// Log after sending email
error_log('Order details email sent for Order ID: ' . $order_id);
}
// Hook into WooCommerce order status changed to 'pending'
add_action('woocommerce_order_status_pending', 'send_custom_order_details_email', 10, 1);
// Hook into WooCommerce order creation
add_action('woocommerce_new_order', 'send_custom_order_details_email', 10, 1);Hello @sigmakicks,
For reference, this particular forum is meant for general support with the core functionality of WooCommerce Stripe Payment Gateway itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:
- A local web developer
- Codeable.io
- WooExperts
I will leave this thread open for a bit to see if anyone can chime in and help you out further.
I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.
Thanks!
so after digging through internet, i found that ‘woocommerce_order_status_pending’ is not triggered and ‘woocommerce_new_order’ doesnt have order details object. i tried using ‘woocommerce_checkout_update_order_meta’ and call the custom function and it sent the email without any order details missing.
reference: php – WooCommerce order status hook not triggering – Stack OverflowHi @sigmakicks
I’m glad to hear that you’ve found a solution to your issue. Using the
woocommerce_checkout_update_order_meta
hook is indeed the right approach to trigger the sending of the order details email automatically after an order is placed. Thewoocommerce_new_order
hook is triggered before the order details are saved, which is why the order details were missing in the email.For future reference, you can always refer to the WooCommerce Hook Reference documentation for more information about the various hooks available and their usage.
- https://woocommerce.github.io/code-reference/hooks/hooks.html
- https://woocommerce.com/document/introduction-to-hooks-actions-and-filters/
I hope this clarifies your query. If you have any further questions or concerns, please don’t hesitate to ask.
Hello @sigmakicks,
I’m marking this topic as “resolved” due to recent inactivity. Hopefully, you were able to find a solution to your problem! If more assistance is needed, feel free to post back here or open a new topic.
Thanks!
- You must be logged in to reply to this topic.