mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Filter PaymentMethods by distributor
This commit is contained in:
@@ -75,6 +75,12 @@ Spree::Order.class_eval do
|
||||
line_items.map { |li| li.variant }
|
||||
end
|
||||
|
||||
# Show payment methods with no distributor or for this distributor
|
||||
def available_payment_methods
|
||||
@available_payment_methods ||= Spree::PaymentMethod.available(:front_end).select do |pm|
|
||||
(self.distributor && (pm.distributor == self.distributor)) || pm.distributor == nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
= f.label :distributor
|
||||
%br
|
||||
|
||||
= collection_select(:payment_method, :distributor, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
|
||||
= collection_select(:payment_method, :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
|
||||
= f.error_message_on :distributor
|
||||
|
||||
Reference in New Issue
Block a user