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
SD-892 Better display shipping free when promotion is applied
Krzysztof Kalisz8926d0a0a561
diff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 58b7df6d8c..615a187acf 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -898,6 +898,7 @@ en:follow_us: Follow usfooter_info: Footer infoforgot_password: Forgot password?+ free: Freefree_shipping: Free Shippingfree_shipping_amount: "-"front_end: Front Enddiff --git a/frontend/app/helpers/spree/orders_helper.rb b/frontend/app/helpers/spree/orders_helper.rbindex 17444cf105..ae4b2e3b99 100644--- a/frontend/app/helpers/spree/orders_helper.rb+++ b/frontend/app/helpers/spree/orders_helper.rb@@ -3,5 +3,11 @@ module Spreedef order_just_completed?(order)flash[:order_completed] && order.present?end+ def order_has_free_shipping?(order)+ order.promotions+ .joins(:promotion_actions)+ .where(spree_promotion_actions: { type: 'Spree::Promotion::Actions::FreeShipping'})+ .exists?+ endendenddiff --git a/frontend/app/views/spree/checkout/_summary.html.erb b/frontend/app/views/spree/checkout/_summary.html.erbindex 397e5b41c3..e4e1f0386a 100644--- a/frontend/app/views/spree/checkout/_summary.html.erb+++ b/frontend/app/views/spree/checkout/_summary.html.erb@@ -27,24 +27,29 @@<% end %><% if order.passed_checkout_step?("address") && order.shipments.any? %>- <div class="d-table-cell"><%= Spree.t(:shipping) %>:</div>- <% shipping_total = Spree::Money.new(order.shipments.to_a.sum(&:cost), currency: order.currency) %>- <div class="d-table-cell text-right"- data-hook='shipping-total'- data-currency='<%= Money::Currency.find(order.currency).symbol %>'- thousands-separator='<%= shipping_total.thousands_separator %>'- decimal-mark='<%= shipping_total.decimal_mark %>'- precision='<%= Money::Currency.find(order.currency).exponent %>'- >- <%= shipping_total.to_html %>- </div>+ <% if order_has_free_shipping?(order) %>+ <div class="d-table-cell"><%= Spree.t(:shipping) %>:</div>+ <div class="d-table-cell text-right"><%= Spree.t(:free) %></div>+ <% else %>+ <div class="d-table-cell"><%= Spree.t(:shipping) %>:</div>+ <% shipping_total = Spree::Money.new(order.shipments.to_a.sum(&:cost), currency: order.currency) %>+ <div class="d-table-cell text-right"+ data-hook='shipping-total'+ data-currency='<%= Money::Currency.find(order.currency).symbol %>'+ thousands-separator='<%= shipping_total.thousands_separator %>'+ decimal-mark='<%= shipping_total.decimal_mark %>'+ precision='<%= Money::Currency.find(order.currency).exponent %>'+ >+ <%= shipping_total.to_html %>+ </div>- <% if order.shipment_adjustments.nonzero.exists? %>- <% order.shipment_adjustments.nonzero.promotion.eligible.group_by(&:label).each do |label, adjustments| %>- <div class="d-table-cell"><%= label %>:</div>- <div class="d-table-cell text-right">- <%= Spree::Money.new(adjustments.sum(&:amount), currency: order.currency).to_html %>- </div>+ <% if order.shipment_adjustments.nonzero.exists? %>+ <% order.shipment_adjustments.nonzero.promotion.eligible.group_by(&:label).each do |label, adjustments| %>+ <div class="d-table-cell"><%= label %>:</div>+ <div class="d-table-cell text-right">+ <%= Spree::Money.new(adjustments.sum(&:amount), currency: order.currency).to_html %>+ </div>+ <% end %><% end %><% end %><% end %>