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 `Shipment#variants` association

Damian Legawiecdd07c0c5bf5a
diff --git a/core/app/models/spree/shipment.rb b/core/app/models/spree/shipment.rb
index ea995b8650..e22182b77a 100644
--- a/core/app/models/spree/shipment.rb
+++ b/core/app/models/spree/shipment.rb
@@ -21,7 +21,6 @@ module Spree
belongs_to :order, class_name: 'Spree::Order', touch: true
end
belongs_to :stock_location, -> { with_deleted }, class_name: 'Spree::StockLocation'
- has_many :variants, through: :inventory_units
with_options dependent: :delete_all do
has_many :adjustments, as: :adjustable
@@ -30,6 +29,7 @@ module Spree
has_many :state_changes, as: :stateful
end
has_many :shipping_methods, through: :shipping_rates
+ has_many :variants, through: :inventory_units
has_one :selected_shipping_rate, -> { where(selected: true).order(:cost) }, class_name: Spree::ShippingRate.to_s
after_save :update_adjustments