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.

Improve `Shipment#with_free_shipping_promotion?` (#13041)

Damian Legawiec2277f9424cab
diff --git a/core/app/models/spree/shipment.rb b/core/app/models/spree/shipment.rb
index 3ce642e74b..e90b618a1c 100644
--- a/core/app/models/spree/shipment.rb
+++ b/core/app/models/spree/shipment.rb
@@ -201,8 +201,11 @@ module Spree
with_free_shipping_promotion?
end
+ # Returns true if the shipment has a free shipping promotion applied
+ #
+ # @return [Boolean]
def with_free_shipping_promotion?
- adjustments.promotion.any? { |p| p.source.type == 'Spree::Promotion::Actions::FreeShipping' }
+ adjustments.promotion.includes(:source).any? { |p| p.source.respond_to?(:free_shipping?) && p.source.free_shipping? }
end
def finalize!