diff --git a/assets/js/src/subscribers/importExport/import.js b/assets/js/src/subscribers/importExport/import.js index af44cdd7e3..0340e06820 100644 --- a/assets/js/src/subscribers/importExport/import.js +++ b/assets/js/src/subscribers/importExport/import.js @@ -1050,6 +1050,7 @@ define( importResults.created = response.data.created; importResults.updated = response.data.updated; importResults.segments = response.data.segments; + importResults.segments_with_welcome_notification = response.data.segments_with_welcome_notification; } queue.run(); }) @@ -1118,9 +1119,10 @@ define( .replace('%1$s', '' + importData.step2.updated.toLocaleString() + '') .replace('%2$s', '"' + importData.step2.segments.join('", "') + '"') : false, - noaction: (!importData.step2.updated && !importData.step2.created) + no_action: (!importData.step2.created && !importData.step2.updated) ? true - : false + : false, + segments_with_welcome_notification: importData.step2.segments_with_welcome_notification }; jQuery('#subscribers_data_import_results') diff --git a/lib/Subscribers/ImportExport/Import/Import.php b/lib/Subscribers/ImportExport/Import/Import.php index 51a69d121d..bf9c86863b 100644 --- a/lib/Subscribers/ImportExport/Import/Import.php +++ b/lib/Subscribers/ImportExport/Import/Import.php @@ -1,6 +1,7 @@ synchronizeWPUsers($wp_users); } } @@ -79,12 +80,19 @@ class Import { ); } $segments = new BootStrapMenu('import'); + $segments = $segments->getSegments(); + $segments_with_welcome_notification = + ($created_subscribers || $updated_subscribers) ? + $this->getSegmentsWithWelcomeNotification($this->segments) : + false; return array( 'result' => true, 'data' => array( 'created' => count($created_subscribers), 'updated' => count($updated_subscribers), - 'segments' => $segments->getSegments() + 'segments' => $segments, + 'segments_with_welcome_notification' => + ($segments_with_welcome_notification) ? true : false ), 'profiler' => $this->timeExecution() ); @@ -363,4 +371,23 @@ class Import { $profiler_end = microtime(true); return ($profiler_end - $this->profiler_start) / 60; } + + function getSegmentsWithWelcomeNotification($segments_ids) { + return NewsletterOption::table_alias('options') + ->join( + MP_NEWSLETTERS_TABLE, + 'newsletters.id = options.newsletter_id', + 'newsletters' + ) + ->join( + MP_NEWSLETTER_OPTION_FIELDS_TABLE, + 'option_fields.id = options.option_field_id', + 'option_fields' + ) + ->whereNull('newsletters.deleted_at') + ->where('newsletters.type', 'welcome') + ->where('option_fields.name', 'segment') + ->whereIn('options.value', $segments_ids) + ->findMany(); + } } \ No newline at end of file diff --git a/views/subscribers/importExport/import/step3.html b/views/subscribers/importExport/import/step3.html index 3bcaf79815..1624222db3 100644 --- a/views/subscribers/importExport/import/step3.html +++ b/views/subscribers/importExport/import/step3.html @@ -25,9 +25,12 @@ {{#if updated}}
  • {{{updated}}}
  • {{/if}} - {{#if noaction}} + {{#if no_action}}
  • <%= __('No new subscribers were found/added.') %>
  • {{/if}} + {{#if segments_with_welcome_notification}} +
  • <%= __('Important note: imported subscribers will not receive any welcome emails.') %>
  • + {{/if}} \ No newline at end of file