Filter PaymentMethods by distributor

This commit is contained in:
David Cook
2013-08-09 17:08:05 +10:00
parent 1621e4c4a4
commit 98d520f0e3
2 changed files with 7 additions and 1 deletions

View File

@@ -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

View File

@@ -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