From 07e5f4a9a0fc4b2225cc52bf1007a712ab1f37dc Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 22 Jan 2016 10:21:21 -0800 Subject: [PATCH 1/3] Add a carrier and service level column to Spree::ShippingMethods. When we're dealing with a shipping method, we have no formal way of adding additional information that would be useful for fulfillment purposes. We can add an "internal" name to the shipping method, but that would require pattern matching to get any useful information from. Often, in most fulfillment scenarios, we have a desire to know _exactly_ what carrier and service level a specific shipping method is representative of. Given a shipment I can then infer that it should be shipped with UPS one day shipping by introspecting on the methods' carrier and service_level columns as necessary. This is optional as it stands, but validations can be added in stores as required for complex fulfillment scenarios. --- ...d_carrier_and_service_level_to_spree_shipping_methods.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 core/db/migrate/20160122182105_add_carrier_and_service_level_to_spree_shipping_methods.rb diff --git a/core/db/migrate/20160122182105_add_carrier_and_service_level_to_spree_shipping_methods.rb b/core/db/migrate/20160122182105_add_carrier_and_service_level_to_spree_shipping_methods.rb new file mode 100644 index 00000000000..2653a55de4d --- /dev/null +++ b/core/db/migrate/20160122182105_add_carrier_and_service_level_to_spree_shipping_methods.rb @@ -0,0 +1,6 @@ +class AddCarrierAndServiceLevelToSpreeShippingMethods < ActiveRecord::Migration + def change + add_column :spree_shipping_methods, :carrier, :string + add_column :spree_shipping_methods, :service_level, :string + end +end From 43b90bdd07567128f819a07bac394739ee9398e9 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 22 Jan 2016 11:12:20 -0800 Subject: [PATCH 2/3] Add carrier and service level to the backend. Allows users to set service levels and carriers for shipping methods on the backend. --- .../admin/shipping_methods/_form.html.erb | 18 ++++++++++++++++++ core/config/locales/en.yml | 3 +++ 2 files changed, 21 insertions(+) diff --git a/backend/app/views/spree/admin/shipping_methods/_form.html.erb b/backend/app/views/spree/admin/shipping_methods/_form.html.erb index 5356fb61b80..d5d3828676e 100644 --- a/backend/app/views/spree/admin/shipping_methods/_form.html.erb +++ b/backend/app/views/spree/admin/shipping_methods/_form.html.erb @@ -33,6 +33,24 @@ +
+
+ <%= f.field_container :carrier do %> + <%= f.label :carrier %>
+ <%= f.text_field :carrier, :class => 'fullwidth', :label => false %> + <%= error_message_on :shipping_method, :carrier %> + <% end %> +
+ +
+ <%= f.field_container :service_level do %> + <%= f.label :service_level %>
+ <%= f.text_field :service_level, :class => 'fullwidth', :label => false %> + <%= error_message_on :shipping_method, :service_level %> + <% end %> +
+
+
<%= f.field_container :tracking_url do %> <%= f.label :tracking_url, Spree.t(:tracking_url) %>
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml index 071c6266da0..a13f02438b8 100644 --- a/core/config/locales/en.yml +++ b/core/config/locales/en.yml @@ -105,6 +105,9 @@ en: amount: Amount spree/role: name: Name + spree/shipping_method: + carrier: Carrier + service_level: Service Level spree/state: abbr: Abbreviation name: Name From af0625c9deeda1d8c548c7726dfc4a4fb30a7887 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 22 Jan 2016 14:59:57 -0800 Subject: [PATCH 3/3] Add carrier and service level to the shipping method factory --- .../spree/testing_support/factories/shipping_method_factory.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/lib/spree/testing_support/factories/shipping_method_factory.rb b/core/lib/spree/testing_support/factories/shipping_method_factory.rb index 0d730c431b4..c512e2449c4 100644 --- a/core/lib/spree/testing_support/factories/shipping_method_factory.rb +++ b/core/lib/spree/testing_support/factories/shipping_method_factory.rb @@ -3,6 +3,8 @@ zones { |a| [Spree::Zone.global] } name 'UPS Ground' code 'UPS_GROUND' + carrier 'UPS' + service_level '1DAYGROUND' before(:create) do |shipping_method, evaluator| if shipping_method.shipping_categories.empty?