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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
fixes
Damian Legawieca6c760af9968
diff --git a/spree/core/app/views/spree/shared/_base_mailer_stylesheets.html.erb b/spree/core/app/views/spree/shared/_base_mailer_stylesheets.html.erbindex 4760b47dfd..601627689c 100644--- a/spree/core/app/views/spree/shared/_base_mailer_stylesheets.html.erb+++ b/spree/core/app/views/spree/shared/_base_mailer_stylesheets.html.erb@@ -119,7 +119,7 @@h3 {margin: 0 0 16px;font-family: "Geist", "Inter", Helvetica, Arial, sans-serif;- color: #A2A9AA;+ color: #726A6A;font-size: 16px;line-height: 1.5;letter-spacing: -0.16px;@@ -146,7 +146,7 @@p.sub {font-size: 13px;- color: #A2A9AA;+ color: #726A6A;}p.sub a {@@ -337,7 +337,7 @@font-size: 11px;line-height: 1.5;letter-spacing: -0.11px;- color: #A2A9AA;+ color: #726A6A;}.body-action {@@ -370,7 +370,7 @@.purchase_item--additional {font-size: 13px;- color: #A2A9AA;+ color: #726A6A;}.purchase_total {diff --git a/spree/core/app/views/spree/shared/_purchased_items_styles.html.erb b/spree/core/app/views/spree/shared/_purchased_items_styles.html.erbindex 1559963308..e552c0ba33 100644--- a/spree/core/app/views/spree/shared/_purchased_items_styles.html.erb+++ b/spree/core/app/views/spree/shared/_purchased_items_styles.html.erb@@ -41,7 +41,7 @@margin: 2px 0 0;font-size: 13px;line-height: 1.5;- color: #A2A9AA;+ color: #726A6A;}.item .item_amount {@@ -54,7 +54,7 @@margin: 0;font-size: 13px;line-height: 1.5;- color: #A2A9AA;+ color: #726A6A;}.item .item_price {@@ -91,7 +91,7 @@display: block;font-size: 13px;line-height: 1.5;- color: #A2A9AA;+ color: #726A6A;}.summary .summary_strong {diff --git a/spree/core/app/views/spree/webhook_mailer/endpoint_disabled.html.erb b/spree/core/app/views/spree/webhook_mailer/endpoint_disabled.html.erbindex 2ef7fefc3a..24de657d3f 100644--- a/spree/core/app/views/spree/webhook_mailer/endpoint_disabled.html.erb+++ b/spree/core/app/views/spree/webhook_mailer/endpoint_disabled.html.erb@@ -47,3 +47,11 @@</td></tr></table>++<table class="section" width="100%" cellpadding="0" cellspacing="0" role="presentation">+ <tr>+ <td>+ <p class="f-fallback"><%= Spree.t('webhook_mailer.endpoint_disabled.instructions') %></p>+ </td>+ </tr>+</table>diff --git a/spree/core/lib/spree/core/previews/export_preview.rb b/spree/core/lib/spree/core/previews/export_preview.rbindex 07b42e5574..95c22f9651 100644--- a/spree/core/lib/spree/core/previews/export_preview.rb+++ b/spree/core/lib/spree/core/previews/export_preview.rb@@ -1,3 +1,5 @@+require_relative 'preview_data'+# Preview Spree export emails at /rails/mailers/spree/exportclass Spree::ExportPreview < ActionMailer::Previewdef export_done@@ -6,16 +8,18 @@ class Spree::ExportPreview < ActionMailer::Previewprivate- # Reuse the most recent export, or build a renderable one on the fly so the- # preview works on a database that has never run an export.+ # Reuse the most recent export, or build an in-memory example so the preview+ # works on a database that has never run an export. The record is never saved,+ # so no `export.created` side effects (attachment upload, generate job) fire.def export- Spree::Export.last || create_example_export+ Spree::Export.last || example_exportend- def create_example_export- export = Spree::Exports::Products.create!(+ def example_export+ export = Spree::Exports::Products.new(+ id: 0,store: Spree::Store.default,- user: Spree.admin_user_class.first,+ user: Spree::PreviewData.admin_user,format: :csv)export.attachment.attach(diff --git a/spree/core/lib/spree/core/previews/invitation_preview.rb b/spree/core/lib/spree/core/previews/invitation_preview.rbindex b60435cb43..623ccb3c90 100644--- a/spree/core/lib/spree/core/previews/invitation_preview.rb+++ b/spree/core/lib/spree/core/previews/invitation_preview.rb@@ -1,10 +1,32 @@+require_relative 'preview_data'+# Preview Spree invitation emails at /rails/mailers/spree/invitationclass Spree::InvitationPreview < ActionMailer::Previewdef invitation_email- Spree::InvitationMailer.invitation_email(Spree::Invitation.pending.last || Spree::Invitation.last)+ Spree::InvitationMailer.invitation_email(Spree::Invitation.pending.last || example_invitation)enddef invitation_accepted- Spree::InvitationMailer.invitation_accepted(Spree::Invitation.accepted.last || Spree::Invitation.last)+ Spree::InvitationMailer.invitation_accepted(Spree::Invitation.accepted.last || example_invitation(accepted: true))+ end++ private++ # Build an in-memory invitation so the preview works on a database with no+ # invitations. Never saved, so no records are created.+ def example_invitation(accepted: false)+ store = Spree::Store.default+ admin = Spree::PreviewData.admin_user+ Spree::Invitation.new(+ id: 0,+ email: '[email protected]',+ resource: store,+ inviter: admin,+ invitee: accepted ? admin : nil,+ role: Spree::Role.first || Spree::Role.new(name: 'admin'),+ token: 'preview-token',+ status: accepted ? 'accepted' : 'pending',+ expires_at: 7.days.from_now+ )endenddiff --git a/spree/core/lib/spree/core/previews/preview_data.rb b/spree/core/lib/spree/core/previews/preview_data.rbnew file mode 100644index 0000000000..2e5fc6dea1--- /dev/null+++ b/spree/core/lib/spree/core/previews/preview_data.rb@@ -0,0 +1,14 @@+# Shared fallbacks for ActionMailer previews. Everything returned here is+# in-memory (never saved) so opening a mailer preview stays read-only.+module Spree+ module PreviewData+ module_function++ # An admin user for previews that need `user.email` / `user.first_name`.+ # Falls back to an unsaved instance when the database has no admin users.+ def admin_user+ Spree.admin_user_class.first ||+ Spree.admin_user_class.new(email: '[email protected]', first_name: 'Alex', last_name: 'Doe')+ end+ end+enddiff --git a/spree/core/lib/spree/core/previews/report_preview.rb b/spree/core/lib/spree/core/previews/report_preview.rbindex db8edf9ece..cf704ae90f 100644--- a/spree/core/lib/spree/core/previews/report_preview.rb+++ b/spree/core/lib/spree/core/previews/report_preview.rb@@ -1,3 +1,5 @@+require_relative 'preview_data'+# Preview Spree report emails at /rails/mailers/spree/reportclass Spree::ReportPreview < ActionMailer::Previewdef report_done@@ -6,17 +8,19 @@ class Spree::ReportPreview < ActionMailer::Previewprivate- # Reuse the most recent report, or build a renderable one on the fly so the- # preview works on a database that has never run a report.+ # Reuse the most recent report, or build an in-memory example so the preview+ # works on a database that has never run a report. The record is never saved,+ # so no `report.created` side effects (attachment upload, generate job) fire.def report- Spree::Report.last || create_example_report+ Spree::Report.last || example_reportend- def create_example_report+ def example_reportstore = Spree::Store.default- report = Spree::Reports::SalesTotal.create!(+ report = Spree::Reports::SalesTotal.new(+ id: 0,store: store,- user: Spree.admin_user_class.first,+ user: Spree::PreviewData.admin_user,date_from: 30.days.ago.to_date,date_to: Date.current,currency: store.default_currencydiff --git a/spree/core/lib/spree/core/previews/webhook_preview.rb b/spree/core/lib/spree/core/previews/webhook_preview.rbindex 48c71eda13..467bbd9242 100644--- a/spree/core/lib/spree/core/previews/webhook_preview.rb+++ b/spree/core/lib/spree/core/previews/webhook_preview.rb@@ -6,14 +6,15 @@ class Spree::WebhookPreview < ActionMailer::Previewprivate- # Reuse the most recent endpoint, or build a renderable disabled one on the- # fly so the preview works on a database that has no webhook endpoints.+ # Reuse the most recent endpoint, or build an in-memory disabled example so the+ # preview works on a database with no webhook endpoints. Never saved, so the+ # admin webhook list stays clean.def webhook_endpoint- Spree::WebhookEndpoint.last || create_example_endpoint+ Spree::WebhookEndpoint.last || example_endpointend- def create_example_endpoint- Spree::WebhookEndpoint.create!(+ def example_endpoint+ Spree::WebhookEndpoint.new(store: Spree::Store.default,name: 'Example endpoint',url: 'https://example.com/webhooks/spree',diff --git a/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb b/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erbindex 29c60f0ae9..048879b82e 100644--- a/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb+++ b/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb@@ -32,11 +32,7 @@<tr><td class="item_image" width="96" valign="middle"><% image = return_item.variant.primary_media || return_item.variant.product.primary_media %>- <% if image.present? && image.attached? %>- <%= link_to spree_image_tag(image, variant: :small, alt: return_item.variant.name, width: 80, class: 'item_thumb'), product_url %>- <% else %>- <%= link_to image_tag('noimage/small.png', alt: return_item.variant.name, width: 80, class: 'item_thumb'), product_url %>- <% end %>+ <%= render 'spree/shared/item_thumbnail_link', image: image, product_url: product_url, alt: return_item.variant.name %></td><td class="item_info" valign="middle"><%= link_to return_item.variant.name, product_url, class: 'f-fallback item_name' %>diff --git a/spree/emails/app/views/spree/shared/_item_thumbnail_link.html.erb b/spree/emails/app/views/spree/shared/_item_thumbnail_link.html.erbnew file mode 100644index 0000000000..1fba790cb8--- /dev/null+++ b/spree/emails/app/views/spree/shared/_item_thumbnail_link.html.erb@@ -0,0 +1,7 @@+<%# Rounded 80px product thumbnail linking to the product page, with a+ no-image fallback. Locals: image, product_url, alt. %>+<% if image.present? && image.attached? %>+ <%= link_to spree_image_tag(image, variant: :small, alt: alt, width: 80, class: 'item_thumb'), product_url %>+<% else %>+ <%= link_to image_tag('noimage/small.png', alt: alt, width: 80, class: 'item_thumb'), product_url %>+<% end %>diff --git a/spree/emails/app/views/spree/shared/purchased_items_table/_line_item.html.erb b/spree/emails/app/views/spree/shared/purchased_items_table/_line_item.html.erbindex 912c39fd93..800d65338f 100644--- a/spree/emails/app/views/spree/shared/purchased_items_table/_line_item.html.erb+++ b/spree/emails/app/views/spree/shared/purchased_items_table/_line_item.html.erb@@ -3,11 +3,7 @@<td class="item_image" width="96" valign="middle"><% image = line_item.variant.primary_media || line_item.product.primary_media %><% product_url = spree_storefront_resource_url(line_item.product) %>- <% if image.present? && image.attached? %>- <%= link_to spree_image_tag(image, variant: :small, alt: line_item.name, width: 80, class: 'item_thumb'), product_url %>- <% else %>- <%= link_to image_tag('noimage/small.png', alt: line_item.name, width: 80, class: 'item_thumb'), product_url %>- <% end %>+ <%= render 'spree/shared/item_thumbnail_link', image: image, product_url: product_url, alt: line_item.name %></td><td class="item_info" valign="middle"><%= link_to line_item.name, product_url, class: 'f-fallback item_name' %>diff --git a/spree/emails/app/views/spree/shared/purchased_items_table/_subtotal.html.erb b/spree/emails/app/views/spree/shared/purchased_items_table/_subtotal.html.erbindex 2866a1e622..12bd1bd28b 100644--- a/spree/emails/app/views/spree/shared/purchased_items_table/_subtotal.html.erb+++ b/spree/emails/app/views/spree/shared/purchased_items_table/_subtotal.html.erb@@ -1,6 +1,6 @@<tr><td valign="middle">- <span class="f-fallback"><%= Spree.t(:subtotal) %></span>+ <span class="f-fallback"><%= Spree.t('order_mailer.subtotal') %></span></td><td class="summary_value" align="right" valign="middle"><span class="f-fallback"><%= order.display_item_total %></span>diff --git a/spree/emails/app/views/spree/shared/purchased_items_table/_total.html.erb b/spree/emails/app/views/spree/shared/purchased_items_table/_total.html.erbindex 729d05ba99..fe073b2294 100644--- a/spree/emails/app/views/spree/shared/purchased_items_table/_total.html.erb+++ b/spree/emails/app/views/spree/shared/purchased_items_table/_total.html.erb@@ -1,6 +1,6 @@<tr class="summary_total"><td valign="middle">- <span class="f-fallback"><%= Spree.t(:total) %></span>+ <span class="f-fallback"><%= Spree.t('order_mailer.total') %></span></td><td class="summary_value" align="right" valign="middle"><span class="f-fallback"><%= order.display_total_minus_store_credits %></span>diff --git a/spree/emails/lib/spree/emails/previews/newsletter_preview.rb b/spree/emails/lib/spree/emails/previews/newsletter_preview.rbindex a887df6c3b..f48b86d86a 100644--- a/spree/emails/lib/spree/emails/previews/newsletter_preview.rb+++ b/spree/emails/lib/spree/emails/previews/newsletter_preview.rb@@ -1,7 +1,20 @@# Preview Spree newsletter emails at /rails/mailers/spree/newsletterclass Spree::NewsletterPreview < ActionMailer::Previewdef email_confirmation- subscriber = Spree::NewsletterSubscriber.unverified.last || Spree::NewsletterSubscriber.last+ subscriber = Spree::NewsletterSubscriber.unverified.last || example_subscriberSpree::NewsletterMailer.email_confirmation(subscriber)end++ private++ # Build an in-memory subscriber so the preview works on a database with no+ # newsletter subscribers. Never saved, so no records are created.+ def example_subscriber+ subscriber = Spree::NewsletterSubscriber.new(+ email: '[email protected]',+ store: Spree::Store.default+ )+ subscriber.verification_token ||= 'preview-token'+ subscriber+ endend