Skip to content

Commit

Permalink
[shopsys] added complaint detail url to mail templates (#3445)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasLudvik authored Sep 23, 2024
1 parent 1e98b01 commit e008749
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/Migrations/Version20240910054629.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ public function up(Schema $schema): void
$this->sql(
'UPDATE mail_templates SET subject = :body WHERE name = \'complaint_status_1\' AND domain_id = :domainId',
[
'body' => t('Complaint status has changed', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale),
'body' => t('Status of complaint with number {complaint_number} from order number {order_number} created on {date} has changed', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale),
'domainId' => $domainId,
],
);
$this->sql(
'UPDATE mail_templates SET body = :body WHERE name = \'complaint_status_1\' AND domain_id = :domainId',
[
'body' => '<div style="box-sizing: border-box; padding: 10px;"><div class="gjs-text-ckeditor">' .
t('Dear customer, <br /><br />Your complaint is being processed.', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale) .
t('Dear customer, <br /><br />Your complaint with number {complaint_number} from order number {order_number} created {date} is being processed. For more information, visit <a href="{complaint_detail_url}">complaint detail</a>.<br /><br />Do you need anything else? Visit our <a href="{url}">website</a>.', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale) .
'</div></div>',
'domainId' => $domainId,
],
);
$this->sql(
'UPDATE mail_templates SET subject = :body WHERE name = \'complaint_status_2\' AND domain_id = :domainId',
[
'body' => t('Complaint status has changed', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale),
'body' => t('Status of complaint with number {complaint_number} from order number {order_number} created on {date} has changed', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale),
'domainId' => $domainId,
],
);
$this->sql(
'UPDATE mail_templates SET body = :body WHERE name = \'complaint_status_2\' AND domain_id = :domainId',
[
'body' => '<div style="box-sizing: border-box; padding: 10px;"><div class="gjs-text-ckeditor">' .
t('Dear customer, <br /><br />Processing your complaint has been finished.', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale) .
t('Dear customer, <br /><br />Your complaint with number {complaint_number} from order number {order_number} created {date} has been finished. For more information, visit <a href="{complaint_detail_url}">complaint detail</a>.<br /><br />Do you need anything else? Visit our <a href="{url}">website</a>.', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $domainLocale) .
'</div></div>',
'domainId' => $domainId,
],
Expand Down
25 changes: 20 additions & 5 deletions src/Model/Complaint/Mail/ComplaintMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

class ComplaintMail implements MessageFactoryInterface
{
protected const MAIL_TEMPLATE_NAME_PREFIX = 'complaint_status_';
public const VARIABLE_COMPLAINT_NUMBER = '{complaint_number}';
public const VARIABLE_ORDER_NUMBER = '{order_number}';
public const VARIABLE_DATE = '{date}';
public const VARIABLE_URL = '{url}';
protected const string MAIL_TEMPLATE_NAME_PREFIX = 'complaint_status_';
public const string VARIABLE_COMPLAINT_NUMBER = '{complaint_number}';
public const string VARIABLE_ORDER_NUMBER = '{order_number}';
public const string VARIABLE_DATE = '{date}';
public const string VARIABLE_URL = '{url}';
public const string VARIABLE_COMPLAINT_DETAIL_URL = '{complaint_detail_url}';

/**
* @param \Shopsys\FrameworkBundle\Component\Setting\Setting $setting
Expand Down Expand Up @@ -80,6 +81,7 @@ protected function getVariablesReplacementsForBody(Complaint $complaint)

return [
self::VARIABLE_COMPLAINT_NUMBER => htmlspecialchars($complaint->getNumber(), ENT_QUOTES),
self::VARIABLE_COMPLAINT_DETAIL_URL => $this->getComplaintDetailUrl($complaint),
self::VARIABLE_ORDER_NUMBER => htmlspecialchars($complaint->getOrder()->getNumber(), ENT_QUOTES),
self::VARIABLE_DATE => $this->getFormattedDateTime($complaint),
self::VARIABLE_URL => $router->generate('front_homepage', [], UrlGeneratorInterface::ABSOLUTE_URL),
Expand Down Expand Up @@ -119,4 +121,17 @@ protected function getDomainLocaleByComplaint(Complaint $complaint)
{
return $this->domain->getDomainConfigById($complaint->getDomainId())->getLocale();
}

/**
* @param \Shopsys\FrameworkBundle\Model\Complaint\Complaint $complaint
* @return string
*/
protected function getComplaintDetailUrl(Complaint $complaint): string
{
return $this->domainRouterFactory->getRouter($complaint->getDomainId())->generate(
'front_complaint_detail',
['complaintNumber' => $complaint->getNumber()],
UrlGeneratorInterface::ABSOLUTE_URL,
);
}
}
1 change: 1 addition & 0 deletions src/Model/Mail/MailTemplateConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ protected function createComplaintStatusMailTemplateVariables(): MailTemplateVar

return $mailTemplateVariables
->addVariable(ComplaintMail::VARIABLE_COMPLAINT_NUMBER, t('Complaint number'))
->addVariable(ComplaintMail::VARIABLE_COMPLAINT_DETAIL_URL, t('Complaint detail URL'))
->addVariable(ComplaintMail::VARIABLE_ORDER_NUMBER, t('Order number'))
->addVariable(ComplaintMail::VARIABLE_DATE, t('Date and time of order creation'))
->addVariable(ComplaintMail::VARIABLE_URL, t('E-shop URL address'), MailTemplateVariables::CONTEXT_BODY);
Expand Down
17 changes: 10 additions & 7 deletions src/Resources/translations/messages.cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ msgstr "Reklamace č."
msgid "Complaint Nr. <strong><a href=\"{{ url }}\">{{ number }}</a></strong> modified"
msgstr "Byla upravena reklamace č. <strong><a href=\"{{ url }}\">{{ number }}</a></strong>"

msgid "Complaint detail URL"
msgstr "URL detailu reklamace"

msgid "Complaint items"
msgstr "Položky reklamace"

Expand All @@ -688,9 +691,6 @@ msgstr "Číslo reklamace"
msgid "Complaint status"
msgstr "Stav reklamace"

msgid "Complaint status has changed"
msgstr "Stav reklamace se změnil"

msgid "Complaint statuses - full"
msgstr "Stavy reklamací - vše"

Expand Down Expand Up @@ -1057,11 +1057,11 @@ msgstr "Dny pro přesun mezi sklady"
msgid "Days until delivery"
msgstr "Dní do doručení"

msgid "Dear customer, <br /><br />Processing your complaint has been finished."
msgstr "Vážený zákazníku, <br /><br />Zpracování Vaší reklamace bylo dokončeno."
msgid "Dear customer, <br /><br />Your complaint with number {complaint_number} from order number {order_number} created {date} has been finished. For more information, visit <a href=\"{complaint_detail_url}\">complaint detail</a>.<br /><br />Do you need anything else? Visit our <a href=\"{url}\">website</a>."
msgstr "Vážený zákazníku, <br /><br />Vaše reklamace s číslem {complaint_number} z objednávky číslo {order_number} vytvořené {date} byla vyřízena. Pro více informací navštivte <a href=\"{complaint_detail_url}\">detail reklamace</a>.<br /><br />Potřebujete cokoliv jiného? Navštivte naše <a href=\"{url}\">webové stránky</a>."

msgid "Dear customer, <br /><br />Your complaint is being processed."
msgstr "Vážený zákazníku, <br /><br />Vaše reklamace se zpracovává."
msgid "Dear customer, <br /><br />Your complaint with number {complaint_number} from order number {order_number} created {date} is being processed. For more information, visit <a href=\"{complaint_detail_url}\">complaint detail</a>.<br /><br />Do you need anything else? Visit our <a href=\"{url}\">website</a>."
msgstr "Vážený zákazníku, <br /><br />Vaše reklamace s číslem {complaint_number} z objednávky číslo {order_number} vytvořené {date} se zpracovává. Pro více informací navštivte <a href=\"{complaint_detail_url}\">detail reklamace</a>.<br /><br />Potřebujete cokoliv jiného? Navštivte naše <a href=\"{url}\">webové stránky</a>."

msgid "Default VAT rate"
msgstr "Výchozí sazba DPH"
Expand Down Expand Up @@ -3490,6 +3490,9 @@ msgstr "Začátek"
msgid "Status"
msgstr "Stav"

msgid "Status of complaint with number {complaint_number} from order number {order_number} created on {date} has changed"
msgstr "Stav reklamace s číslem {complaint_number} z objednávky číslo {order_number} vytvořené {date} se změnil"

msgid "Status of complaints"
msgstr "Stavy reklamací"

Expand Down
13 changes: 8 additions & 5 deletions src/Resources/translations/messages.en.po
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ msgstr ""
msgid "Complaint Nr. <strong><a href=\"{{ url }}\">{{ number }}</a></strong> modified"
msgstr ""

msgid "Complaint detail URL"
msgstr ""

msgid "Complaint items"
msgstr ""

Expand All @@ -688,9 +691,6 @@ msgstr ""
msgid "Complaint status"
msgstr ""

msgid "Complaint status has changed"
msgstr ""

msgid "Complaint statuses - full"
msgstr ""

Expand Down Expand Up @@ -1057,10 +1057,10 @@ msgstr ""
msgid "Days until delivery"
msgstr ""

msgid "Dear customer, <br /><br />Processing your complaint has been finished."
msgid "Dear customer, <br /><br />Your complaint with number {complaint_number} from order number {order_number} created {date} has been finished. For more information, visit <a href=\"{complaint_detail_url}\">complaint detail</a>.<br /><br />Do you need anything else? Visit our <a href=\"{url}\">website</a>."
msgstr ""

msgid "Dear customer, <br /><br />Your complaint is being processed."
msgid "Dear customer, <br /><br />Your complaint with number {complaint_number} from order number {order_number} created {date} is being processed. For more information, visit <a href=\"{complaint_detail_url}\">complaint detail</a>.<br /><br />Do you need anything else? Visit our <a href=\"{url}\">website</a>."
msgstr ""

msgid "Default VAT rate"
Expand Down Expand Up @@ -3490,6 +3490,9 @@ msgstr ""
msgid "Status"
msgstr ""

msgid "Status of complaint with number {complaint_number} from order number {order_number} created on {date} has changed"
msgstr ""

msgid "Status of complaints"
msgstr ""

Expand Down

0 comments on commit e008749

Please sign in to comment.