Skip to content

Commit

Permalink
fix(reader-revenue): prevent sending duplicate receipt emails
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed May 29, 2024
1 parent 240e79c commit aa91890
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ public static function send_customizable_receipt_email( $enable, $order, $class
if ( ! is_a( $order, 'WC_Order' ) || ! Emails::can_send_email( Reader_Revenue_Emails::EMAIL_TYPES['RECEIPT'] ) ) {
return $enable;
}
if ( $order->get_meta( '_newspack_receipt_email_sent', true ) ) {
return $enable;
}

$frequencies = [
'month' => __( 'Monthly', 'newspack-plugin' ),
Expand Down Expand Up @@ -591,8 +594,11 @@ public static function send_customizable_receipt_email( $enable, $order, $class
$order->get_billing_email(),
$placeholders
);

return false;
if ( $sent ) {
$order->add_meta_data( '_newspack_receipt_email_sent', true, true );
return false;
}
return $enable;
}

/**
Expand Down

0 comments on commit aa91890

Please sign in to comment.