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.

Update

Matthew Kennedy3bff7ab9274a
diff --git a/core/app/models/spree/payment_method.rb b/core/app/models/spree/payment_method.rb
index 3409b69eb5..93a3f87a14 100644
--- a/core/app/models/spree/payment_method.rb
+++ b/core/app/models/spree/payment_method.rb
@@ -79,7 +79,7 @@ module Spree
end
def available_for_store?(store)
- return true if store_ids.empty? || store_ids.include?(store.id)
+ store_ids.include?(store.id)
end
end
end
diff --git a/core/db/migrate/20210114182625_create_spree_payment_methods_stores.rb b/core/db/migrate/20210114182625_create_spree_payment_methods_stores.rb
index 0f4bdc6620..578e28d65d 100644
--- a/core/db/migrate/20210114182625_create_spree_payment_methods_stores.rb
+++ b/core/db/migrate/20210114182625_create_spree_payment_methods_stores.rb
@@ -4,5 +4,7 @@ class CreateSpreePaymentMethodsStores < ActiveRecord::Migration[6.0]
t.belongs_to :payment_method
t.belongs_to :store
end
+
+ add_index :spree_payment_methods_stores, [:payment_method_id, :store_id], unique: true, name: 'payment_mentod_id_store_id_unique_index'
end
end
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 b62f395926..5f4ca605c4 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,5 +1,20 @@
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
+ end
+
def change
- remove_column :spree_payment_methods, :store_id
+ remove_column :spree_payment_methods, :store_id, :integer
end
end