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.

FIX payment intents update for promotions (#13144)

brozek552851742c13
diff --git a/core/app/models/spree/promotion_handler/coupon.rb b/core/app/models/spree/promotion_handler/coupon.rb
index 6441b125b7..5c3f16d427 100644
--- a/core/app/models/spree/promotion_handler/coupon.rb
+++ b/core/app/models/spree/promotion_handler/coupon.rb
@@ -191,8 +191,7 @@ module Spree
if discount || created_line_items
handle_coupon_code(discount, coupon_code) if discount
- order.update_totals
- order.persist_totals
+ order.update_with_updater!
set_success_code :coupon_code_applied
elsif order.promotions.with_coupon_code(order.coupon_code)
# since CouponCode is disposable...
diff --git a/core/spec/models/spree/promotion_handler/coupon_spec.rb b/core/spec/models/spree/promotion_handler/coupon_spec.rb
index 67289d379a..2caa01c2bb 100644
--- a/core/spec/models/spree/promotion_handler/coupon_spec.rb
+++ b/core/spec/models/spree/promotion_handler/coupon_spec.rb
@@ -90,6 +90,11 @@ module Spree
expect(order.reload.total).to eq(100)
end
+ it 'calls update_with_updater!' do
+ expect(order).to receive(:update_with_updater!)
+ subject.apply
+ end
+
it 'coupon already applied to the order' do
subject.apply
expect(subject.success).to be_present