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.

Fixed `PromotionHandler::FreeShipping` with multiple coupon codes promos

Damian Legawieca7c05fb18479
diff --git a/core/app/models/spree/promotion_handler/free_shipping.rb b/core/app/models/spree/promotion_handler/free_shipping.rb
index cc76b879b0..200ebba2a0 100644
--- a/core/app/models/spree/promotion_handler/free_shipping.rb
+++ b/core/app/models/spree/promotion_handler/free_shipping.rb
@@ -13,7 +13,7 @@ module Spree
def activate
promotions.each do |promotion|
- next if promotion.code.present? && !order_promo_ids.include?(promotion.id)
+ next if promotion.coupon_code? && !order_promo_ids.include?(promotion.id)
promotion.activate(order: order) if promotion.eligible?(order)
end
diff --git a/core/spec/models/spree/promotion_handler/free_shipping_spec.rb b/core/spec/models/spree/promotion_handler/free_shipping_spec.rb
index 89fd5262cf..07ba6b07d9 100644
--- a/core/spec/models/spree/promotion_handler/free_shipping_spec.rb
+++ b/core/spec/models/spree/promotion_handler/free_shipping_spec.rb
@@ -28,6 +28,10 @@ module Spree
expect { subject.activate }.to change { shipment.adjustments.count }
end
+
+ it 'does not adjust the shipment when not applied to order' do
+ expect { subject.activate }.not_to change { shipment.adjustments.count }
+ end
end
context 'if promo has multiple codes' do
@@ -39,6 +43,10 @@ module Spree
expect { subject.activate }.to change { shipment.adjustments.count }
end
+
+ it 'does not adjust the shipment when not applied to order' do
+ expect { subject.activate }.not_to change { shipment.adjustments.count }
+ end
end
context 'if promo has a path' do