Skip to content

Instantly share code, notes, and snippets.

@gaelgerard
Created December 10, 2025 16:07
Show Gist options
  • Select an option

  • Save gaelgerard/5204e8e4ee3db856664009e8442dc4c7 to your computer and use it in GitHub Desktop.

Select an option

Save gaelgerard/5204e8e4ee3db856664009e8442dc4c7 to your computer and use it in GitHub Desktop.
WordPress Send email using the WooCommerce template.
/**
* Send email using the WooCommerce template.
*
* @param string $to Receiver's email.
* @param string $email_subject Email subject.
* @param string $body_heading Title which appears at the top in large fonts.
* @param string $body_message Email text.
*
* @return bool
*/
function wc_send_email( $to, $email_subject, $body_heading, $body_message ) {
$mailer = WC()->mailer();
$message = $mailer->wrap_message( $body_heading, $body_message );
return $mailer->send( $to, wp_strip_all_tags( $email_subject ), $message );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment