run-as-root / module-eu-warranty
Displays the official EU Warranty Notice in a frontend modal and in order confirmation emails
Package info
github.com/run-as-root/magento2-module-eu-warranty
Type:magento2-module
pkg:composer/run-as-root/module-eu-warranty
Requires
- php: ^8.1
- magento/framework: *
- magento/module-config: *
- magento/module-email: *
- magento/module-sales: *
- magento/module-store: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Displays the official EU legal guarantee notice (EU Warranty Notice) on a dedicated storefront page and in order confirmation emails.
Configuration
Stores > Configuration > General > EU Warranty Information
General
- Notice Language — the notice language. Defaults to English when left empty.
Notice Page
- Enabled — turns the notice on for the
/eu-warrantypage. - Custom URL — an additional URL (e.g.
legal/warranty) the/eu-warrantypage is also reachable at. Leave empty to only use the default/eu-warrantyURL. - Meta Title — the browser tab title for the
/eu-warrantypage. Optional, defaults to "Legal Guarantee" when left empty. - Show H1 Heading — shows an H1 heading above the Notice on the
/eu-warrantypage. - H1 Heading — the H1 text. Optional, defaults to "Legal Guarantee" when left empty.
Order Confirmation Email
- Include Warranty Notice — includes the notice in the order confirmation email (see below on how to insert it into the template).
- Notice Format — how the notice is included in the order confirmation email:
- Insert into HTML — embeds the Notice image inline in the email body.
- Attach as PDF — attaches the Notice PDF file to the email; the email body only gets a link to the full text.
- PDF File Name — the file name (without extension) of the attached PDF. Optional, defaults to "eu-warranty" when left empty.
The full-text URL (full_text_url) is computed automatically from the selected language (europa.eu/.../index_<lang>.htm) and is not configurable.
The /eu-warranty page
The page is created automatically by the module but isn't linked anywhere — add a link to it manually (e.g. via the CMS footer editor). Set Notice Page > Custom URL if you'd rather link to a different, friendlier URL; the default /eu-warranty URL keeps working regardless.
To add content (e.g. a CMS block widget) before or after the Notice on this page, go to Content > Elements > Widgets, create a widget, and under its layout update pick Specified Page > EU Warranty Notice Page, then choose the "EU Warranty Notice - Before" or "EU Warranty Notice - After" container.
Inserting the notice into the order email
There are two ways to do this. Both require Order Confirmation Email > Include Warranty Notice = Yes — otherwise the notice simply won't render.
Option 1 — layout handle (recommended)
Add a single line to the email template (e.g. next to sales_email_order_items):
{{layout handle="eu_warranty_email_notice" order_id=$order_id area="frontend"}}
The block resolves the notice itself and adapts automatically: it renders the inline image + link for "Insert into HTML", just the link for "Attach as PDF" (see below), and nothing at all when disabled — no extra guarding needed.
Option 2 — manually, via variables
If you need full control over the markup, use the warranty_notice.* template variables. They're also available in the template editor's Insert Variable... popup, under their own "Warranty Notice" group.
{{depend warranty_notice.enabled}}
<table width="100%" cellspacing="0" cellpadding="0" border="0" role="presentation">
<tr>
<td style="padding: 20px 0;">
{{if warranty_notice.html}}
<img src="{{var warranty_notice.image_url}}"
alt="{{trans 'EU legal guarantee notice'}}"
width="600"
style="display:block; width:100%; max-width:600px; height:auto; margin: 0 0 10px; border:1px solid #000; background-color:#fff;"/>
{{/if}}
<p style="margin: 0;">
<a href="{{var warranty_notice.full_text_url}}">
{{trans 'Read the full legal guarantee information'}}
</a>
</p>
</td>
</tr>
</table>
{{/depend}}
The image only renders in "Insert into HTML" mode (warranty_notice.html); the link itself
always renders regardless of mode.
Important: the inner conditional block uses {{if warranty_notice.html}}, not {{depend}} — both would otherwise share the same parent {{depend warranty_notice.enabled}}, and two nested {{depend}} blocks with the same directive name break the template parser (the outer block closes at the first {{/depend}}} it finds, i.e. the inner block's closing tag). Don't change {{if}} back to {{depend}} here.
PDF attachment on the order confirmation email
When Order Confirmation Email > Notice Format is set to Attach as PDF (with
Order Confirmation Email > Include Warranty Notice = Yes), the customer receives
the Notice as a PDF file attached to their order confirmation email (and any copies
sent to other recipients). Since the image itself is now in the attachment, both the
eu_warranty_email_notice layout handle and the warranty_notice.* variables render
only a link to the full text in this mode, instead of the inline image. It works no
matter which mail-sending method (SMTP or otherwise) the store uses.