diff --git a/core/app/models/spree/shipping_method.rb b/core/app/models/spree/shipping_method.rb index 360a3a8b5e4..2f6ca280677 100644 --- a/core/app/models/spree/shipping_method.rb +++ b/core/app/models/spree/shipping_method.rb @@ -36,10 +36,12 @@ def self.with_all_shipping_category_ids(shipping_category_ids) # cause this to return incorrect results. join_table = Spree::ShippingMethodCategory.arel_table having = join_table[:id].count(true).eq(shipping_category_ids.count) - joins(:shipping_method_categories). + subquery = joins(:shipping_method_categories). where(spree_shipping_method_categories: { shipping_category_id: shipping_category_ids }). group('spree_shipping_methods.id'). having(having) + + where(id: subquery.select(:id)) end # @param stock_location [Spree::StockLocation] stock location