Untitled
function send_woocommerce_welcome_email($customer_id) { // Get the customer data $customer = get_userdata($customer_id); if (!$customer) return; // Get WooCommerce mailer $mailer = WC()->mailer(); // Email subject and heading $email_subject = 'Welcome to ' . get_bloginfo('name'); $email_heading = 'Welcome to Our Store!'; // Prepare email content $email_content = sprintf( '<p>Hello %s,</p> <p>Thank you for creating an account with us. We're excited to have you as part of our community!</p> <p>Here are a few things you might want to know:</p> <ul> <li>View your orders and account details in your <a href="%s">account dashboard</a></li> <li>Browse our latest products and exclusive offers</li> <li>Use code "WELCOME10" for 10%% off your first purchase</li> </ul> <p>If you have any questions, our support team is here to help!</p> <p>Best regards,<br>The team at %s</p>', esc_html($customer->display_name), esc_url(wc_get_page_permalink('myaccount')), esc_html(get_bloginfo('name')) ); // Get WooCommerce email template $email_template = $mailer->wrap_message( $email_heading, $email_content ); // Create email headers $headers = array( 'Content-Type: text/html; charset=UTF-8', 'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>' ); // Send the email $mailer->send($customer->user_email, $email_subject, $email_template, $headers); }
Leave a Comment