Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Added store branding for customer emails

Damian Legawiecef779a50b136
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yaml
index 0dccf09154..d194392f13 100644
--- a/docs/api-reference/admin.yaml
+++ b/docs/api-reference/admin.yaml
@@ -7445,59 +7445,62 @@ paths:
key: layouts/spree/base_mailer
subject:
body: |
- <mjml lang="{{ locale }}">
+ {% assign brand = store.branding %}<mjml lang="{{ locale }}">
<mj-head>
<mj-title>{{ subject }}</mj-title>
+ {% if brand.font_url %}<mj-font name="{{ brand.font_family | split: ',' | first }}" href="{{ brand.font_url }}" />{% endif %}
<mj-attributes>
- <mj-all font-family="Inter, Helvetica, Arial, sans-serif" />
+ <mj-all font-family="{{ brand.font_family }}" />
<mj-section padding="0" />
<mj-column padding="0" />
- <mj-text padding="0" color="#726A6A" font-size="14px" line-height="1.6" align="center" />
- <mj-button background-color="#FFFFFF" border="1px solid #E8E9E9" border-radius="8px" color="#1F2222" font-size="15px" font-weight="500" line-height="1.6" inner-padding="12px 20px" padding="32px 0 0" />
- <mj-table padding="0" color="#726A6A" font-size="14px" line-height="1.6" />
- <mj-class name="heading" font-family="Geist, Inter, Helvetica, Arial, sans-serif" font-size="40px" font-weight="700" line-height="1.2" letter-spacing="-0.8px" color="#332C2C" css-class="heading" />
- <mj-class name="greeting" padding="24px 0 0" font-size="15px" font-weight="500" color="#332C2C" />
+ <mj-text padding="0" color="{{ brand.text_color }}" font-size="14px" line-height="1.6" align="center" />
+ <mj-button background-color="{{ brand.button_color }}" border="{{ brand.button_border }}" border-radius="8px" color="{{ brand.button_text_color }}" font-size="15px" font-weight="500" line-height="1.6" inner-padding="12px 20px" padding="32px 0 0" />
+ <mj-table padding="0" color="{{ brand.text_color }}" font-size="14px" line-height="1.6" />
+ <mj-class name="heading" font-family="{{ brand.heading_font_family }}" font-size="40px" font-weight="700" line-height="1.2" letter-spacing="-0.8px" color="{{ brand.heading_color }}" css-class="heading" />
+ <mj-class name="greeting" padding="24px 0 0" font-size="15px" font-weight="500" color="{{ brand.heading_color }}" />
<mj-class name="lead" padding="12px 0 0" />
<mj-class name="note" padding="24px 0 0" font-size="13px" css-class="note" />
- <mj-class name="section-heading" padding="48px 0 16px" font-family="Geist, Inter, Helvetica, Arial, sans-serif" font-size="16px" font-weight="500" letter-spacing="-0.16px" align="left" />
+ <mj-class name="section-heading" padding="48px 0 16px" font-family="{{ brand.heading_font_family }}" font-size="16px" font-weight="500" letter-spacing="-0.16px" align="left" />
<mj-class name="body" padding="16px 0 0" align="left" />
<mj-class name="footer" padding="12px 0 0" font-size="11px" line-height="1.5" />
</mj-attributes>
<mj-style>
+ {% if brand.font == 'inter' %}
@font-face { font-family: "Geist"; font-style: normal; font-weight: 500 700; src: url("https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwcGFU.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 450; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuOKfMZg.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf") format("truetype"); }
- a { color: #332C2C; }
+ {% endif %}
+ a { color: {{ brand.link_color }}; }
.hero > table { max-width: 420px; margin: 0 auto; }
- .note a { color: #726A6A; word-break: break-all; }
- .footer a { color: #726A6A; }
+ .note a { color: {{ brand.text_color }}; word-break: break-all; }
+ .footer a { color: {{ brand.text_color }}; }
.item { width: 100%; background-color: #F0F0F0; border-radius: 16px; margin: 0 0 8px; }
.item_image { padding: 8px; width: 96px; }
.item_thumb { display: block; width: 80px; height: auto; border-radius: 12px; }
.item_thumb_placeholder { width: 80px; height: 80px; background-color: #E4E4E4; border-radius: 12px; }
.item_info { padding: 8px 16px 8px 8px; }
- .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; text-decoration: none; }
- .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
+ .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: {{ brand.heading_color }}; text-decoration: none; }
+ .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: {{ brand.text_color }}; }
.item_amount { padding: 8px 16px 8px 8px; text-align: right; white-space: nowrap; }
- .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
- .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; }
- .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: #726A6A; }
- .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: #332C2C; }
+ .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: {{ brand.text_color }}; }
+ .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: {{ brand.heading_color }}; }
+ .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: {{ brand.text_color }}; }
+ .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: {{ brand.heading_color }}; }
.summary_sub { display: block; font-size: 13px; line-height: 1.5; }
- .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: #332C2C; }
+ .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: {{ brand.heading_color }}; }
.summary_total .summary_value { font-weight: 600; }
- .mailer_hero h1 { margin: 0; font-family: Geist, Inter, Helvetica, Arial, sans-serif; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: #332C2C; }
+ .mailer_hero h1 { margin: 0; font-family: {{ brand.heading_font_family }}; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: {{ brand.heading_color }}; }
.mailer_hero p { margin: 12px 0 0; }
- .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: #332C2C; }
+ .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: {{ brand.heading_color }}; }
.mailer_hero .sub { margin-top: 24px; font-size: 13px; }
@media only screen and (max-width: 600px) {
.heading div { font-size: 32px !important; letter-spacing: -0.64px !important; }
}
</mj-style>
</mj-head>
- <mj-body background-color="#FFFFFF" width="640px">
- <mj-wrapper background-color="#F6F6F6" padding="56px 24px">
+ <mj-body background-color="{{ brand.background_color }}" width="640px">
+ <mj-wrapper background-color="{{ brand.card_color }}" padding="56px 24px">
<mj-section padding="0 0 32px">
<mj-column>
{% if store.logo_url and store.logo_width %}
@@ -7505,7 +7508,7 @@ paths:
{% elsif store.logo_url %}
<mj-text><a href="{{ store.url }}"><img src="{{ store.logo_url }}" alt="{{ store.name }}" height="32" style="height: 32px; width: auto; border: 0;" /></a></mj-text>
{% else %}
- <mj-text font-size="22px" font-weight="700" color="#332C2C" text-transform="uppercase"><a href="{{ store.url }}" style="color: #332C2C; text-decoration: none;">{{ store.name }}</a></mj-text>
+ <mj-text font-size="22px" font-weight="700" color="{{ brand.heading_color }}" text-transform="uppercase"><a href="{{ store.url }}" style="color: {{ brand.heading_color }}; text-decoration: none;">{{ store.name }}</a></mj-text>
{% endif %}
</mj-column>
</mj-section>
@@ -7528,59 +7531,62 @@ paths:
published_at:
default_subject:
default_body: |
- <mjml lang="{{ locale }}">
+ {% assign brand = store.branding %}<mjml lang="{{ locale }}">
<mj-head>
<mj-title>{{ subject }}</mj-title>
+ {% if brand.font_url %}<mj-font name="{{ brand.font_family | split: ',' | first }}" href="{{ brand.font_url }}" />{% endif %}
<mj-attributes>
- <mj-all font-family="Inter, Helvetica, Arial, sans-serif" />
+ <mj-all font-family="{{ brand.font_family }}" />
<mj-section padding="0" />
<mj-column padding="0" />
- <mj-text padding="0" color="#726A6A" font-size="14px" line-height="1.6" align="center" />
- <mj-button background-color="#FFFFFF" border="1px solid #E8E9E9" border-radius="8px" color="#1F2222" font-size="15px" font-weight="500" line-height="1.6" inner-padding="12px 20px" padding="32px 0 0" />
- <mj-table padding="0" color="#726A6A" font-size="14px" line-height="1.6" />
- <mj-class name="heading" font-family="Geist, Inter, Helvetica, Arial, sans-serif" font-size="40px" font-weight="700" line-height="1.2" letter-spacing="-0.8px" color="#332C2C" css-class="heading" />
- <mj-class name="greeting" padding="24px 0 0" font-size="15px" font-weight="500" color="#332C2C" />
+ <mj-text padding="0" color="{{ brand.text_color }}" font-size="14px" line-height="1.6" align="center" />
+ <mj-button background-color="{{ brand.button_color }}" border="{{ brand.button_border }}" border-radius="8px" color="{{ brand.button_text_color }}" font-size="15px" font-weight="500" line-height="1.6" inner-padding="12px 20px" padding="32px 0 0" />
+ <mj-table padding="0" color="{{ brand.text_color }}" font-size="14px" line-height="1.6" />
+ <mj-class name="heading" font-family="{{ brand.heading_font_family }}" font-size="40px" font-weight="700" line-height="1.2" letter-spacing="-0.8px" color="{{ brand.heading_color }}" css-class="heading" />
+ <mj-class name="greeting" padding="24px 0 0" font-size="15px" font-weight="500" color="{{ brand.heading_color }}" />
<mj-class name="lead" padding="12px 0 0" />
<mj-class name="note" padding="24px 0 0" font-size="13px" css-class="note" />
- <mj-class name="section-heading" padding="48px 0 16px" font-family="Geist, Inter, Helvetica, Arial, sans-serif" font-size="16px" font-weight="500" letter-spacing="-0.16px" align="left" />
+ <mj-class name="section-heading" padding="48px 0 16px" font-family="{{ brand.heading_font_family }}" font-size="16px" font-weight="500" letter-spacing="-0.16px" align="left" />
<mj-class name="body" padding="16px 0 0" align="left" />
<mj-class name="footer" padding="12px 0 0" font-size="11px" line-height="1.5" />
</mj-attributes>
<mj-style>
+ {% if brand.font == 'inter' %}
@font-face { font-family: "Geist"; font-style: normal; font-weight: 500 700; src: url("https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwcGFU.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 450; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuOKfMZg.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf") format("truetype"); }
- a { color: #332C2C; }
+ {% endif %}
+ a { color: {{ brand.link_color }}; }
.hero > table { max-width: 420px; margin: 0 auto; }
- .note a { color: #726A6A; word-break: break-all; }
- .footer a { color: #726A6A; }
+ .note a { color: {{ brand.text_color }}; word-break: break-all; }
+ .footer a { color: {{ brand.text_color }}; }
.item { width: 100%; background-color: #F0F0F0; border-radius: 16px; margin: 0 0 8px; }
.item_image { padding: 8px; width: 96px; }
.item_thumb { display: block; width: 80px; height: auto; border-radius: 12px; }
.item_thumb_placeholder { width: 80px; height: 80px; background-color: #E4E4E4; border-radius: 12px; }
.item_info { padding: 8px 16px 8px 8px; }
- .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; text-decoration: none; }
- .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
+ .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: {{ brand.heading_color }}; text-decoration: none; }
+ .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: {{ brand.text_color }}; }
.item_amount { padding: 8px 16px 8px 8px; text-align: right; white-space: nowrap; }
- .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
- .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; }
- .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: #726A6A; }
- .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: #332C2C; }
+ .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: {{ brand.text_color }}; }
+ .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: {{ brand.heading_color }}; }
+ .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: {{ brand.text_color }}; }
+ .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: {{ brand.heading_color }}; }
.summary_sub { display: block; font-size: 13px; line-height: 1.5; }
- .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: #332C2C; }
+ .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: {{ brand.heading_color }}; }
.summary_total .summary_value { font-weight: 600; }
- .mailer_hero h1 { margin: 0; font-family: Geist, Inter, Helvetica, Arial, sans-serif; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: #332C2C; }
+ .mailer_hero h1 { margin: 0; font-family: {{ brand.heading_font_family }}; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: {{ brand.heading_color }}; }
.mailer_hero p { margin: 12px 0 0; }
- .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: #332C2C; }
+ .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: {{ brand.heading_color }}; }
.mailer_hero .sub { margin-top: 24px; font-size: 13px; }
@media only screen and (max-width: 600px) {
.heading div { font-size: 32px !important; letter-spacing: -0.64px !important; }
}
</mj-style>
</mj-head>
- <mj-body background-color="#FFFFFF" width="640px">
- <mj-wrapper background-color="#F6F6F6" padding="56px 24px">
+ <mj-body background-color="{{ brand.background_color }}" width="640px">
+ <mj-wrapper background-color="{{ brand.card_color }}" padding="56px 24px">
<mj-section padding="0 0 32px">
<mj-column>
{% if store.logo_url and store.logo_width %}
@@ -7588,7 +7594,7 @@ paths:
{% elsif store.logo_url %}
<mj-text><a href="{{ store.url }}"><img src="{{ store.logo_url }}" alt="{{ store.name }}" height="32" style="height: 32px; width: auto; border: 0;" /></a></mj-text>
{% else %}
- <mj-text font-size="22px" font-weight="700" color="#332C2C" text-transform="uppercase"><a href="{{ store.url }}" style="color: #332C2C; text-decoration: none;">{{ store.name }}</a></mj-text>
+ <mj-text font-size="22px" font-weight="700" color="{{ brand.heading_color }}" text-transform="uppercase"><a href="{{ store.url }}" style="color: {{ brand.heading_color }}; text-decoration: none;">{{ store.name }}</a></mj-text>
{% endif %}
</mj-column>
</mj-section>
@@ -8200,7 +8206,8 @@ paths:
matching record, or the one `record_id` names, and returns the email
with the variables it was rendered with. An unsaved `subject` and
`body` take the place of the current version. The layout and partials
- render inside an email, `email_key` or the first one.
+ render inside an email, `email_key` or the first one. `branding`
+ previews colors and a font before they are saved to the store.
**Required scope:** `write_email_templates` (for API-key authentication).
@@ -8243,60 +8250,134 @@ paths:
example:
id:
subject: ''
- html: |-
- <!doctype html><html lang="en" dir="auto" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title></title><!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
- <style type="text/css">
- #outlook a { padding: 0; }
- body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
- table, td { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
- img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }
- p { display: block; margin: 13px 0; }
- </style>
- <!--[if mso]>
- <noscript>
- <xml>
- <o:OfficeDocumentSettings>
- <o:AllowPNG/>
- <o:PixelsPerInch>96</o:PixelsPerInch>
- </o:OfficeDocumentSettings>
- </xml>
- </noscript>
- <![endif]-->
- <!--[if lte mso 11]>
- <style type="text/css">
- .mj-outlook-group-fix { width:100% !important; }
- </style>
- <![endif]-->
- <style type="text/css">@media only screen and (min-width:480px) { .mj-column-per-100 { width:100% !important; max-width:100%; } }</style><style media="screen and (min-width:480px)">.moz-text-html .mj-column-per-100 { width:100% !important; max-width:100%; } </style><style type="text/css">@font-face { font-family: "Geist"; font-style: normal; font-weight: 500 700; src: url("https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwcGFU.woff2") format("woff2"); }
- @font-face { font-family: "Inter"; font-style: normal; font-weight: 400 450; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuOKfMZg.ttf") format("truetype"); }
- @font-face { font-family: "Inter"; font-style: normal; font-weight: 500; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf") format("truetype"); }
- @font-face { font-family: "Inter"; font-style: normal; font-weight: 600; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf") format("truetype"); }
- a { color: #332C2C; }
- .hero > table { max-width: 420px; margin: 0 auto; }
- .note a { color: #726A6A; word-break: break-all; }
- .footer a { color: #726A6A; }
- .item { width: 100%; background-color: #F0F0F0; border-radius: 16px; margin: 0 0 8px; }
- .item_image { padding: 8px; width: 96px; }
- .item_thumb { display: block; width: 80px; height: auto; border-radius: 12px; }
- .item_thumb_placeholder { width: 80px; height: 80px; background-color: #E4E4E4; border-radius: 12px; }
- .item_info { padding: 8px 16px 8px 8px; }
- .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; text-decoration: none; }
- .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
- .item_amount { padding: 8px 16px 8px 8px; text-align: right; white-space: nowrap; }
- .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
- .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; }
- .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: #726A6A; }
- .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: #332C2C; }
- .summary_sub { display: block; font-size: 13px; line-height: 1.5; }
- .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: #332C2C; }
- .summary_total .summary_value { font-weight: 600; }
- .mailer_hero h1 { margin: 0; font-family: Geist, Inter, Helvetica, Arial, sans-serif; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: #332C2C; }
- .mailer_hero p { margin: 12px 0 0; }
- .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: #332C2C; }
- .mailer_hero .sub { margin-top: 24px; font-size: 13px; }
- @media only screen and (max-width: 600px) {
- .heading div { font-size: 32px !important; letter-spacing: -0.64px !important; }
- }</style></head><body style="word-spacing:normal;background-color:#FFFFFF;"><div lang="en" dir="auto" style="background-color:#FFFFFF;"><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation" bgcolor="#F6F6F6" align="center" width="640" style="width:640px;"><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:#F6F6F6;background-color:#F6F6F6;margin:0px auto;max-width:640px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" style="background:#F6F6F6;background-color:#F6F6F6;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:56px 24px;text-align:center;"><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation"><tr><td width="640px"><![endif]--><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" width="592" style="width:592px;"><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="margin:0px auto;max-width:592px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:0 0 32px;text-align:center;"><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation"><tr><![endif]--><!--[if mso | IE]><td style="vertical-align:top;width:592px;"><![endif]--><div class="mj-outlook-group-fix mj-column-per-100" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tbody><tr><td style="vertical-align:top;padding:0;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tbody><tr><td align="center" style="font-size:0px;padding:0;word-break:break-word;"><div style="font-family:Inter, Helvetica, Arial, sans-serif;font-size:22px;font-weight:700;line-height:1.6;text-align:center;text-transform:uppercase;color:#332C2C;"><a href="http://www.example.com:3000" style="color: #332C2C; text-decoration: none;">Spree Test Store</a></div></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]></td><![endif]--><!--[if mso | IE]></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--><!--[if mso | IE]></td></tr><tr><td width="640px"><![endif]--><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" width="592" style="width:592px;"><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="margin:0px auto;max-width:592px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:0;text-align:center;"><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation"><tr><![endif]--><!--[if mso | IE]><td style="vertical-align:top;width:592px;"><![endif]--><div class="mj-outlook-group-fix mj-column-per-100" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tbody><tr><td style="vertical-align:top;padding:0;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tbody><tr><td align="center" style="font-size:0px;padding:0;word-break:break-word;"><div style="font-family:Inter, Helvetica, Arial, sans-serif;font-size:14px;line-height:1.6;text-align:center;color:#726A6A;">Hi Ann</div></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]></td><![endif]--><!--[if mso | IE]></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" width="640" style="width:640px;"><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="margin:0px auto;max-width:640px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" align="center" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:64px 24px;text-align:center;"><!--[if mso | IE]><table border="0" cellpadding="0" cellspacing="0" role="presentation"><tr><![endif]--><!--[if mso | IE]><td style="vertical-align:top;width:640px;"><![endif]--><div class="mj-outlook-group-fix mj-column-per-100" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tbody><tr><td style="vertical-align:top;padding:0;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tbody><tr><td align="center" class="footer" style="font-size:0px;padding:0;word-break:break-word;"><div style="font-family:Inter, Helvetica, Arial, sans-serif;font-size:13px;line-height:1.5;text-align:center;color:#726A6A;"><a href="http://www.example.com:3000" style="font-weight: 500; text-decoration: none;">Spree Test Store</a></div></td></tr><tr><td align="center" class="footer" style="font-size:0px;padding:12px 0 0;word-break:break-word;"><div style="font-family:Inter, Helvetica, Arial, sans-serif;font-size:11px;line-height:1.5;text-align:center;color:#726A6A;"><a href="mailto:[email protected]">[email protected]</a></div></td></tr><tr><td align="center" style="font-size:0px;padding:20px 0 0;word-break:break-word;"><div style="font-family:Inter, Helvetica, Arial, sans-serif;font-size:11px;line-height:1.5;text-align:center;color:#726A6A;">&copy; 2026 Spree Test Store</div></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]></td><![endif]--><!--[if mso | IE]></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html>
+ html: "<!doctype html><html lang=\"en\" dir=\"auto\" xmlns=\"http://www.w3.org/1999/xhtml\"
+ xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\"><head><title></title><!--[if
+ !mso]><!--><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><!--<![endif]--><meta
+ http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><meta
+ name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<style
+ type=\"text/css\">\n#outlook a { padding: 0; }\nbody { margin: 0;
+ padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust:
+ 100%; }\ntable, td { border-collapse: collapse; mso-table-lspace:
+ 0pt; mso-table-rspace: 0pt; }\nimg { border: 0; height: auto; line-height:
+ 100%; outline: none; text-decoration: none; -ms-interpolation-mode:
+ bicubic; }\np { display: block; margin: 13px 0; }\n</style>\n<!--[if
+ mso]>\n<noscript>\n<xml>\n<o:OfficeDocumentSettings>\n <o:AllowPNG/>\n
+ \ <o:PixelsPerInch>96</o:PixelsPerInch>\n</o:OfficeDocumentSettings>\n</xml>\n</noscript>\n<![endif]-->\n<!--[if
+ lte mso 11]>\n<style type=\"text/css\">\n.mj-outlook-group-fix {
+ width:100% !important; }\n</style>\n<![endif]-->\n<style type=\"text/css\">@media
+ only screen and (min-width:480px) { .mj-column-per-100 { width:100%
+ !important; max-width:100%; } }</style><style media=\"screen and
+ (min-width:480px)\">.moz-text-html .mj-column-per-100 { width:100%
+ !important; max-width:100%; } </style><style type=\"text/css\">@font-face
+ { font-family: \"Geist\"; font-style: normal; font-weight: 500 700;
+ src: url(\"https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwcGFU.woff2\")
+ format(\"woff2\"); }\n @font-face { font-family: \"Inter\";
+ font-style: normal; font-weight: 400 450; src: url(\"https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuOKfMZg.ttf\")
+ format(\"truetype\"); }\n @font-face { font-family: \"Inter\";
+ font-style: normal; font-weight: 500; src: url(\"https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf\")
+ format(\"truetype\"); }\n @font-face { font-family: \"Inter\";
+ font-style: normal; font-weight: 600; src: url(\"https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf\")
+ format(\"truetype\"); }\n \n a { color: #332C2C; }\n .hero
+ > table { max-width: 420px; margin: 0 auto; }\n .note a { color:
+ #726A6A; word-break: break-all; }\n .footer a { color: #726A6A;
+ }\n .item { width: 100%; background-color: #F0F0F0; border-radius:
+ 16px; margin: 0 0 8px; }\n .item_image { padding: 8px; width:
+ 96px; }\n .item_thumb { display: block; width: 80px; height:
+ auto; border-radius: 12px; }\n .item_thumb_placeholder { width:
+ 80px; height: 80px; background-color: #E4E4E4; border-radius: 12px;
+ }\n .item_info { padding: 8px 16px 8px 8px; }\n .item_name
+ { font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C;
+ text-decoration: none; }\n .item_meta { margin: 2px 0 0; font-size:
+ 13px; line-height: 1.5; color: #726A6A; }\n .item_amount {
+ padding: 8px 16px 8px 8px; text-align: right; white-space: nowrap;
+ }\n .item_qty { margin: 0; font-size: 13px; line-height: 1.5;
+ color: #726A6A; }\n .item_price { margin: 2px 0 0; font-size:
+ 15px; line-height: 1.5; font-weight: 500; color: #332C2C; }\n .summary
+ td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: #726A6A;
+ }\n .summary_value { font-size: 15px; font-weight: 500; text-align:
+ right; white-space: nowrap; color: #332C2C; }\n .summary_sub
+ { display: block; font-size: 13px; line-height: 1.5; }\n .summary_total
+ td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight:
+ 500; color: #332C2C; }\n .summary_total .summary_value { font-weight:
+ 600; }\n .mailer_hero h1 { margin: 0; font-family: Geist, Inter,
+ Helvetica, Arial, sans-serif; font-size: 40px; line-height: 1.2;
+ letter-spacing: -0.8px; font-weight: 700; color: #332C2C; }\n .mailer_hero
+ p { margin: 12px 0 0; }\n .mailer_hero .greeting { margin-top:
+ 24px; font-size: 15px; font-weight: 500; color: #332C2C; }\n .mailer_hero
+ .sub { margin-top: 24px; font-size: 13px; }\n @media only screen
+ and (max-width: 600px) {\n .heading div { font-size: 32px
+ !important; letter-spacing: -0.64px !important; }\n }</style></head><body
+ style=\"word-spacing:normal;background-color:#FFFFFF;\"><div lang=\"en\"
+ dir=\"auto\" style=\"background-color:#FFFFFF;\"><!--[if mso | IE]><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ bgcolor=\"#F6F6F6\" align=\"center\" width=\"640\" style=\"width:640px;\"><tr><td
+ style=\"line-height:0px;font-size:0px;mso-line-height-rule:exactly;\"><![endif]--><div
+ style=\"background:#F6F6F6;background-color:#F6F6F6;margin:0px auto;max-width:640px;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ align=\"center\" style=\"background:#F6F6F6;background-color:#F6F6F6;width:100%;\"><tbody><tr><td
+ style=\"direction:ltr;font-size:0px;padding:56px 24px;text-align:center;\"><!--[if
+ mso | IE]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
+ role=\"presentation\"><tr><td width=\"640px\"><![endif]--><!--[if
+ mso | IE]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
+ role=\"presentation\" align=\"center\" width=\"592\" style=\"width:592px;\"><tr><td
+ style=\"line-height:0px;font-size:0px;mso-line-height-rule:exactly;\"><![endif]--><div
+ style=\"margin:0px auto;max-width:592px;\"><table border=\"0\" cellpadding=\"0\"
+ cellspacing=\"0\" role=\"presentation\" align=\"center\" style=\"width:100%;\"><tbody><tr><td
+ style=\"direction:ltr;font-size:0px;padding:0 0 32px;text-align:center;\"><!--[if
+ mso | IE]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
+ role=\"presentation\"><tr><![endif]--><!--[if mso | IE]><td style=\"vertical-align:top;width:592px;\"><![endif]--><div
+ class=\"mj-outlook-group-fix mj-column-per-100\" style=\"font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ width=\"100%\"><tbody><tr><td style=\"vertical-align:top;padding:0;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ width=\"100%\"><tbody><tr><td align=\"center\" style=\"font-size:0px;padding:0;word-break:break-word;\"><div
+ style=\"font-family:Inter, Helvetica, Arial, sans-serif;font-size:22px;font-weight:700;line-height:1.6;text-align:center;text-transform:uppercase;color:#332C2C;\"><a
+ href=\"http://www.example.com:3000\" style=\"color: #332C2C; text-decoration:
+ none;\">Spree Test Store</a></div></td></tr></tbody></table></td></tr></tbody></table></div><!--[if
+ mso | IE]></td><![endif]--><!--[if mso | IE]></tr></table><![endif]--></td></tr></tbody></table></div><!--[if
+ mso | IE]></td></tr></table><![endif]--><!--[if mso | IE]></td></tr><tr><td
+ width=\"640px\"><![endif]--><!--[if mso | IE]><table border=\"0\"
+ cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" align=\"center\"
+ width=\"592\" style=\"width:592px;\"><tr><td style=\"line-height:0px;font-size:0px;mso-line-height-rule:exactly;\"><![endif]--><div
+ style=\"margin:0px auto;max-width:592px;\"><table border=\"0\" cellpadding=\"0\"
+ cellspacing=\"0\" role=\"presentation\" align=\"center\" style=\"width:100%;\"><tbody><tr><td
+ style=\"direction:ltr;font-size:0px;padding:0;text-align:center;\"><!--[if
+ mso | IE]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
+ role=\"presentation\"><tr><![endif]--><!--[if mso | IE]><td style=\"vertical-align:top;width:592px;\"><![endif]--><div
+ class=\"mj-outlook-group-fix mj-column-per-100\" style=\"font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ width=\"100%\"><tbody><tr><td style=\"vertical-align:top;padding:0;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ width=\"100%\"><tbody><tr><td align=\"center\" style=\"font-size:0px;padding:0;word-break:break-word;\"><div
+ style=\"font-family:Inter, Helvetica, Arial, sans-serif;font-size:14px;line-height:1.6;text-align:center;color:#726A6A;\">Hi
+ Ann</div></td></tr></tbody></table></td></tr></tbody></table></div><!--[if
+ mso | IE]></td><![endif]--><!--[if mso | IE]></tr></table><![endif]--></td></tr></tbody></table></div><!--[if
+ mso | IE]></td></tr></table><![endif]--><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if
+ mso | IE]></td></tr></table><![endif]--><!--[if mso | IE]><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ align=\"center\" width=\"640\" style=\"width:640px;\"><tr><td style=\"line-height:0px;font-size:0px;mso-line-height-rule:exactly;\"><![endif]--><div
+ style=\"margin:0px auto;max-width:640px;\"><table border=\"0\" cellpadding=\"0\"
+ cellspacing=\"0\" role=\"presentation\" align=\"center\" style=\"width:100%;\"><tbody><tr><td
+ style=\"direction:ltr;font-size:0px;padding:64px 24px;text-align:center;\"><!--[if
+ mso | IE]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
+ role=\"presentation\"><tr><![endif]--><!--[if mso | IE]><td style=\"vertical-align:top;width:640px;\"><![endif]--><div
+ class=\"mj-outlook-group-fix mj-column-per-100\" style=\"font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ width=\"100%\"><tbody><tr><td style=\"vertical-align:top;padding:0;\"><table
+ border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\"
+ width=\"100%\"><tbody><tr><td align=\"center\" class=\"footer\"
+ style=\"font-size:0px;padding:0;word-break:break-word;\"><div style=\"font-family:Inter,
+ Helvetica, Arial, sans-serif;font-size:13px;line-height:1.5;text-align:center;color:#726A6A;\"><a
+ href=\"http://www.example.com:3000\" style=\"font-weight: 500; text-decoration:
+ none;\">Spree Test Store</a></div></td></tr><tr><td align=\"center\"
+ class=\"footer\" style=\"font-size:0px;padding:12px 0 0;word-break:break-word;\"><div
+ style=\"font-family:Inter, Helvetica, Arial, sans-serif;font-size:11px;line-height:1.5;text-align:center;color:#726A6A;\"><a
+ href=\"mailto:[email protected]\">[email protected]</a></div></td></tr><tr><td
+ align=\"center\" style=\"font-size:0px;padding:20px 0 0;word-break:break-word;\"><div
+ style=\"font-family:Inter, Helvetica, Arial, sans-serif;font-size:11px;line-height:1.5;text-align:center;color:#726A6A;\">&copy;
+ 2026 Spree Test Store</div></td></tr></tbody></table></td></tr></tbody></table></div><!--[if
+ mso | IE]></td><![endif]--><!--[if mso | IE]></tr></table><![endif]--></td></tr></tbody></table></div><!--[if
+ mso | IE]></td></tr></table><![endif]--></div></body></html>"
text: |
Spree Test Store (http://www.example.com:3000)
@@ -8320,6 +8401,20 @@ paths:
support_email: [email protected]
logo_url:
logo_width:
+ branding:
+ background_color: "#FFFFFF"
+ card_color: "#F6F6F6"
+ text_color: "#726A6A"
+ heading_color: "#332C2C"
+ accent_color:
+ link_color: "#332C2C"
+ button_color: "#FFFFFF"
+ button_text_color: "#1F2222"
+ button_border: '1px solid #E8E9E9'
+ font: inter
+ font_family: Inter, Helvetica, Arial, sans-serif
+ heading_font_family: Geist, Inter, Helvetica, Arial, sans-serif
+ font_url:
locale: en
user:
first_name: Ann
@@ -8351,6 +8446,32 @@ paths:
type: string
example: spree.order_mailer.confirm_email
description: For the layout or a partial, the email to show it in
+ branding:
+ type: object
+ description: Unsaved colors and font to preview, named like the
+ store's `preferred_email_*` settings without the prefix
+ properties:
+ accent_color:
+ type: string
+ example: "#FF5500"
+ background_color:
+ type: string
+ card_color:
+ type: string
+ text_color:
+ type: string
+ heading_color:
+ type: string
+ font:
+ type: string
+ enum:
+ - inter
+ - system
+ - helvetica
+ - georgia
+ - roboto
+ - lato
+ - merriweather
"/api/v3/admin/email_templates/{email_template_id}/test_email":
parameters:
- name: email_template_id
@@ -24044,6 +24165,12 @@ paths:
customer_support_email: [email protected]
new_order_notifications_email: [email protected]
preferred_send_consumer_transactional_emails: true
+ preferred_email_accent_color:
+ preferred_email_background_color:
+ preferred_email_card_color:
+ preferred_email_text_color:
+ preferred_email_heading_color:
+ preferred_email_font:
preferred_admin_locale:
preferred_timezone: UTC
preferred_weight_unit: lb
@@ -24377,6 +24504,12 @@ paths:
customer_support_email: [email protected]
new_order_notifications_email: [email protected]
preferred_send_consumer_transactional_emails: true
+ preferred_email_accent_color:
+ preferred_email_background_color:
+ preferred_email_card_color:
+ preferred_email_text_color:
+ preferred_email_heading_color:
+ preferred_email_font:
preferred_admin_locale:
preferred_timezone: UTC
preferred_weight_unit: lb
@@ -51267,6 +51400,32 @@ components:
nullable: true
preferred_send_consumer_transactional_emails:
type: boolean
+ preferred_email_accent_color:
+ type: string
+ nullable: true
+ preferred_email_background_color:
+ type: string
+ nullable: true
+ preferred_email_card_color:
+ type: string
+ nullable: true
+ preferred_email_text_color:
+ type: string
+ nullable: true
+ preferred_email_heading_color:
+ type: string
+ nullable: true
+ preferred_email_font:
+ type: string
+ nullable: true
+ enum:
+ - inter
+ - system
+ - helvetica
+ - georgia
+ - roboto
+ - lato
+ - merriweather
preferred_admin_locale:
type: string
nullable: true
@@ -51395,6 +51554,12 @@ components:
- customer_support_email
- new_order_notifications_email
- preferred_send_consumer_transactional_emails
+ - preferred_email_accent_color
+ - preferred_email_background_color
+ - preferred_email_card_color
+ - preferred_email_text_color
+ - preferred_email_heading_color
+ - preferred_email_font
- preferred_admin_locale
- preferred_timezone
- preferred_weight_unit
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index 2490ec8067..9715d40b81 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -106,6 +106,18 @@ export interface StoreUpdateParams {
new_order_notifications_email?: string | null
/** When false, transactional consumer emails (order confirmation, etc.) are suppressed. */
preferred_send_consumer_transactional_emails?: boolean
+ /** Customer email buttons and links, as `#RRGGBB`. Blank keeps the outlined buttons emails ship with. */
+ preferred_email_accent_color?: string | null
+ /** Customer email page background, as `#RRGGBB`. */
+ preferred_email_background_color?: string | null
+ /** Customer email card behind the content, as `#RRGGBB`. */
+ preferred_email_card_color?: string | null
+ /** Customer email body text, as `#RRGGBB`. */
+ preferred_email_text_color?: string | null
+ /** Customer email headings and emphasized text, as `#RRGGBB`. */
+ preferred_email_heading_color?: string | null
+ /** Customer email font: `inter`, `system`, `helvetica`, `georgia`, `roboto`, `lato` or `merriweather`. */
+ preferred_email_font?: string | null
/** Active Storage signed_id from a direct upload — the logo embedded in transactional emails. */
mailer_logo?: string | null
/** Where prices come from: a registered provider key, or `internal`. */
@@ -3157,6 +3169,15 @@ export interface EmailTemplatePreviewParams extends EmailTemplateLanguageParams
record_id?: string
/** For the layout or a partial, the email to show it in. */
email_key?: string
+ /** Unsaved colors and font to preview, named like the store's `preferred_email_*` settings without the prefix. */
+ branding?: {
+ accent_color?: string | null
+ background_color?: string | null
+ card_color?: string | null
+ text_color?: string | null
+ heading_color?: string | null
+ font?: string | null
+ }
}
export interface EmailTemplateRestoreParams extends EmailTemplateLanguageParams {
diff --git a/packages/admin-sdk/src/types/generated/Store.ts b/packages/admin-sdk/src/types/generated/Store.ts
index 157df6dd4f..43681f8485 100644
--- a/packages/admin-sdk/src/types/generated/Store.ts
+++ b/packages/admin-sdk/src/types/generated/Store.ts
@@ -1,4 +1,4 @@
-// Typelizer digest f552723a571754fb2dc4b977b2226a9e
+// Typelizer digest b6eb6c8f44397c9f36544bf5737c8bf2
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {SetupTask} from '@/types'
@@ -16,6 +16,12 @@ interface Store {
customer_support_email: string | null;
new_order_notifications_email: string | null;
preferred_send_consumer_transactional_emails: boolean;
+ preferred_email_accent_color: string | null;
+ preferred_email_background_color: string | null;
+ preferred_email_card_color: string | null;
+ preferred_email_text_color: string | null;
+ preferred_email_heading_color: string | null;
+ preferred_email_font: 'inter' | 'system' | 'helvetica' | 'georgia' | 'roboto' | 'lato' | 'merriweather' | null;
preferred_admin_locale: string | null;
preferred_timezone: string;
preferred_weight_unit: 'g' | 'kg' | 'lb' | 'oz';
@@ -41,9 +47,11 @@ interface Store {
preferred_inventory_provider_failure_policy: string;
preferred_payout_provider: string | null;
preferred_default_payouts_schedule_interval: string;
+ preferred_default_minimum_payout_amount: number;
preferred_auto_approve_sellers: boolean;
preferred_auto_approve_seller_products: boolean;
preferred_send_seller_transactional_emails: boolean;
+ preferred_default_commission_tax_rate: number;
preferred_document_number_format: string;
preferred_order_number_prefix: string;
preferred_order_number_suffix: string;
@@ -55,8 +63,6 @@ interface Store {
created_at: string;
updated_at: string;
order_number_sequence_started: boolean;
- preferred_default_minimum_payout_amount: number;
- preferred_default_commission_tax_rate: number;
url: string;
api_url: string;
setup_tasks: Array<SetupTask>;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailStore.ts b/packages/admin-sdk/src/types/generated/emails/EmailStore.ts
index 8ff96eda1c..90f72aeaec 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailStore.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailStore.ts
@@ -1,4 +1,4 @@
-// Typelizer digest e2d71c11c3fe406fb8bcd62062058cb4
+// Typelizer digest ee9a32b07caa10810a43baa2d6493895
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -13,6 +13,7 @@ interface EmailStore {
support_email: string;
logo_url: string | null;
logo_width: number | null;
+ branding: { background_color: string; card_color: string; text_color: string; heading_color: string; accent_color: string | null; link_color: string; button_color: string; button_text_color: string; button_border: string; font: string; font_family: string; heading_font_family: string; font_url: string | null };
}
export default EmailStore;
diff --git a/packages/admin-sdk/src/zod/generated/Store.ts b/packages/admin-sdk/src/zod/generated/Store.ts
index ea17a537fe..1f309bf0a8 100644
--- a/packages/admin-sdk/src/zod/generated/Store.ts
+++ b/packages/admin-sdk/src/zod/generated/Store.ts
@@ -15,6 +15,12 @@ export const StoreSchema = z.object({
customer_support_email: z.string().nullable(),
new_order_notifications_email: z.string().nullable(),
preferred_send_consumer_transactional_emails: z.boolean(),
+ preferred_email_accent_color: z.string().nullable(),
+ preferred_email_background_color: z.string().nullable(),
+ preferred_email_card_color: z.string().nullable(),
+ preferred_email_text_color: z.string().nullable(),
+ preferred_email_heading_color: z.string().nullable(),
+ preferred_email_font: z.string().nullable(),
preferred_admin_locale: z.string().nullable(),
preferred_timezone: z.string(),
preferred_weight_unit: z.string(),
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 1dcbdfb85c..911626f36a 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -4159,7 +4159,7 @@
"customers": "حسابات العملاء والعناوين والبطاقات والمجموعات",
"dashboard": "تحليلات المبيعات والأداء",
"delivery_methods": "خيارات الشحن والأسعار والقواعد التي تتحكم بها",
- "email_templates": "قوالب رسائل العملاء وتخطيط البريد والهوية البصرية",
+ "email_templates": "قوالب رسائل العملاء وتخطيط البريد الإلكتروني",
"fulfillments": "تجهيز الطلبات وشحنها وتتبعها",
"gift_cards": "بطاقات الهدايا ودفعاتها",
"integrations": "بيانات اعتماد مزوّدي الخدمة واتصالاتهم",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index 54a77e592f..d3f2fbe6a3 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -4131,7 +4131,7 @@
"customers": "Kundenkonten, Adressen, Karten und Gruppen",
"dashboard": "Umsatz- und Leistungsanalysen",
"delivery_methods": "Versandoptionen, Tarife und die Regeln, die sie steuern",
- "email_templates": "Kunden-E-Mail-Vorlagen, das E-Mail-Layout und Branding",
+ "email_templates": "Kunden-E-Mail-Vorlagen und das E-Mail-Layout",
"fulfillments": "Bestellungen packen, versenden und verfolgen",
"gift_cards": "Geschenkkarten und Geschenkkarten-Chargen",
"integrations": "Anbieter-Zugangsdaten und Verbindungen",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index fd94c51813..ac51e7a49b 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -4131,7 +4131,7 @@
"customers": "Customer accounts, addresses, cards and groups",
"dashboard": "Sales and performance analytics",
"delivery_methods": "Shipping options, rates and the rules that gate them",
- "email_templates": "Customer email templates, the email layout and branding",
+ "email_templates": "Customer email templates and the email layout",
"fulfillments": "Pack, ship and track order fulfillments",
"gift_cards": "Gift cards and gift card batches",
"integrations": "Provider credentials and connections",
diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.json
index d0f1e17a7e..d3f0ea672a 100644
--- a/packages/dashboard/src/locales/es.json
+++ b/packages/dashboard/src/locales/es.json
@@ -4051,7 +4051,7 @@
"customers": "Cuentas, direcciones, tarjetas y grupos de clientes",
"dashboard": "Análisis de ventas y rendimiento",
"delivery_methods": "Opciones de envío, tarifas y las reglas que las controlan",
- "email_templates": "Plantillas de correo para clientes, el diseño del correo y la marca",
+ "email_templates": "Plantillas de correo para clientes y el diseño del correo",
"fulfillments": "Armar, despachar y rastrear cumplimientos de pedidos",
"gift_cards": "Tarjetas de regalo y lotes de tarjetas",
"integrations": "Credenciales y conexiones de proveedores",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 34cc9381ff..cecf35ecd5 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -4131,7 +4131,7 @@
"customers": "Comptes clients, adresses, cartes et groupes",
"dashboard": "Analyses des ventes et des performances",
"delivery_methods": "Options de livraison, tarifs et règles qui les conditionnent",
- "email_templates": "Modèles d'e-mails clients, mise en page et image de marque des e-mails",
+ "email_templates": "Modèles d'e-mails clients et mise en page des e-mails",
"fulfillments": "Préparer, expédier et suivre les commandes",
"gift_cards": "Cartes cadeaux et lots de cartes cadeaux",
"integrations": "Identifiants et connexions des fournisseurs",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 052bece73a..b569d9ee6e 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -4185,7 +4185,7 @@
"customers": "Konta klientów, adresy, karty i grupy",
"dashboard": "Analizy sprzedaży i wyników",
"delivery_methods": "Opcje wysyłki, stawki i reguły, które nimi sterują",
- "email_templates": "Szablony e-maili do klientów, układ e-maili i wygląd marki",
+ "email_templates": "Szablony e-maili do klientów i układ e-maili",
"fulfillments": "Pakowanie, wysyłka i śledzenie realizacji",
"gift_cards": "Karty podarunkowe i ich partie",
"integrations": "Dane dostępowe i połączenia dostawców",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index 6c355b88cc..cd46e83a25 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -4121,7 +4121,7 @@
"customers": "客户账户、地址、卡片与分组",
"dashboard": "销售与业绩分析",
"delivery_methods": "配送选项、费率及其适用规则",
- "email_templates": "客户邮件模板、邮件布局和品牌样式",
+ "email_templates": "客户邮件模板和邮件布局",
"fulfillments": "打包、发货并跟踪订单履约",
"gift_cards": "礼品卡及其批次",
"integrations": "服务商凭据与连接",
diff --git a/spree/api/app/controllers/concerns/spree/api/v3/admin/email_template_lookup.rb b/spree/api/app/controllers/concerns/spree/api/v3/admin/email_template_lookup.rb
index ea7854c31f..d834581a45 100644
--- a/spree/api/app/controllers/concerns/spree/api/v3/admin/email_template_lookup.rb
+++ b/spree/api/app/controllers/concerns/spree/api/v3/admin/email_template_lookup.rb
@@ -42,11 +42,13 @@ module Spree
end
# An unsaved subject and body are previewed only when sent, so an
- # empty body still previews as empty.
+ # empty body still previews as empty. `branding` previews unsaved
+ # colors and font.
def preview_arguments
arguments = params.permit(:record_id, :subject, :body).to_h.symbolize_keys
arguments[:locale] = language
arguments[:email_key] = params[:email_key].to_s.tr('.', '/').presence
+ arguments[:branding] = params.fetch(:branding, {}).permit(*Spree::Emails::Branding.attribute_names).to_h
arguments
end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/store_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/store_controller.rb
index c1af46bed4..23eb63602a 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/store_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/store_controller.rb
@@ -117,6 +117,12 @@ module Spree
:customer_support_email,
:new_order_notifications_email,
:preferred_send_consumer_transactional_emails,
+ :preferred_email_accent_color,
+ :preferred_email_background_color,
+ :preferred_email_card_color,
+ :preferred_email_text_color,
+ :preferred_email_heading_color,
+ :preferred_email_font,
:mailer_logo
)
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb
index 67246c1d53..ffff76e7e5 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb
@@ -16,6 +16,12 @@ module Spree
customer_support_email: [:string, nullable: true],
new_order_notifications_email: [:string, nullable: true],
preferred_send_consumer_transactional_emails: :boolean,
+ preferred_email_accent_color: [:string, nullable: true],
+ preferred_email_background_color: [:string, nullable: true],
+ preferred_email_card_color: [:string, nullable: true],
+ preferred_email_text_color: [:string, nullable: true],
+ preferred_email_heading_color: [:string, nullable: true],
+ preferred_email_font: [:string, nullable: true, enum: Spree::Emails::Branding::FONTS.keys],
preferred_admin_locale: [:string, nullable: true],
preferred_timezone: :string,
preferred_weight_unit: [:string, enum: Spree::Variant::WEIGHT_UNITS],
@@ -68,6 +74,12 @@ module Spree
:customer_support_email,
:new_order_notifications_email,
:preferred_send_consumer_transactional_emails,
+ :preferred_email_accent_color,
+ :preferred_email_background_color,
+ :preferred_email_card_color,
+ :preferred_email_text_color,
+ :preferred_email_heading_color,
+ :preferred_email_font,
:preferred_admin_locale,
:preferred_timezone,
:preferred_weight_unit,
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/email_templates/previews_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/email_templates/previews_controller_spec.rb
index bd71cdcf60..5091214bb5 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/email_templates/previews_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/email_templates/previews_controller_spec.rb
@@ -23,6 +23,14 @@ RSpec.describe Spree::Api::V3::Admin::EmailTemplates::PreviewsController, type:
expect(json_response['variables']['user']).to include('first_name' => 'Ann')
end
+ it 'previews unsaved branding without saving it' do
+ post :create, params: { email_template_id: id, branding: { card_color: '#123456', font: 'georgia' } }, as: :json
+
+ expect(json_response['html']).to include('#123456', 'Georgia')
+ expect(json_response['variables']['store']['branding']).to include('card_color' => '#123456')
+ expect(store.reload.preferred_email_card_color).to be_nil
+ end
+
it 'says what is wrong and where when the template does not render' do
post :create, params: { email_template_id: id, body: "<mj-section>\n{% if %}</mj-section>" }, as: :json
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/store_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/store_controller_spec.rb
index 0f7923b380..ee4a6443fd 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/store_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/store_controller_spec.rb
@@ -300,6 +300,26 @@ RSpec.describe Spree::Api::V3::Admin::StoreController, type: :controller do
end
end
+ context 'with email branding params' do
+ let(:params) { { preferred_email_accent_color: '#FF5500', preferred_email_font: 'georgia' } }
+
+ it 'saves the colors and font customer emails use' do
+ subject
+ expect(response).to have_http_status(:ok)
+ expect(json_response).to include('preferred_email_accent_color' => '#FF5500', 'preferred_email_font' => 'georgia')
+ end
+
+ context 'with a value that is not a color' do
+ let(:params) { { preferred_email_accent_color: 'red' } }
+
+ it 'refuses it' do
+ subject
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(json_response['error']['details']).to have_key('preferred_email_accent_color')
+ end
+ end
+ end
+
context 'with an invalid mail_from_address' do
let(:params) { { mail_from_address: 'not-an-email' } }
diff --git a/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb
index ce0a3db326..4751c5dff9 100644
--- a/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb
+++ b/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb
@@ -265,7 +265,8 @@ RSpec.describe 'Admin Email Templates API', type: :request, swagger_doc: 'api-re
matching record, or the one `record_id` names, and returns the email
with the variables it was rendered with. An unsaved `subject` and
`body` take the place of the current version. The layout and partials
- render inside an email, `email_key` or the first one.
+ render inside an email, `email_key` or the first one. `branding`
+ previews colors and a font before they are saved to the store.
DESC
admin_scope :write, :email_templates
@@ -279,7 +280,19 @@ RSpec.describe 'Admin Email Templates API', type: :request, swagger_doc: 'api-re
subject: { type: :string, example: 'Reset your {{ store.name }} password' },
body: { type: :string, example: '<mj-section><mj-column><mj-text>Hi {{ user.first_name }}</mj-text></mj-column></mj-section>' },
record_id: { type: :string, example: 'or_m3Rp9wXz', description: 'The record to build sample data from' },
- email_key: { type: :string, example: 'spree.order_mailer.confirm_email', description: 'For the layout or a partial, the email to show it in' }
+ email_key: { type: :string, example: 'spree.order_mailer.confirm_email', description: 'For the layout or a partial, the email to show it in' },
+ branding: {
+ type: :object,
+ description: "Unsaved colors and font to preview, named like the store's `preferred_email_*` settings without the prefix",
+ properties: {
+ accent_color: { type: :string, example: '#FF5500' },
+ background_color: { type: :string },
+ card_color: { type: :string },
+ text_color: { type: :string },
+ heading_color: { type: :string },
+ font: { type: :string, enum: Spree::Emails::Branding::FONTS.keys }
+ }
+ }
}
}
diff --git a/spree/core/app/models/concerns/spree/stores/email_branding.rb b/spree/core/app/models/concerns/spree/stores/email_branding.rb
new file mode 100644
index 0000000000..2e2a9d3376
--- /dev/null
+++ b/spree/core/app/models/concerns/spree/stores/email_branding.rb
@@ -0,0 +1,31 @@
+module Spree
+ module Stores
+ # The colors and font of a store's customer emails (see Spree::Emails::Branding).
+ # All optional: a blank one keeps the shipped design.
+ module EmailBranding
+ extend ActiveSupport::Concern
+
+ included do
+ Spree::Emails::Branding.attribute_names.each { |name| preference :"email_#{name}", :string }
+
+ validate :email_branding_valid
+ end
+
+ # @param overrides [Hash] unsaved values, e.g. to preview them
+ # @return [Spree::Emails::Branding]
+ def email_branding(overrides = {})
+ saved = Spree::Emails::Branding.attribute_names.to_h { |name| [name, public_send(:"preferred_email_#{name}")] }
+ Spree::Emails::Branding.new(saved.merge(overrides.to_h.stringify_keys.slice(*saved.keys)))
+ end
+
+ private
+
+ def email_branding_valid
+ branding = email_branding
+ return if branding.valid?
+
+ branding.errors.each { |error| errors.add(:"preferred_email_#{error.attribute}", error.type) }
+ end
+ end
+ end
+end
diff --git a/spree/core/app/models/spree/emails/branding.rb b/spree/core/app/models/spree/emails/branding.rb
new file mode 100644
index 0000000000..870fc1de3c
--- /dev/null
+++ b/spree/core/app/models/spree/emails/branding.rb
@@ -0,0 +1,80 @@
+module Spree
+ module Emails
+ # How a store's customer emails look: its colors and font over the
+ # defaults the shipped layout was designed with. Templates read it as
+ # `store.branding`, so it outlives any edit or revert of a template.
+ class Branding
+ include ActiveModel::Model
+ include ActiveModel::Attributes
+
+ COLOR_FORMAT = /\A#\h{6}\z/
+
+ # Email-safe fonts, with fallback stacks for clients that do not load
+ # web fonts. Family names stay unquoted: templates escape what they print.
+ FONTS = {
+ 'inter' => { family: 'Inter, Helvetica, Arial, sans-serif', heading_family: 'Geist, Inter, Helvetica, Arial, sans-serif' },
+ 'system' => { family: '-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif' },
+ 'helvetica' => { family: 'Helvetica, Arial, sans-serif' },
+ 'georgia' => { family: 'Georgia, Times New Roman, Times, serif' },
+ 'roboto' => { family: 'Roboto, Helvetica, Arial, sans-serif', url: 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700' },
+ 'lato' => { family: 'Lato, Helvetica, Arial, sans-serif', url: 'https://fonts.googleapis.com/css2?family=Lato:wght@400;700' },
+ 'merriweather' => { family: 'Merriweather, Georgia, serif', url: 'https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700' }
+ }.freeze
+
+ DEFAULT_FONT = 'inter'.freeze
+ DEFAULT_COLORS = {
+ background_color: '#FFFFFF', card_color: '#F6F6F6', text_color: '#726A6A', heading_color: '#332C2C'
+ }.freeze
+ COLORS = %i[accent_color background_color card_color text_color heading_color].freeze
+
+ COLORS.each { |color| attribute color, :string }
+ attribute :font, :string
+
+ validates(*COLORS, format: { with: COLOR_FORMAT }, allow_blank: true)
+ validates :font, inclusion: { in: FONTS.keys }, allow_blank: true
+
+ # What templates read as `store.branding`. A value that is not a color
+ # or a known font falls back to the default, so nothing else ever reaches
+ # an email's CSS, unsaved preview values included.
+ #
+ # @return [Hash{String => String, nil}]
+ def to_h
+ accent = color(:accent_color)
+ typeface_key = FONTS.key?(font) ? font : DEFAULT_FONT
+ typeface = FONTS[typeface_key]
+ colors = DEFAULT_COLORS.to_h { |name, default| [name, color(name) || default] }
+
+ {
+ **colors,
+ accent_color: accent,
+ link_color: accent || colors[:heading_color],
+ # Without an accent, buttons keep the outlined look the layout ships with.
+ button_color: accent || '#FFFFFF',
+ button_text_color: accent ? readable_text_on(accent) : '#1F2222',
+ button_border: accent ? 'none' : '1px solid #E8E9E9',
+ font: typeface_key,
+ font_family: typeface[:family],
+ heading_font_family: typeface[:heading_family] || typeface[:family],
+ font_url: typeface[:url]
+ }.stringify_keys
+ end
+
+ private
+
+ def color(name)
+ value = public_send(name).to_s
+ value.upcase if value.match?(COLOR_FORMAT)
+ end
+
+ # Black or white, whichever reads better on the color (WCAG relative luminance).
+ def readable_text_on(hex)
+ red, green, blue = hex.delete('#').scan(/../).map do |channel|
+ value = channel.to_i(16) / 255.0
+ value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055)**2.4
+ end
+ luminance = (0.2126 * red) + (0.7152 * green) + (0.0722 * blue)
+ luminance > 0.179 ? '#000000' : '#FFFFFF'
+ end
+ end
+ end
+end
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index ecd8ac37f5..25091ee8c2 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -13,6 +13,7 @@ module Spree
include Spree::Stores::Setup
include Spree::Stores::Markets
include Spree::Stores::Channels
+ include Spree::Stores::EmailBranding
include Spree::StoreDataSources
include Spree::Security::Stores if defined?(Spree::Security::Stores)
include Spree::UserManagement
diff --git a/spree/core/app/serializers/spree/emails/store_serializer.rb b/spree/core/app/serializers/spree/emails/store_serializer.rb
index 46a5f39a1b..d10c1df25d 100644
--- a/spree/core/app/serializers/spree/emails/store_serializer.rb
+++ b/spree/core/app/serializers/spree/emails/store_serializer.rb
@@ -21,6 +21,11 @@ module Spree
width, height = store.email_logo&.metadata.to_h.values_at('width', 'height').map(&:to_f)
(LOGO_HEIGHT * width / height).round if height.to_f.positive?
end
+
+ # Colors and font (see Spree::Emails::Branding).
+ attribute :branding do |store|
+ store.email_branding(params[:branding] || {}).to_h
+ end
end
end
end
diff --git a/spree/core/app/services/spree/email_templates/preview.rb b/spree/core/app/services/spree/email_templates/preview.rb
index a90e246c1e..841c22c891 100644
--- a/spree/core/app/services/spree/email_templates/preview.rb
+++ b/spree/core/app/services/spree/email_templates/preview.rb
@@ -22,8 +22,9 @@ module Spree
# @param record_id [String, nil] the prefixed id of the record to build sample data from
# @param email_key [String, nil] for the layout or a partial, the email to show it in
# @param strict [Boolean] whether an unknown variable raises
+ # @param branding [Hash] unsaved branding values (see Spree::Emails::Branding)
def initialize(store:, key:, locale: Spree::EmailTemplate::ANY_LOCALE, subject: nil, body: nil,
- record_id: nil, email_key: nil, strict: false)
+ record_id: nil, email_key: nil, strict: false, branding: {})
@store = store
@key = key
@locale = locale.presence || Spree::EmailTemplate::ANY_LOCALE
@@ -32,6 +33,7 @@ module Spree
@record_id = record_id
@email_key = email_key
@strict = strict
+ @branding = branding
end
# @return [Spree::Emails::RenderedEmail]
@@ -40,7 +42,8 @@ module Spree
sample = email.sample_class.new(store: @store, record_id: @record_id)
in_locale do
- renderer = Spree::Emails::Renderer.new(resolver: resolver, store: @store, currency: sample.currency, strict: @strict)
+ renderer = Spree::Emails::Renderer.new(resolver: resolver, store: @store, currency: sample.currency, strict: @strict,
+ branding: @branding)
sample_variables = sample.variables
@variables = renderer.variables(sample_variables)
@rendered = renderer.render(resolver.find(email.key), sample_variables)
diff --git a/spree/core/app/services/spree/emails/renderer.rb b/spree/core/app/services/spree/emails/renderer.rb
index 504216b1d9..2d2a37d9e0 100644
--- a/spree/core/app/services/spree/emails/renderer.rb
+++ b/spree/core/app/services/spree/emails/renderer.rb
@@ -34,9 +34,11 @@ module Spree
# @param currency [String, nil] what `money` formats in, defaults to the store's
# @param strict [Boolean] whether an unknown variable raises; defaults to
# true in development and test, false in production
- def initialize(resolver:, store:, currency: nil, strict: Rails.env.local?)
+ # @param branding [Hash] unsaved branding values over the store's, for previews
+ def initialize(resolver:, store:, currency: nil, strict: Rails.env.local?, branding: {})
@resolver = resolver
@store = store
+ @branding = branding
@currency = currency.presence || store.default_currency
@strict = strict
end
@@ -112,7 +114,7 @@ module Spree
def base_assigns
@base_assigns ||= {
- 'store' => JSON.parse(Spree::Emails::StoreSerializer.new(@store).serialize),
+ 'store' => JSON.parse(Spree::Emails::StoreSerializer.new(@store, params: { branding: @branding }).serialize),
'locale' => I18n.locale.to_s
}
end
diff --git a/spree/core/app/views/layouts/spree/base_mailer.liquid b/spree/core/app/views/layouts/spree/base_mailer.liquid
index 869e32b053..23736ec976 100644
--- a/spree/core/app/views/layouts/spree/base_mailer.liquid
+++ b/spree/core/app/views/layouts/spree/base_mailer.liquid
@@ -1,56 +1,59 @@
-<mjml lang="{{ locale }}">
+{% assign brand = store.branding %}<mjml lang="{{ locale }}">
<mj-head>
<mj-title>{{ subject }}</mj-title>
+ {% if brand.font_url %}<mj-font name="{{ brand.font_family | split: ',' | first }}" href="{{ brand.font_url }}" />{% endif %}
<mj-attributes>
- <mj-all font-family="Inter, Helvetica, Arial, sans-serif" />
+ <mj-all font-family="{{ brand.font_family }}" />
<mj-section padding="0" />
<mj-column padding="0" />
- <mj-text padding="0" color="#726A6A" font-size="14px" line-height="1.6" align="center" />
- <mj-button background-color="#FFFFFF" border="1px solid #E8E9E9" border-radius="8px" color="#1F2222" font-size="15px" font-weight="500" line-height="1.6" inner-padding="12px 20px" padding="32px 0 0" />
- <mj-table padding="0" color="#726A6A" font-size="14px" line-height="1.6" />
- <mj-class name="heading" font-family="Geist, Inter, Helvetica, Arial, sans-serif" font-size="40px" font-weight="700" line-height="1.2" letter-spacing="-0.8px" color="#332C2C" css-class="heading" />
- <mj-class name="greeting" padding="24px 0 0" font-size="15px" font-weight="500" color="#332C2C" />
+ <mj-text padding="0" color="{{ brand.text_color }}" font-size="14px" line-height="1.6" align="center" />
+ <mj-button background-color="{{ brand.button_color }}" border="{{ brand.button_border }}" border-radius="8px" color="{{ brand.button_text_color }}" font-size="15px" font-weight="500" line-height="1.6" inner-padding="12px 20px" padding="32px 0 0" />
+ <mj-table padding="0" color="{{ brand.text_color }}" font-size="14px" line-height="1.6" />
+ <mj-class name="heading" font-family="{{ brand.heading_font_family }}" font-size="40px" font-weight="700" line-height="1.2" letter-spacing="-0.8px" color="{{ brand.heading_color }}" css-class="heading" />
+ <mj-class name="greeting" padding="24px 0 0" font-size="15px" font-weight="500" color="{{ brand.heading_color }}" />
<mj-class name="lead" padding="12px 0 0" />
<mj-class name="note" padding="24px 0 0" font-size="13px" css-class="note" />
- <mj-class name="section-heading" padding="48px 0 16px" font-family="Geist, Inter, Helvetica, Arial, sans-serif" font-size="16px" font-weight="500" letter-spacing="-0.16px" align="left" />
+ <mj-class name="section-heading" padding="48px 0 16px" font-family="{{ brand.heading_font_family }}" font-size="16px" font-weight="500" letter-spacing="-0.16px" align="left" />
<mj-class name="body" padding="16px 0 0" align="left" />
<mj-class name="footer" padding="12px 0 0" font-size="11px" line-height="1.5" />
</mj-attributes>
<mj-style>
+ {% if brand.font == 'inter' %}
@font-face { font-family: "Geist"; font-style: normal; font-weight: 500 700; src: url("https://fonts.gstatic.com/s/geist/v4/gyByhwUxId8gMEwcGFU.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 450; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuOKfMZg.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; src: url("https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf") format("truetype"); }
- a { color: #332C2C; }
+ {% endif %}
+ a { color: {{ brand.link_color }}; }
.hero > table { max-width: 420px; margin: 0 auto; }
- .note a { color: #726A6A; word-break: break-all; }
- .footer a { color: #726A6A; }
+ .note a { color: {{ brand.text_color }}; word-break: break-all; }
+ .footer a { color: {{ brand.text_color }}; }
.item { width: 100%; background-color: #F0F0F0; border-radius: 16px; margin: 0 0 8px; }
.item_image { padding: 8px; width: 96px; }
.item_thumb { display: block; width: 80px; height: auto; border-radius: 12px; }
.item_thumb_placeholder { width: 80px; height: 80px; background-color: #E4E4E4; border-radius: 12px; }
.item_info { padding: 8px 16px 8px 8px; }
- .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; text-decoration: none; }
- .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
+ .item_name { font-size: 15px; line-height: 1.5; font-weight: 500; color: {{ brand.heading_color }}; text-decoration: none; }
+ .item_meta { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: {{ brand.text_color }}; }
.item_amount { padding: 8px 16px 8px 8px; text-align: right; white-space: nowrap; }
- .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: #726A6A; }
- .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: #332C2C; }
- .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: #726A6A; }
- .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: #332C2C; }
+ .item_qty { margin: 0; font-size: 13px; line-height: 1.5; color: {{ brand.text_color }}; }
+ .item_price { margin: 2px 0 0; font-size: 15px; line-height: 1.5; font-weight: 500; color: {{ brand.heading_color }}; }
+ .summary td { padding: 6px 0; font-size: 14px; line-height: 1.6; color: {{ brand.text_color }}; }
+ .summary_value { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; color: {{ brand.heading_color }}; }
.summary_sub { display: block; font-size: 13px; line-height: 1.5; }
- .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: #332C2C; }
+ .summary_total td { padding: 14px 0 0; border-top: 1px solid #E8E9E9; font-weight: 500; color: {{ brand.heading_color }}; }
.summary_total .summary_value { font-weight: 600; }
- .mailer_hero h1 { margin: 0; font-family: Geist, Inter, Helvetica, Arial, sans-serif; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: #332C2C; }
+ .mailer_hero h1 { margin: 0; font-family: {{ brand.heading_font_family }}; font-size: 40px; line-height: 1.2; letter-spacing: -0.8px; font-weight: 700; color: {{ brand.heading_color }}; }
.mailer_hero p { margin: 12px 0 0; }
- .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: #332C2C; }
+ .mailer_hero .greeting { margin-top: 24px; font-size: 15px; font-weight: 500; color: {{ brand.heading_color }}; }
.mailer_hero .sub { margin-top: 24px; font-size: 13px; }
@media only screen and (max-width: 600px) {
.heading div { font-size: 32px !important; letter-spacing: -0.64px !important; }
}
</mj-style>
</mj-head>
- <mj-body background-color="#FFFFFF" width="640px">
- <mj-wrapper background-color="#F6F6F6" padding="56px 24px">
+ <mj-body background-color="{{ brand.background_color }}" width="640px">
+ <mj-wrapper background-color="{{ brand.card_color }}" padding="56px 24px">
<mj-section padding="0 0 32px">
<mj-column>
{% if store.logo_url and store.logo_width %}
@@ -58,7 +61,7 @@
{% elsif store.logo_url %}
<mj-text><a href="{{ store.url }}"><img src="{{ store.logo_url }}" alt="{{ store.name }}" height="32" style="height: 32px; width: auto; border: 0;" /></a></mj-text>
{% else %}
- <mj-text font-size="22px" font-weight="700" color="#332C2C" text-transform="uppercase"><a href="{{ store.url }}" style="color: #332C2C; text-decoration: none;">{{ store.name }}</a></mj-text>
+ <mj-text font-size="22px" font-weight="700" color="{{ brand.heading_color }}" text-transform="uppercase"><a href="{{ store.url }}" style="color: {{ brand.heading_color }}; text-decoration: none;">{{ store.name }}</a></mj-text>
{% endif %}
</mj-column>
</mj-section>
diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.yml
index 02863991f1..617e998f6d 100644
--- a/spree/core/config/locales/en.yml
+++ b/spree/core/config/locales/en.yml
@@ -1298,7 +1298,7 @@ en:
description: Sales and performance analytics
label: Analytics dashboard
email_templates:
- description: Customer email templates, the email layout and branding
+ description: Customer email templates and the email layout
label: Email templates
fulfillments:
description: Pack, ship and track order fulfillments
diff --git a/spree/core/spec/models/spree/emails/branding_spec.rb b/spree/core/spec/models/spree/emails/branding_spec.rb
new file mode 100644
index 0000000000..e9189d734e
--- /dev/null
+++ b/spree/core/spec/models/spree/emails/branding_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe Spree::Emails::Branding do
+ it 'keeps the shipped design when nothing is set' do
+ expect(described_class.new.to_h).to include(
+ 'background_color' => '#FFFFFF', 'card_color' => '#F6F6F6', 'accent_color' => nil,
+ 'button_color' => '#FFFFFF', 'button_border' => '1px solid #E8E9E9', 'font' => 'inter',
+ 'heading_font_family' => 'Geist, Inter, Helvetica, Arial, sans-serif', 'font_url' => nil
+ )
+ end
+
+ it 'gives buttons the accent with whichever of black or white reads on it' do
+ expect(described_class.new(accent_color: '#ffee00').to_h).to include('button_color' => '#FFEE00', 'button_text_color' => '#000000', 'link_color' => '#FFEE00')
+ expect(described_class.new(accent_color: '#1a237e').to_h).to include('button_text_color' => '#FFFFFF')
+ end
+
+ it 'loads a web font with its fallback stack' do
+ expect(described_class.new(font: 'roboto').to_h).to include('font_family' => 'Roboto, Helvetica, Arial, sans-serif', 'font_url' => a_string_including('Roboto'))
+ end
+
+ it 'never lets anything but a color or a known font through to the CSS' do
+ branding = described_class.new(accent_color: 'red;}</style><script>', text_color: 'blue', font: 'comic')
+
+ expect(branding).not_to be_valid
+ expect(branding.to_h).to include('accent_color' => nil, 'text_color' => '#726A6A', 'font' => 'inter')
+ end
+
+ describe 'on a store' do
+ let(:store) { build(:store) }
+
+ it 'refuses a branding setting that is not a color or a known font' do
+ store.preferred_email_card_color = '#12345'
+ store.preferred_email_font = 'comic'
+
+ expect(store).not_to be_valid
+ expect(store.errors[:preferred_email_card_color]).to be_present
+ expect(store.errors[:preferred_email_font]).to be_present
+ end
+
+ it 'previews unsaved values over the saved ones' do
+ store.preferred_email_text_color = '#111111'
+
+ expect(store.email_branding(card_color: '#222222').to_h).to include('text_color' => '#111111', 'card_color' => '#222222')
+ end
+ end
+end
diff --git a/spree/emails/app/views/spree/return_mailer/refunded_email.liquid b/spree/emails/app/views/spree/return_mailer/refunded_email.liquid
index 04912d0eec..7e08f657e0 100644
--- a/spree/emails/app/views/spree/return_mailer/refunded_email.liquid
+++ b/spree/emails/app/views/spree/return_mailer/refunded_email.liquid
@@ -12,7 +12,7 @@ subject: "{% if resend %}[{{ 'resend' | t | upcase }}] {% endif %}{{ store.name
<mj-section padding="48px 0 0">
<mj-column>
<mj-text mj-class="section-heading" padding="0 0 16px">{{ 'return_mailer.refunded_email.refund_summary' | t }}</mj-text>
- <mj-text mj-class="body" padding="0" font-weight="500" color="#332C2C">{{ 'return_mailer.refunded_email.total_refunded' | t: total: return.display_refunded_total }}</mj-text>
+ <mj-text mj-class="body" padding="0" font-weight="500" color="{{ store.branding.heading_color }}">{{ 'return_mailer.refunded_email.total_refunded' | t: total: return.display_refunded_total }}</mj-text>
</mj-column>
</mj-section>
{% render 'spree/shared/order_summary', heading: heading, purchase: order, items: return.returned_items, totals: false %}
diff --git a/spree/emails/config/initializers/typelizer.rb b/spree/emails/config/initializers/typelizer.rb
index 4a688ae174..e7b0ab370e 100644
--- a/spree/emails/config/initializers/typelizer.rb
+++ b/spree/emails/config/initializers/typelizer.rb
@@ -22,7 +22,10 @@ Rails.application.config.after_initialize do
Spree::Emails::StoreSerializer.typelize(
id: :string, name: :string, address: [:string, nullable: true], mail_from_address: :string, default_currency: :string,
default_locale: :string, url: :string, support_email: :string, logo_url: [:string, nullable: true],
- logo_width: [:number, nullable: true]
+ logo_width: [:number, nullable: true],
+ branding: '{ background_color: string; card_color: string; text_color: string; heading_color: string; ' \
+ 'accent_color: string | null; link_color: string; button_color: string; button_text_color: string; ' \
+ 'button_border: string; font: string; font_family: string; heading_font_family: string; font_url: string | null }'
)
# Staff emails are not editable, so their data has no type.