Last active
February 21, 2017 09:31
-
-
Save mklasen/a39a2073300fcabddda5599018ac5005 to your computer and use it in GitHub Desktop.
Use Woocommerce's email function and templates to send e-mails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function my_email_function($email, $header, $content) { | |
| // We'll use Woocommerce e-mail function to send e-mail to users | |
| ob_start(); | |
| // Get WC e-mail header | |
| do_action( 'woocommerce_email_header', $header, $email ); | |
| // Content | |
| echo $content; | |
| // Get WC e-mail footer | |
| do_action( 'woocommerce_email_footer', $email ); | |
| // Get output | |
| $output = ob_get_contents(); | |
| ob_end_clean(); | |
| // Send e-mail | |
| wc_mail( $email, $header, $output, $headers = "Content-Type: text/htmlrn", $attachments = "" ); | |
| } | |
| // Usage | |
| my_email_function('[email protected]', 'Your text in header', 'Your text in content. <a href="/my-account/">Click here</a>.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment