John Davidson

php - Send E-Mail after Checkout in WooCommerce

0 comments
Message:


i want to add a code which send the email "WC_Email_Customer_On_Hold_Order" after a customer give up his order with the payment method "A" (as example).


But i dont know where to add the code.
Somebody can help?



My Answer:
after a successful checkout in WooCommerce. Here is a sample code that you can use to achieve this:

php
// Add a custom function to send email after checkout
add_action('woocommerce_order_status_completed', 'send_custom_email_after_checkout');

function send_custom_email_after_checkout($order_id) {
$order = wc_get_order($order_id);
$email = $order->get_billing_email();

$subject = 'Thank you for your order!';
$message = 'Your order has been successfully completed. Thank you for shopping with us.';

wp_mail($email, $subject, $message);
}


You can add this code to your theme's functions.php file or in a custom plugin. This code will send an email to the customer's billing email address after the order status is marked as completed in WooCommerce. You can customize the email subject and message as needed.

Rate this post

5 of 5 based on 7093 votes

Comments




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