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
Drop whole-order totals from the shipped email summary
Damian Legawiec20e2e1f990a8
diff --git a/spree/emails/app/views/spree/shared/_order_summary_section.html.erb b/spree/emails/app/views/spree/shared/_order_summary_section.html.erbindex 9863dbb5dd..c134ca37d8 100644--- a/spree/emails/app/views/spree/shared/_order_summary_section.html.erb+++ b/spree/emails/app/views/spree/shared/_order_summary_section.html.erb@@ -1,10 +1,15 @@<%# Labelled line-items + totals section shared by the order-related emails.- Locals: heading, line_items, order. %>+ Locals: heading, line_items, order, optional totals (default true — pass+ false when line_items is a subset of the order, e.g. one shipment's items,+ so whole-order amounts aren't shown next to a partial item list). %><table class="section" width="100%" cellpadding="0" cellspacing="0" role="presentation"><tr><td><h3 class="f-fallback"><%= heading %></h3>- <%= render 'spree/shared/purchased_items_table', line_items: line_items, order: order %>+ <%= render 'spree/shared/purchased_items_table',+ line_items: line_items,+ order: order,+ totals: local_assigns.fetch(:totals, true) %></td></tr></table>diff --git a/spree/emails/app/views/spree/shared/_purchased_items_table.html.erb b/spree/emails/app/views/spree/shared/_purchased_items_table.html.erbindex bf9935a1e3..3cb47c75e1 100644--- a/spree/emails/app/views/spree/shared/_purchased_items_table.html.erb+++ b/spree/emails/app/views/spree/shared/_purchased_items_table.html.erb@@ -1,5 +1,6 @@<%= render collection: line_items, partial: 'spree/shared/purchased_items_table/line_item', as: :line_item %>+<% if local_assigns.fetch(:totals, true) %><table class="summary purchase_content" width="100%" cellpadding="0" cellspacing="0" role="presentation"><%= render 'spree/shared/purchased_items_table/subtotal', order: order %><% if order.line_item_adjustments.exists? %>@@ -32,3 +33,4 @@<% end %><%= render 'spree/shared/purchased_items_table/total', order: order %></table>+<% end %>diff --git a/spree/emails/app/views/spree/shipment_mailer/shipped_email.html.erb b/spree/emails/app/views/spree/shipment_mailer/shipped_email.html.erbindex 7a705260e7..9912491bfc 100644--- a/spree/emails/app/views/spree/shipment_mailer/shipped_email.html.erb+++ b/spree/emails/app/views/spree/shipment_mailer/shipped_email.html.erb@@ -16,4 +16,5 @@<%= render 'spree/shared/order_summary_section',heading: Spree.t('shipment_mailer.shipped_email.shipment_summary'),line_items: @shipment.manifest.map(&:line_item),- order: @shipment.order %>+ order: @shipment.order,+ totals: false %>diff --git a/spree/emails/spec/mailers/spree/shipment_mailer_spec.rb b/spree/emails/spec/mailers/spree/shipment_mailer_spec.rbindex 057fbc218b..36ea241e99 100644--- a/spree/emails/spec/mailers/spree/shipment_mailer_spec.rb+++ b/spree/emails/spec/mailers/spree/shipment_mailer_spec.rb@@ -34,6 +34,13 @@ describe Spree::ShipmentMailer, type: :mailer doexpect(shipment_email.body).not_to include(%q{Out of Stock})end+ # The shipment may cover only part of the order, so whole-order amounts+ # would be misleading next to the shipped-items list.+ it "doesn't include order totals in the email body" do+ shipment_email = described_class.shipped_email(shipment)+ expect(shipment_email).not_to have_body_text(Spree.t('order_mailer.total'))+ end+it 'shipment_email accepts an shipment id as an alternative to an Shipment object' doexpect dodescribed_class.shipped_email(shipment.id).body