From 540aee0a2e0da9731fbd57ab97c7c6d0c6beb69e 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 bfb81a4d7afc9ecd1294506c16a149076f364cd3 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 ff523814767..e6917b53c88 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 8ebea10ccdf..ab8ffbc5d29 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 eba36baf0dd89d203736ab795dcd03eb593ce0a6 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 ae276706ac4..cf90fefd5e0 100644 --- a/core/lib/spree/testing_support/factories/shipping_method_factory.rb +++ b/core/lib/spree/testing_support/factories/shipping_method_factory.rb @@ -16,6 +16,8 @@ name 'UPS Ground' code 'UPS_GROUND' + carrier 'UPS' + service_level '1DAYGROUND' calculator { |s| s.association(:shipping_calculator, strategy: :build, preferred_amount: s.cost) }