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
Align promotion rule eligibility error message with currency of the order. (#12762)
Josef Hovad28fca0d42b4b
diff --git a/core/app/models/spree/promotion/rules/item_total.rb b/core/app/models/spree/promotion/rules/item_total.rbindex 55d3b55496..7537454a53 100644--- a/core/app/models/spree/promotion/rules/item_total.rb+++ b/core/app/models/spree/promotion/rules/item_total.rb@@ -27,39 +27,39 @@ module Spreeupper_limit_condition = trueend- eligibility_errors.add(:base, ineligible_message_max) unless upper_limit_condition- eligibility_errors.add(:base, ineligible_message_min) unless lower_limit_condition+ eligibility_errors.add(:base, ineligible_message_max(order)) unless upper_limit_condition+ eligibility_errors.add(:base, ineligible_message_min(order)) unless lower_limit_conditioneligibility_errors.empty?endprivate- def formatted_amount_min- Spree::Money.new(preferred_amount_min).to_s+ def formatted_amount_min(order)+ Spree::Money.new(preferred_amount_min, currency: order.currency).to_send- def formatted_amount_max+ def formatted_amount_max(order)if preferred_amount_max.present?- Spree::Money.new(preferred_amount_max).to_s+ Spree::Money.new(preferred_amount_max, currency: order.currency).to_selseSpree.t('no_maximum')endend- def ineligible_message_max+ def ineligible_message_max(order)if preferred_operator_max == 'lt'- eligibility_error_message(:item_total_more_than_or_equal, amount: formatted_amount_max)+ eligibility_error_message(:item_total_more_than_or_equal, amount: formatted_amount_max(order))else- eligibility_error_message(:item_total_more_than, amount: formatted_amount_max)+ eligibility_error_message(:item_total_more_than, amount: formatted_amount_max(order))endend- def ineligible_message_min+ def ineligible_message_min(order)if preferred_operator_min == 'gte'- eligibility_error_message(:item_total_less_than, amount: formatted_amount_min)+ eligibility_error_message(:item_total_less_than, amount: formatted_amount_min(order))else- eligibility_error_message(:item_total_less_than_or_equal, amount: formatted_amount_min)+ eligibility_error_message(:item_total_less_than_or_equal, amount: formatted_amount_min(order))endendenddiff --git a/core/spec/models/spree/promotion/rules/item_total_spec.rb b/core/spec/models/spree/promotion/rules/item_total_spec.rbindex c23be84265..303b318a33 100644--- a/core/spec/models/spree/promotion/rules/item_total_spec.rb+++ b/core/spec/models/spree/promotion/rules/item_total_spec.rb@@ -3,7 +3,7 @@ require 'spec_helper'describe Spree::Promotion::Rules::ItemTotal, type: :model dolet!(:store) { @default_store }let(:rule) { Spree::Promotion::Rules::ItemTotal.new }- let(:order) { double(:order) }+ let(:order) { build(:order, store: store) }before dorule.preferred_amount_min = 50