From 40dd307a35eb5091229804e0e194fd8d92e6559b Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Fri, 8 May 2020 11:40:44 +0100 Subject: [PATCH] Remove shipping method display on front_end option, it is not working and it's not straight forward to make it work correctly --- .../spree/admin/shipping_methods/_form.html.haml | 2 +- config/locales/en.yml | 10 ++++------ ...01630_convert_frontend_shipping_method_to_both.rb | 12 ++++++++++++ db/schema.rb | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20200508101630_convert_frontend_shipping_method_to_both.rb diff --git a/app/views/spree/admin/shipping_methods/_form.html.haml b/app/views/spree/admin/shipping_methods/_form.html.haml index dfef7418a1..450febb31b 100644 --- a/app/views/spree/admin/shipping_methods/_form.html.haml +++ b/app/views/spree/admin/shipping_methods/_form.html.haml @@ -18,7 +18,7 @@ .alpha.three.columns = f.label :display_on, t(:display) .omega.eight.columns - = select(:shipping_method, :display_on, Spree::ShippingMethod::DISPLAY.collect { |display| [t(".#{display}"), display == :both ? nil : display.to_s] }, {}, {class: 'select2 fullwidth'}) + = select(:shipping_method, :display_on, [[t(".both"), nil], [t(".back_end"), "back_end"]], {}, {class: 'select2 fullwidth'}) = error_message_on :shipping_method, :display_on .row diff --git a/config/locales/en.yml b/config/locales/en.yml index fa92cb72a1..685004c6ab 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3221,9 +3221,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using zone: "Zone" calculator: "Calculator" display: "Display" - both: "Both" - front_end: "Front End" - back_end: "Back End" + both: "Both Checkout and Back office" + back_end: "Back office only" no_shipping_methods_found: "No shipping methods found" new: new_shipping_method: "New Shipping Method" @@ -3235,9 +3234,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using form: categories: "Categories" zones: "Zones" - both: "Both" - front_end: "Front End" - back_end: "Back End" + both: "Both Checkout and Back office" + back_end: "Back office only" payment_methods: new: new_payment_method: "New Payment Method" diff --git a/db/migrate/20200508101630_convert_frontend_shipping_method_to_both.rb b/db/migrate/20200508101630_convert_frontend_shipping_method_to_both.rb new file mode 100644 index 0000000000..5e2418c3b8 --- /dev/null +++ b/db/migrate/20200508101630_convert_frontend_shipping_method_to_both.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class ConvertFrontendShippingMethodToBoth < ActiveRecord::Migration + def up + # The display_on value front_end is not working + # (it's not being used in the back office to ignore shipping methods marked as front_end) + # So, here we are converting all entries to the more generic "both" option + # both is represented as nil in the database + # # This enables us to remove the front_end option from the code + execute("UPDATE spree_shipping_methods SET display_on = null WHERE display_on = 'front_end'") + end +end diff --git a/db/schema.rb b/db/schema.rb index e08122c5d6..99415dc9fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20200430105459) do +ActiveRecord::Schema.define(:version => 20200508101630) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id"