diff --git a/engines/order_management/app/services/order_management/stock/package.rb b/engines/order_management/app/services/order_management/stock/package.rb index d6ebbb35c1..8872d8571a 100644 --- a/engines/order_management/app/services/order_management/stock/package.rb +++ b/engines/order_management/app/services/order_management/stock/package.rb @@ -79,24 +79,11 @@ module OrderManagement # TODO calculate from first variant? end - # Returns all existing shipping categories. - # It disables the matching of product shipping category with shipping method's category - # It allows checkout of products with categories that are not the ship method's categories - # - # @return [Array] - def shipping_categories - Spree::ShippingCategory.all - end - - # Skips the methods that are not used by the order's distributor + # Returns the shipping methods that are enabled by the order's distributor # # @return [Array] def shipping_methods - available_shipping_methods = shipping_categories.flat_map(&:shipping_methods).uniq.to_a - - available_shipping_methods.keep_if do |shipping_method| - ships_with?(order.distributor.shipping_methods.to_a, shipping_method) - end + order.distributor.shipping_methods.uniq.to_a end def inspect @@ -124,17 +111,6 @@ module OrderManagement shipment end - - private - - # Checks whether the given distributor provides the specified shipping method - # - # @param shipping_methods [Array] - # @param shipping_method [Spree::ShippingMethod] - # @return [Boolean] - def ships_with?(shipping_methods, shipping_method) - shipping_methods.include?(shipping_method) - end end end end diff --git a/engines/order_management/spec/services/order_management/stock/package_spec.rb b/engines/order_management/spec/services/order_management/stock/package_spec.rb index 899b998ee5..d7ba4fba74 100644 --- a/engines/order_management/spec/services/order_management/stock/package_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/package_spec.rb @@ -171,16 +171,6 @@ module OrderManagement expect(package.shipping_methods).to_not include shipping_method3 end end - - describe '#shipping_categories' do - it "returns ship categories that are not the ship categories of the order's products" do - package - other_shipping_category = Spree::ShippingCategory.create(name: "Custom") - - expect(package.shipping_categories).to eq [shipping_method1.shipping_categories.first, - other_shipping_category] - end - end end end end