From 5e1f7bbb601380a5ea2140ca2e6d61e5e25c81d3 Mon Sep 17 00:00:00 2001 From: Dumitru Ceban Date: Fri, 15 May 2020 11:38:48 +0200 Subject: [PATCH] Add admin UI for shipping methods - stock loc association Introduce the admin UI to be able to associate a shipping method to specific stock locations. This makes editable also `Spree::ShippingMethod#available_to_all` from admin, being directly related to stock location association behaviour. --- .../admin/shipping_methods/_form.html.erb | 26 +++++++++++++++++++ core/config/locales/en.yml | 7 +++++ 2 files changed, 33 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 7e2f07ccc7e..677fb613bc6 100644 --- a/backend/app/views/spree/admin/shipping_methods/_form.html.erb +++ b/backend/app/views/spree/admin/shipping_methods/_form.html.erb @@ -54,6 +54,32 @@ <%= error_message_on :shipping_method, :tracking_url %> <% end %> + +
+ <%= f.field_container :stock_locations do %> + <%= f.label :stock_locations %> + <%= f.collection_select :stock_location_ids, + Spree::StockLocation.order_default, :id, :name, + {}, + class: 'fullwidth select2', + multiple: true %> + <%= error_message_on :shipping_method, :stock_locations %> + <% end %> +
+ +
+ <%= f.field_container :available_to_all, class: %w(checkbox) do %> + + <%= error_message_on :shipping_method, :available_to_all %> + <% end %> +
<%= f.field_container :available_to_users, class: %w(checkbox) do %> diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml index 281b4c7668b..2d9cc8c9735 100644 --- a/core/config/locales/en.yml +++ b/core/config/locales/en.yml @@ -319,6 +319,8 @@ en: name: Name service_level: Service Level tracking_url: Tracking URL + stock_locations: Stock Locations + available_to_all: Available to all stock locations spree/shipping_rate: amount: Amount label: Label @@ -883,6 +885,11 @@ en: expired: Expired inactive: Inactive not_started: Not started + shipping_methods: + form: + available_to_all_hint: When checked, this shipping method will be + available to all stock locations ignoring the selected values in + "Stock Locations" field. stock_locations: form: address: Address