Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Created January 16, 2016 09:37
Show Gist options
  • Save goranefbl/9e24f3f22901eddeaf64 to your computer and use it in GitHub Desktop.
Save goranefbl/9e24f3f22901eddeaf64 to your computer and use it in GitHub Desktop.
Use woocommerce email template header/footer with your plugin
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