Overriding Annex I texts and email templates in your theme
What it does
Replace the Annex I texts (the withdrawal information notice and the model withdrawal form) and the module's email templates with your own versions, kept in your storefront theme. The module reads both from the theme first and falls back to its own files.
Before you start
- You have your own storefront theme, or a child theme of the one you use, under
app/design/frontend/Vendor/theme/(your vendor and theme names). - You have the module's original files to copy from. For a Composer install they are in
vendor/mageme/module-eu-withdrawal/view/frontend/. - The new texts are checked (merchant review required). The module does not check what you write.
Steps
Override the Annex I texts
-
Copy
view/frontend/precontract/annex_i_xx_XX.xmlof the module for each language you change, wherexx_XXis the locale, for exampleannex_i_de_DE.xml. -
Put the copy in your theme as
app/design/frontend/Vendor/theme/MageMe_EUWithdrawal/precontract/annex_i_xx_XX.xml. -
Edit the texts inside the elements. Keep the structure: the
annex_iaelement with onesectionelement per part of the notice, and theannex_ibelement with the model form.<annex_ia><section id="right_of_withdrawal">You have the right to withdraw from this contract within {period_days} days without giving any reason.</section><!-- … the other sections … --></annex_ia><annex_ib>MODEL WITHDRAWAL FORM…</annex_ib> -
Keep the placeholders in braces. The module fills them from your settings:
{merchant_name},{merchant_address},{merchant_phone},{merchant_email},{merchant_return_address},{period_days}and{withdrawal_function_url}. -
Flush the Magento cache.
Override an email template
- Copy the template from
view/frontend/email/of the module, for examplereceipt.html. - Put the copy in your theme as
app/design/frontend/Vendor/theme/MageMe_EUWithdrawal/email/receipt.html. - Edit the copy. Keep the variables the template uses, such as
{{var email_footer_html|raw}}. - Flush the Magento cache.
The files you can override: notification.html (submission), approved.html, denied.html, cancelled_admin.html,
cancelled_self.html, receipt.html, auto_refund_initiated.html, waiver_confirmation_consumer.html,
waiver_confirmation_merchant_bcc.html, and the four order and shipment templates sales_order_new.html,
sales_order_new_guest.html, sales_shipment_new.html and sales_shipment_new_guest.html.
To change an email for one store only, without a theme file, create a template from the module's one in Marketing → Email Templates and select it in the settings. See Turning emails on and off.
Add the withdrawal box to your own order email
If your order or shipment email uses a template of your own, add the box where it should appear:
{{depend withdrawal_link_url}}
<tr class="email-withdrawal">
<td>
{{block class='MageMe\EUWithdrawal\Block\Email\WithdrawalLinkSnippet' template='MageMe_EUWithdrawal::email/withdrawal_link_snippet.phtml' withdrawal_link_url=$withdrawal_link_url}}
</td>
</tr>
{{/depend}}
The module sets withdrawal_link_url for order and shipment emails of orders in scope. Invoice emails don't get it. With Pro, it is the
Magic Link. See Withdrawal link in order and shipment emails.
What you should see
- The withdrawal information at checkout shows your text for the locale you overrode. Other locales keep the module's text.
- The next email of the type you overrode uses your template.
Limits
- An Annex I file applies to its exact locale. A store view whose locale has no file in the theme or the module uses the file of its parent language, then English, and the module records that fallback in the audit log (Pro). See Languages, locales and button labels.
- A child theme's file wins over its parent's. The module walks the theme chain of the store view.
- A malformed Annex I file stops the notice from showing at checkout for that locale. The checkout still works, and the error is written to the Magento log. Check the XML before you deploy it.
- With Pro, Pre-Contract Proof stores each new version of the notice text the first time a customer sees it. Orders placed earlier keep the version they were shown. See Pre-Contract Proof.
- Theme files are part of your deployment. Compare them with the module's files after each update of the module.
Troubleshooting
- The old text still shows. Flush the cache, and check that the file is in the theme used by the store view, in
MageMe_EUWithdrawal/precontract/, with the exact locale in its name. - The email shows an empty footer or
{{var …}}text. A variable was removed or misspelt in your copy. Compare it with the module's template.
What's next
- Annex I texts: notice and model withdrawal form: what the texts are and where they appear.
- Withdrawal link in order and shipment emails: the module's order and shipment templates.
- Customising the waiver texts: the waiver texts are changed in the admin, not in the theme.