function uc_payment_uc_payment_method_checkout_alter in Ubercart 8.4
Same name and namespace in other branches
- 7.3 payment/uc_payment/uc_payment.module \uc_payment_uc_payment_method_checkout_alter()
Implements hook_uc_payment_method_checkout_alter().
File
- payment/
uc_payment/ uc_payment.module, line 106 - Defines the payment API that lets payment modules interact with Ubercart.
Code
function uc_payment_uc_payment_method_checkout_alter(array &$methods, OrderInterface $order) {
if (isset($methods['free_order'])) {
if ($order
->getTotal() < 0.01) {
// Unset all other payment methods if this is a free order.
foreach (array_keys($methods) as $key) {
if ($key != 'free_order') {
unset($methods[$key]);
}
}
}
else {
// Disallow this payment method if the order is not free.
unset($methods['free_order']);
}
}
}