public function PaymentGatewayStorage::loadMultipleForOrder in Commerce Core 8.2
Loads all eligible payment gateways for the given order.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
Return value
\Drupal\commerce_payment\Entity\PaymentGatewayInterface[] The payment gateways.
Overrides PaymentGatewayStorageInterface::loadMultipleForOrder
File
- modules/
payment/ src/ PaymentGatewayStorage.php, line 84
Class
- PaymentGatewayStorage
- Defines the payment gateway storage.
Namespace
Drupal\commerce_paymentCode
public function loadMultipleForOrder(OrderInterface $order) {
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface[] $payment_gateways */
$payment_gateways = $this
->loadByProperties([
'status' => TRUE,
]);
// Allow the list of payment gateways to be filtered via code.
$event = new FilterPaymentGatewaysEvent($payment_gateways, $order);
$this->eventDispatcher
->dispatch(PaymentEvents::FILTER_PAYMENT_GATEWAYS, $event);
$payment_gateways = $event
->getPaymentGateways();
// Evaluate conditions for the remaining ones.
foreach ($payment_gateways as $payment_gateway_id => $payment_gateway) {
if (!$payment_gateway
->applies($order)) {
unset($payment_gateways[$payment_gateway_id]);
}
}
uasort($payment_gateways, [
$this->entityType
->getClass(),
'sort',
]);
return $payment_gateways;
}