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: making sure ShippingMethodZone is unique

Damian Legawiec6cb326d92dc9
diff --git a/core/app/models/spree/shipping_method_zone.rb b/core/app/models/spree/shipping_method_zone.rb
index e044c47523..fc500a9d51 100644
--- a/core/app/models/spree/shipping_method_zone.rb
+++ b/core/app/models/spree/shipping_method_zone.rb
@@ -1,6 +1,8 @@
module Spree
class ShippingMethodZone < Spree::Base
- belongs_to :shipping_method
- belongs_to :zone
+ belongs_to :shipping_method, -> { with_deleted }, inverse_of: :shipping_method_zones, class_name: 'Spree::ShippingMethod'
+ belongs_to :zone, inverse_of: :shipping_method_zones, class_name: 'Spree::Zone'
+
+ validates :shipping_method, uniqueness: { scope: :zone }
end
end