-
-
Save sonipb/40a543af7fe230ba2995183e102ffd0a to your computer and use it in GitHub Desktop.
Use woocommerce email template header/footer with your plugin
This file contains 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
public function gens_send_email($user_id,$coupon_code) { | |
if ( !$user_id || !$coupon_code) { | |
return false; | |
} | |
global $woocommerce; | |
$mailer = $woocommerce->mailer(); | |
$user_info = get_userdata($user_id); | |
$user_email = $user_info->user_email; | |
$user_message = get_option( 'gens_raf_email_message' ); | |
ob_start(); | |
wc_get_template( 'emails/email-header.php', array( 'email_heading' => 'You refered someone!' ) ); | |
echo str_replace( '{{code}}', $coupon_code, $user_message ); | |
wc_get_template( 'emails/email-footer.php' ); | |
$message = ob_get_clean(); | |
$subject = get_option( 'gens_raf_email_subject' ); | |
// Debug wp_die($user_email); | |
$mailer->send( $user_email, $subject, $message); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment