Skip to content

Commit

Permalink
updated email templates (#3711)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlebektomas authored Jan 20, 2025
2 parents 14a8579 + 3f17f1e commit 213cf86
Show file tree
Hide file tree
Showing 22 changed files with 662 additions and 174 deletions.
6 changes: 3 additions & 3 deletions src/Form/Admin/Transport/TransportFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => t('Tracking URL variables'),
'required' => false,
'variables' => [
OrderMail::TRANSPORT_VARIABLE_TRACKING_NUMBER => [
OrderMail::VARIABLE_TRANSPORT_TRACKING_NUMBER => [
'text' => t('Tracking number'),
'required' => false,
],
Expand All @@ -218,11 +218,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => t('Tracking instructions variables'),
'required' => false,
'variables' => [
OrderMail::TRANSPORT_VARIABLE_TRACKING_NUMBER => [
OrderMail::VARIABLE_TRANSPORT_TRACKING_NUMBER => [
'text' => t('Tracking number'),
'required' => false,
],
OrderMail::TRANSPORT_VARIABLE_TRACKING_URL => [
OrderMail::VARIABLE_TRANSPORT_TRACKING_URL => [
'text' => t('Tracking URL'),
'required' => false,
],
Expand Down
5 changes: 3 additions & 2 deletions src/Migrations/Version20241001113136.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ public function up(Schema $schema): void
$this->updateMailTemplate(
InquiryMail::CUSTOMER_MAIL_TEMPLATE_NAME,
t('Thank you for your product inquiry', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale),
t('<div class="gjs-text-ckeditor"><p>Dear {fullName},</p><p>Thank you for your interest in <a data-cke-saved-href="{productUrl}" href="{productUrl}">{productName}</a>.</p><p>We have received your inquiry and will be reaching out to you shortly with further information.</p><p>If you need immediate assistance or have additional questions, feel free to reply to this email or contact us.</p><p>Best regards</p></div>', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale),
t('<div class="gjs-text-ckeditor"><div style="font-family: Arial, sans-serif; line-height: 1.6;"><h1>Your inquiry has been placed</h1><p>Dear {fullName},</p><p>thank you for your interest! We will be reaching out to you shortly with further information.</p><p><strong>Inquired product:</strong></p><p><a data-cke-saved-href="{productUrl}" href="{productUrl}" style="color: #1a73e8; text-decoration: none">{productName}</a> (Catalog number: {productCatnum})</p><p><img src="{productImageUrl}" alt="{productName}" style="max-width: 200px; max-height: 200px; height: auto" /></p><p><strong>Your contact details:</strong></p><ul style="list-style-type: none; padding: 0"><li><strong>Name:</strong> {fullName}</li><li><strong>Email:</strong> <a href="mailto:{email}">{email}</a></li><li><strong>Telephone:</strong> <a href="tel:{telephone}">{telephone}</a></li><li><strong>Company name:</strong> {companyName}</li><li><strong>Company number:</strong> {companyNumber}</li><li><strong>Company tax number:</strong> {companyTaxNumber}</li></ul><p><strong>Note:</strong></p><blockquote style="border-left: 4px solid #ccc;margin: 0 0 1em;padding: 0.5em;font-style: italic;background-color: #f9f9f9;">{note}</blockquote><p>If you need immediate assistance or have additional questions, feel free to reply to this email or contact us.</p><p>Best regards</p></div></div>
', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale),
$domainId,
);

$this->updateMailTemplate(
InquiryMail::ADMIN_MAIL_TEMPLATE_NAME,
t('New product inquiry received', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale),
t('<div class="gjs-text-ckeditor"><div style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;"><p>A new product inquiry has just been received from <strong>{fullName}</strong>.</p><p>Please find the details below:</p><ul style="list-style-type: none; padding: 0;"><li><strong>Customer name:</strong> {fullName}</li><li><strong>Customer email:</strong> <a href="mailto:{email}">{email}</a></li><li><strong>Customer telephone:</strong> <a href="tel:{telephone}">{telephone}</a></li><li><strong>Company name:</strong> {companyName}</li><li><strong>Company number:</strong> {companyNumber}</li><li><strong>Company tax number:</strong> {companyTaxNumber}</li></ul><p><strong>Note from customer:</strong></p><blockquote style="border-left: 4px solid #ccc; margin: 0 0 1em; padding: 0.5em; font-style: italic; background-color: #f9f9f9;">{note}</blockquote><p><strong>Inquired product:</strong></p><p><a href="{productUrl}" style="color: #1a73e8; text-decoration: none;">{productName}</a> (Catalog number: {productCatnum})</p><p><img src="{productImageUrl}" alt="{productName}" style="max-width: 200px; height: auto; border: 1px solid #ddd; padding: 4px;"></p><p>Please review the inquiry and take the necessary steps to follow up.</p><p><a href="{adminInquiryDetailUrl}" style="background-color: #1a73e8; color: #fff; padding: 10px 15px; text-decoration: none; border-radius: 5px;">Review Inquiry</a></p></div></div>
t('<div class="gjs-text-ckeditor"><div style="font-family: Arial, sans-serif; line-height: 1.6;"><p>A new product inquiry has just been received from <strong>{fullName}</strong>.</p><p>Please find the details below:</p><ul style="list-style-type: none; padding: 0;"><li><strong>Customer name:</strong> {fullName}</li><li><strong>Customer email:</strong> <a href="mailto:{email}">{email}</a></li><li><strong>Customer telephone:</strong> <a href="tel:{telephone}">{telephone}</a></li><li><strong>Company name:</strong> {companyName}</li><li><strong>Company number:</strong> {companyNumber}</li><li><strong>Company tax number:</strong> {companyTaxNumber}</li></ul><p><strong>Note from customer:</strong></p><blockquote style="border-left: 4px solid #ccc; margin: 0 0 1em; padding: 0.5em; font-style: italic; background-color: #f9f9f9;">{note}</blockquote><p><strong>Inquired product:</strong></p><p><a href="{productUrl}" style="color: #1a73e8; text-decoration: none;">{productName}</a> (Catalog number: {productCatnum})</p><p><img src="{productImageUrl}" alt="{productName}" style="max-width: 200px; height: auto; border: 1px solid #ddd; padding: 4px;"></p><p>Please review the inquiry and take the necessary steps to follow up.</p><p><a href="{adminInquiryDetailUrl}" style="background-color: #1a73e8; color: #fff; padding: 10px 15px; text-decoration: none; border-radius: 5px;">Review Inquiry</a></p></div></div>
', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale),
$domainId,
);
Expand Down
14 changes: 11 additions & 3 deletions src/Model/ContactForm/ContactFormFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Mail\Mailer;
use Shopsys\FrameworkBundle\Model\Mail\MailTemplateBuilder;
use Shopsys\FrameworkBundle\Model\Mail\MessageData;
use Shopsys\FrameworkBundle\Model\Mail\Setting\MailSettingFacade;
use Twig\Environment;
Expand All @@ -17,19 +18,21 @@ class ContactFormFacade
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
* @param \Shopsys\FrameworkBundle\Model\Mail\Mailer $mailer
* @param \Twig\Environment $twig
* @param \Shopsys\FrameworkBundle\Model\Mail\MailTemplateBuilder $mailTemplateBuilder
*/
public function __construct(
protected readonly MailSettingFacade $mailSettingFacade,
protected readonly Domain $domain,
protected readonly Mailer $mailer,
protected readonly Environment $twig,
protected readonly MailTemplateBuilder $mailTemplateBuilder,
) {
}

/**
* @param \Shopsys\FrameworkBundle\Model\ContactForm\ContactFormData $contactFormData
*/
public function sendMail(ContactFormData $contactFormData)
public function sendMail(ContactFormData $contactFormData): void
{
$mainAdminMail = $this->mailSettingFacade->getMainAdminMail($this->domain->getId());
$messageData = new MessageData(
Expand All @@ -47,10 +50,15 @@ public function sendMail(ContactFormData $contactFormData)
* @param \Shopsys\FrameworkBundle\Model\ContactForm\ContactFormData $contactFormData
* @return string
*/
protected function getMailBody($contactFormData)
protected function getMailBody(ContactFormData $contactFormData): string
{
return $this->twig->render('@ShopsysFramework/Mail/ContactForm/mail.html.twig', [
$content = $this->twig->render('@ShopsysFramework/Mail/ContactForm/mail.html.twig', [
'contactFormData' => $contactFormData,
]);

return $this->mailTemplateBuilder->getMailTemplateWithContent(
$this->domain->getId(),
$content,
);
}
}
Loading

0 comments on commit 213cf86

Please sign in to comment.