mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Ensure valid payment method is selected
This commit is contained in:
@@ -15,6 +15,7 @@ Spree::Admin::PaymentsController.class_eval do
|
|||||||
# Only show payments for the order's distributor
|
# Only show payments for the order's distributor
|
||||||
def filter_payment_methods
|
def filter_payment_methods
|
||||||
@payment_methods = @payment_methods.select{ |pm| pm.has_distributor? @order.distributor}
|
@payment_methods = @payment_methods.select{ |pm| pm.has_distributor? @order.distributor}
|
||||||
|
@payment_method ||= @payment_methods.first
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ Spree::PaymentMethod.class_eval do
|
|||||||
where('distributor_id IN (?)', user.enterprises.map {|enterprise| enterprise.id })
|
where('distributor_id IN (?)', user.enterprises.map {|enterprise| enterprise.id })
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
def has_distributor?(distributor)
|
def has_distributor?(distributor)
|
||||||
self.distributor == distributor
|
self.distributor == distributor
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ensure that all derived classes also allow distributor_id
|
# Ensure that all derived classes also allow distributor_id
|
||||||
|
|||||||
Reference in New Issue
Block a user