Skip to content

Instantly share code, notes, and snippets.

@sonipb
Forked from goranefbl/woo-email.php
Created February 3, 2018 11:20
Show Gist options
  • Save sonipb/40a543af7fe230ba2995183e102ffd0a to your computer and use it in GitHub Desktop.
Save sonipb/40a543af7fe230ba2995183e102ffd0a 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