Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Remove outdated prompt for leave blank.

Matthew Kennedy980173bbef15
diff --git a/backend/app/views/spree/admin/payment_methods/_form.html.erb b/backend/app/views/spree/admin/payment_methods/_form.html.erb
index a5ff976679..68a2a8d3ac 100644
--- a/backend/app/views/spree/admin/payment_methods/_form.html.erb
+++ b/backend/app/views/spree/admin/payment_methods/_form.html.erb
@@ -27,7 +27,6 @@
<div data-hook="store" class="form-group">
<%= label_tag :payment_method_store, Spree.t(:stores) %>
<%= collection_select(:payment_method, :store_ids, @stores, :id, :unique_name, {}, { multiple: true, id: 'store_id', class: 'select2' }) %>
- <small class="form-text text-muted"><%= Spree.t('payment_method_form.stores_help') %></small>
</div>
<div data-hook="display" class="form-group">
diff --git a/core/app/models/spree/payment_method.rb b/core/app/models/spree/payment_method.rb
index 93a3f87a14..a1db8f7440 100644
--- a/core/app/models/spree/payment_method.rb
+++ b/core/app/models/spree/payment_method.rb
@@ -79,6 +79,8 @@ module Spree
end
def available_for_store?(store)
+ return false if store.blank?
+
store_ids.include?(store.id)
end
end
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index f5453ca364..0c2d4e7424 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -1249,8 +1249,6 @@ en:
payment_identifier: Payment Identifier
payment_information: Payment Information
payment_method: Payment Method
- payment_method_form:
- stores_help: Leave blank to show this payment method in all stores.
payment_methods: Payment Methods
payment_method_not_supported: That payment method is unsupported. Please choose another one.
payment_processing_failed: Payment could not be processed, please check the details you entered
diff --git a/core/db/migrate/20210114220232_remove_store_id_from_spree_payment_methods.rb b/core/db/migrate/20210114220232_remove_store_id_from_spree_payment_methods.rb
index 5f4ca605c4..2ae63c3099 100644
--- a/core/db/migrate/20210114220232_remove_store_id_from_spree_payment_methods.rb
+++ b/core/db/migrate/20210114220232_remove_store_id_from_spree_payment_methods.rb
@@ -1,20 +1,19 @@
class RemoveStoreIdFromSpreePaymentMethods < ActiveRecord::Migration[6.0]
-
def up
Spree::PaymentMethod.all.each do |payment_method|
- if payment_method.store_id.nil?
- Spree::Store.all.each do |store|
- payment_method.store_ids = store.id
- payment_method.save
- end
- else
- payment_method.store_ids = [:store_id]
- payment_method.save
- end
- end
+ next if payment_method.store_ids.any?
+
+ payment_method.store_ids = if payment_method[:store_id].present?
+ payment_method[:store_id]
+ else
+ Spree::Store.ids
+ end
+
+ payment_method.save
+ end
end
def change
- remove_column :spree_payment_methods, :store_id, :integer
+ remove_column :spree_payment_methods, :store_id
end
end