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.

Bring back old logic of always having a Calculator for `CreateItemAdjustments` and `CreateAdjustment`

Damian Legawiece85f2caa13d5
diff --git a/core/app/models/spree/promotion/actions/create_adjustment.rb b/core/app/models/spree/promotion/actions/create_adjustment.rb
index 132ec3f005..194888530a 100644
--- a/core/app/models/spree/promotion/actions/create_adjustment.rb
+++ b/core/app/models/spree/promotion/actions/create_adjustment.rb
@@ -5,6 +5,8 @@ module Spree
include Spree::CalculatedAdjustments
include Spree::AdjustmentSource
+ before_validation -> { self.calculator ||= Calculator::FlatPercentItemTotal.new }
+
def perform(options = {})
order = options[:order]
diff --git a/core/app/models/spree/promotion/actions/create_item_adjustments.rb b/core/app/models/spree/promotion/actions/create_item_adjustments.rb
index 480ed09746..b572e49109 100644
--- a/core/app/models/spree/promotion/actions/create_item_adjustments.rb
+++ b/core/app/models/spree/promotion/actions/create_item_adjustments.rb
@@ -5,6 +5,8 @@ module Spree
include Spree::CalculatedAdjustments
include Spree::AdjustmentSource
+ before_validation -> { self.calculator ||= Calculator::PercentOnLineItem.new }
+
def perform(options = {})
order = options[:order]
promotion = options[:promotion]