E-Mailテンプレートの編集
ModernよりもClassicテーマの方がレイアウトが整然としていて見やすいです。
メールで使用される各テンプレートは、テーマ毎 (Modern, Classic)
に mails/themes
に纏められています。
mails/themes
フォルダ内の各テーマの twig
ファイルから、html
または txt
形式のファイルが作成されます(この作成作業は、管理画面のデザイン ---> Email Theme ---> Generate emails
から行うか、以下のprestashop:mail:generate
でも可能です)。
prestashop:mail:generate
# bin/console prestashop:mail:generate --help
Usage:
prestashop:mail:generate [options] [--] <theme> <locale> [<coreOutputFolder>] [<modulesOutputFolder>]
Arguments:
theme Theme to use for mail templates.
locale Which locale to use for the templates.
coreOutputFolder Output folder to export core templates.
modulesOutputFolder Output folder to export modules templates (by default same as core).
Options:
-o, --overwrite[=OVERWRITE] Overwrite existing templates [default: false]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "dev"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
ロケールと上書きオプションを指定してジェネレートコマンドを実行
# bin/console prestashop:mail:generate -o true classic ja-JP
# bin/console prestashop:mail:generate -o true classic en-US
また、作成されたテーマごとのメール送信テストは、 Email themes
から行うことが出来ます(選択したテーマでのみ送信テストが可能)。
作成されたテンプレートをさらに細かく編集したい場合には、以下翻訳メニューから行うことが出来ます。
International ---> Translations ---> Modify Translations
から以下の項目を選択
Core emails
から編集するテンプレートを選択
テンプレートの編集箇所が多い場合は、直接twigファイルを編集したほうが良いかもしれません。上記テンプレートの {recycled_packaging_label}
やフッター prestashop
へのリンクを削除する場合は、メールコアの order_conf
で該当する表の行を削除するか、
次のClassicテーマのtwigテンプレート
mails/themes/classic/conponents/footer.html.twig
mails/themes/classic/core/order_conf.html.twig
から該当箇所を削除し、以下のメニュー画面に従って言語毎に再作成します(編集後、所有権の修正を忘れずに)。
Gmail SMTPサーバによる送信メール内のイメージについて
メール関連ファイル
コントローラ
src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmailController.php
管理画面メール設定ファイル
src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/email.yml
テンプレート設定ファイル
src/PrestaShopBundle/Resources/config/services/core/mail_template.yml
prestashop.core.mail_template.theme_folder_catalog:
class: 'PrestaShop\PrestaShop\Core\MailTemplate\FolderThemeCatalog'
arguments:
- '%mail_themes_dir%'
- '@prestashop.core.mail_template.theme_folder_scanner'
- '@prestashop.core.hook.dispatcher'
prestashop.core.mail_template.variables_builder:
class: 'PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutVariablesBuilder'
arguments:
- '@prestashop.core.hook.dispatcher'
- '@prestashop.core.language.language_default_fonts_catalog'
- mailThemesUrl: "@=service('prestashop.adapter.legacy.context').getMailThemesUrl()"
上記 mailThemesUrl
は、
src/Adapter/LegacyContext.php
/**
* Url to the mail themes folder
*
* @return string
*/
public function getMailThemesUrl()
{
return $this->tools->getShopDomainSsl(true) . __PS_BASE_URI__ . $this->mailThemesUri;
}
管理画面メール設定テンプレートフォルダ
src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email
Twig Configration
app/config/config.yml
# Twig Configuration
twig:
autoescape: "name"
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- 'PrestaShopBundle:Admin/TwigTemplateForm:bootstrap_4_horizontal_layout.html.twig'
paths:
'%admin_page%/Product': Product
'%admin_page%/TwigTemplateForm': Twig
'%admin_page%/Common': Common
'%admin_page%/Configure/AdvancedParameters': AdvancedParameters
'%admin_page%/Configure/ShopParameters': ShopParameters
'%kernel.root_dir%/../modules': Modules
'%mail_themes_dir%': MailThemes
globals:
webpack_server: false
multistore_field_prefix: !php/const:PrestaShopBundle\Service\Form\MultistoreCheckboxEnabler::MULTISTORE_FIELD_PREFIX
送信メールテンプレート
mails/themes/modern/core/order_conf.html.twig
<img src="{{ mailThemesUrl }}/modern/assets/baseline-local_shipping-24px.png" style="margin-{{ align_right }}:10px">