Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woo commerce new user email

I wrote a custom plugin that handles login and registration for my WordPress Woocommerce site.

When a user registers via my custom form handler I would like to trigger Woocommerce to send the new user an email instead of using wp_mail. This way I reduce code redundancy, and all of the transactional emails can be formatted the same (they all have the same look and feel).

Is it possible to do so?

like image 272
Joshua Wieczorek Avatar asked Feb 14 '17 12:02

Joshua Wieczorek


People also ask

How do I create a welcome email in WordPress?

Next, go to MailPoet > Emails and hit “Add New.” Choose “Welcome Email” from the available options. On the next page, you'll be asked when you want to send your welcome email and which list you want to send to. Select the options that suit your needs and click “Next.”

How do I add an email to WooCommerce?

Simply head to WooCommerce » Settings from your WordPress admin panel and then click the 'Email' tab. Here you'll see all the emails WooCommerce sends to your customers, including emails for new orders, canceled orders, failed orders, orders refunded, password reset, new accounts, and more.

How do I disable confirmation email for new users in WordPress?

The easiest way to disable the new user notification email in Wordpress is to use the Manage Notification E-mails plugin. This plugin will allow you to disable a slew of admin related emails. After installing and activating the plugin you'll see a new option in your settings for “Notification e-mails”.


1 Answers

Try this:

$wc = new WC_Emails();
$wc->customer_new_account($user_id);

$customerID should be the ID of the newly created customer. Here you can find out everything about the WC_Email_Customer_New_Account class: https://docs.woocommerce.com/wc-apidocs/class-WC_Email_Customer_New_Account.html. Just place this code somewhere where it will run after the customer has been registered, so I assume somewhere where you would have placed the wp_mail functions. Let me know if this helped :)

like image 169
L L Avatar answered Sep 20 '22 10:09

L L