Skip to content

Commit

Permalink
do not send the invoice email if no attachment available
Browse files Browse the repository at this point in the history
  • Loading branch information
timiwahalahti committed Jul 24, 2023
1 parent 92043ac commit f4c8ec5
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ public static function send_invoice( $invoice_id ) {
if ( empty( $invoice_metas['email'] ) && is_email( $invoice_metas['email'] ) ) {
return false;
}//end if

$invoice_pdf = ctx_get_invoice( $invoice_id );
if ( empty( $invoice_pdf ) ) {
return false;
}

$attachments = array( $invoice_pdf );
$opt = get_option( 'camptix_options' );

Expand All @@ -351,6 +356,7 @@ public static function send_invoice( $invoice_id ) {
'Content-type: text/html; charset=UTF-8',
)
);

$message = array(
__( 'Hello,', 'wordcamporg' ),
// translators: event name.
Expand All @@ -362,6 +368,7 @@ public static function send_invoice( $invoice_id ) {
// translators: event name.
sprintf( __( 'The %s team', 'wordcamporg' ), sanitize_text_field( $opt['event_name'] ) ),
);

$message = implode( PHP_EOL, $message );
$message = '<p>' . nl2br( $message ) . '</p>';
wp_mail( $invoice_metas['email'], $subject, $message, $headers, $attachments );
Expand Down

0 comments on commit f4c8ec5

Please sign in to comment.