Skip to content

Commit

Permalink
fix: render all lists when reader is not subscribed
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed May 24, 2024
1 parent 6b5a726 commit 33fb5f1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,21 +462,24 @@ public static function get_registration_newsletter_lists() {
/**
* Get the newsletter lists that should be rendered after checkout.
*
* @param string $email Email address.
* @param string $email_address Email address. Optional.
*
* @return array
*/
public static function get_post_checkout_newsletter_lists( $email ) {
public static function get_post_checkout_newsletter_lists( $email_address = '' ) {
$available_lists = self::get_available_newsletter_lists();
$registration_lists = [];
$current_lists = [];

if ( empty( $available_lists ) || ! method_exists( '\Newspack_Newsletters_Subscription', 'get_contact_lists' ) ) {
return [];
}

$current_lists = \Newspack_Newsletters_Subscription::get_contact_lists( $email );
if ( \is_wp_error( $current_lists ) || ! is_array( $current_lists ) ) {
return [];
if ( $email ) {
$current_lists = \Newspack_Newsletters_Subscription::get_contact_lists( $email );
if ( \is_wp_error( $current_lists ) || ! is_array( $current_lists ) ) {
return [];
}
}

foreach ( $available_lists as $list_id => $list ) {
Expand Down Expand Up @@ -1401,11 +1404,7 @@ public static function render_newsletters_signup_modal() {
return;
}

$email_address = self::get_logged_in_reader_email_address();
if ( ! $email_address ) {
return;
}

$email_address = self::get_logged_in_reader_email_address();
$newsletters_lists = self::get_post_checkout_newsletter_lists( $email_address );
if ( empty( $newsletters_lists ) ) {
return;
Expand Down

0 comments on commit 33fb5f1

Please sign in to comment.