Use the rendered subject in stats email
This commit is contained in:
committed by
Jack Kitterhing
parent
486ef4fe67
commit
83d9c85737
@@ -82,8 +82,9 @@ class Worker {
|
|||||||
$newsletter = $this->getNewsletter($task);
|
$newsletter = $this->getNewsletter($task);
|
||||||
$link = NewsletterLink::findTopLinkForNewsletter($newsletter);
|
$link = NewsletterLink::findTopLinkForNewsletter($newsletter);
|
||||||
$context = $this->prepareContext($newsletter, $link);
|
$context = $this->prepareContext($newsletter, $link);
|
||||||
|
$subject = $newsletter->queue['newsletter_rendered_subject'];
|
||||||
return [
|
return [
|
||||||
'subject' => sprintf(_x('Stats for email %s', 'title of an automatic email containing statistics (newsletter open rate, click rate, etc)', 'mailpoet'), $newsletter->subject),
|
'subject' => sprintf(_x('Stats for email %s', 'title of an automatic email containing statistics (newsletter open rate, click rate, etc)', 'mailpoet'), $subject),
|
||||||
'body' => [
|
'body' => [
|
||||||
'html' => $this->renderer->render('emails/statsNotification.html', $context),
|
'html' => $this->renderer->render('emails/statsNotification.html', $context),
|
||||||
'text' => $this->renderer->render('emails/statsNotification.txt', $context),
|
'text' => $this->renderer->render('emails/statsNotification.txt', $context),
|
||||||
@@ -101,9 +102,9 @@ class Worker {
|
|||||||
throw new \Exception('Newsletter not found');
|
throw new \Exception('Newsletter not found');
|
||||||
}
|
}
|
||||||
return $newsletter
|
return $newsletter
|
||||||
->withSendingQueue()
|
->withSendingQueue()
|
||||||
->withTotalSent()
|
->withTotalSent()
|
||||||
->withStatistics($this->woocommerce_helper);
|
->withStatistics($this->woocommerce_helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,8 +116,9 @@ class Worker {
|
|||||||
$clicked = ($newsletter->statistics['clicked'] * 100) / $newsletter->total_sent;
|
$clicked = ($newsletter->statistics['clicked'] * 100) / $newsletter->total_sent;
|
||||||
$opened = ($newsletter->statistics['opened'] * 100) / $newsletter->total_sent;
|
$opened = ($newsletter->statistics['opened'] * 100) / $newsletter->total_sent;
|
||||||
$unsubscribed = ($newsletter->statistics['unsubscribed'] * 100) / $newsletter->total_sent;
|
$unsubscribed = ($newsletter->statistics['unsubscribed'] * 100) / $newsletter->total_sent;
|
||||||
|
$subject = $newsletter->queue['newsletter_rendered_subject'];
|
||||||
$context = [
|
$context = [
|
||||||
'subject' => $newsletter->subject,
|
'subject' => $subject,
|
||||||
'preheader' => sprintf(_x(
|
'preheader' => sprintf(_x(
|
||||||
'%1$s%% opens, %2$s%% clicks, %3$s%% unsubscribes in a nutshell.', 'newsletter open rate, click rate and unsubscribe rate', 'mailpoet'),
|
'%1$s%% opens, %2$s%% clicks, %3$s%% unsubscribes in a nutshell.', 'newsletter open rate, click rate and unsubscribe rate', 'mailpoet'),
|
||||||
number_format($opened, 2),
|
number_format($opened, 2),
|
||||||
|
@@ -69,7 +69,7 @@ class WorkerTest extends \MailPoetTest {
|
|||||||
'task_id' => $stats_notifications_task->id(),
|
'task_id' => $stats_notifications_task->id(),
|
||||||
]);
|
]);
|
||||||
$this->queue = SendingQueue::createOrUpdate([
|
$this->queue = SendingQueue::createOrUpdate([
|
||||||
'newsletter_rendered_subject' => 'Email Subject',
|
'newsletter_rendered_subject' => 'Rendered Email Subject',
|
||||||
'task_id' => $sending_task->id(),
|
'task_id' => $sending_task->id(),
|
||||||
'newsletter_id' => $this->newsletter->id(),
|
'newsletter_id' => $this->newsletter->id(),
|
||||||
'count_processed' => 5,
|
'count_processed' => 5,
|
||||||
@@ -150,7 +150,7 @@ class WorkerTest extends \MailPoetTest {
|
|||||||
->with(
|
->with(
|
||||||
$this->anything(),
|
$this->anything(),
|
||||||
$this->callback(function($context){
|
$this->callback(function($context){
|
||||||
return $context['subject'] === 'Email Subject1';
|
return $context['subject'] === 'Rendered Email Subject';
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$this->stats_notifications->process();
|
$this->stats_notifications->process();
|
||||||
@@ -263,7 +263,7 @@ class WorkerTest extends \MailPoetTest {
|
|||||||
'task_id' => $stats_notifications_task->id(),
|
'task_id' => $stats_notifications_task->id(),
|
||||||
]);
|
]);
|
||||||
SendingQueue::createOrUpdate([
|
SendingQueue::createOrUpdate([
|
||||||
'newsletter_rendered_subject' => 'Email Subject2',
|
'newsletter_rendered_subject' => 'Rendered Email Subject2',
|
||||||
'task_id' => $sending_task->id(),
|
'task_id' => $sending_task->id(),
|
||||||
'newsletter_id' => $newsletter->id(),
|
'newsletter_id' => $newsletter->id(),
|
||||||
'count_processed' => 15,
|
'count_processed' => 15,
|
||||||
|
Reference in New Issue
Block a user