From ccc7a43a068f7e00a21082c1299a7bdb8ce86bb4 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sat, 15 Jun 2019 20:51:24 +0100 Subject: [PATCH] Bypass validation of shipping methods zone on checkout --- app/models/spree/shipping_method_decorator.rb | 8 ++++++++ spec/factories/shipping_method_factory.rb | 1 + 2 files changed, 9 insertions(+) diff --git a/app/models/spree/shipping_method_decorator.rb b/app/models/spree/shipping_method_decorator.rb index 555e1e24c1..44308f4d93 100644 --- a/app/models/spree/shipping_method_decorator.rb +++ b/app/models/spree/shipping_method_decorator.rb @@ -53,6 +53,14 @@ Spree::ShippingMethod.class_eval do spree_calculators.send model_name_without_spree_namespace end + # This is bypassing the validation of shipping method zones on checkout + # It allows checkout using shipping methods without zones (see issue #3928 for details) + # and it allows checkout with addresses outside of the zones of the selected shipping method + def include?(address) + return false unless address + true + end + def has_distributor?(distributor) distributors.include?(distributor) end diff --git a/spec/factories/shipping_method_factory.rb b/spec/factories/shipping_method_factory.rb index 4d4d7c710e..c98a62bf76 100644 --- a/spec/factories/shipping_method_factory.rb +++ b/spec/factories/shipping_method_factory.rb @@ -41,5 +41,6 @@ FactoryBot.modify do factory :shipping_method, parent: :base_shipping_method do distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] } display_on '' + zones { |a| [] } end end