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
Fixed Country Promotion rule for Store default country
Damian Legawiec1f81e2eea039
diff --git a/core/app/models/spree/promotion/rules/country.rb b/core/app/models/spree/promotion/rules/country.rbindex 3126c6793e..247725926d 100644--- a/core/app/models/spree/promotion/rules/country.rb+++ b/core/app/models/spree/promotion/rules/country.rb@@ -11,7 +11,7 @@ module Spreedef eligible?(order, options = {})country_id = options[:country_id] || order.ship_address.try(:country_id)- unless country_id.eql?(preferred_country_id || Spree::Country.default)+ unless country_id.eql?(preferred_country_id || order.store.default_country_id)eligibility_errors.add(:base, eligibility_error_message(:wrong_country))enddiff --git a/core/spec/models/spree/promotion/rules/country_spec.rb b/core/spec/models/spree/promotion/rules/country_spec.rbindex 45fee571ef..6052f1233d 100644--- a/core/spec/models/spree/promotion/rules/country_spec.rb+++ b/core/spec/models/spree/promotion/rules/country_spec.rb@@ -1,13 +1,12 @@require 'spec_helper'describe Spree::Promotion::Rules::Country, type: :model do- let(:rule) { Spree::Promotion::Rules::Country.new }- let(:order) { create(:order) }+ let!(:store) { create(:store, default_country: other_country) }+ let(:rule) { described_class.new }+ let(:order) { create(:order, store: store) }let(:country) { create(:country) }let(:other_country) { create(:country) }- before { allow(Spree::Country).to receive(:default) { other_country } }-context 'preferred country is set' dobefore { rule.preferred_country_id = country.id }