Skip to content

Commit

Permalink
Add admin UI for shipping methods - stock loc association
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cedum committed May 15, 2020
1 parent 83ea392 commit 5e1f7bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions backend/app/views/spree/admin/shipping_methods/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@
<%= error_message_on :shipping_method, :tracking_url %>
<% end %>
</div>

<div class="col-5">
<%= 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 %>
</div>

<div class="col-5">
<%= f.field_container :available_to_all, class: %w(checkbox) do %>
<label>
<%= f.check_box(:available_to_all) %>
<%= Spree::ShippingMethod.human_attribute_name :available_to_all %>
<span class="hint-tooltip"
data-content="<%= t('spree.admin.shipping_methods.form.available_to_all_hint') %>">
<i class="fa fa-info-circle"></i>
</span>
</label>
<%= error_message_on :shipping_method, :available_to_all %>
<% end %>
</div>
</div>

<%= f.field_container :available_to_users, class: %w(checkbox) do %>
Expand Down
7 changes: 7 additions & 0 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5e1f7bb

Please sign in to comment.