Last active
November 12, 2021 08:31
-
-
Save rvdsteege/a1d71cf95ae9989812c6915eef599ba2 to your computer and use it in GitHub Desktop.
Order payments gateways in Restrict Content Pro. Add WordPress filter to for example the `functions.php` file of your WordPress theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pronamic_pay_rcp_payment_methods_order( $gateways ) { | |
/* | |
* Gateways in preferred order. | |
* | |
* @link https://github.com/wp-pay-extensions/restrict-content-pro/blob/3.0.0/src/Extension.php#L201-L242 | |
*/ | |
$order = array( | |
'pronamic_pay_direct_debit_bancontact', | |
'pronamic_pay_credit_card', | |
); | |
// Build gateways array in preferred order. | |
$new_gateways = array(); | |
foreach ( $order as $gateway ) { | |
// Check if payment method has been registered. | |
if ( ! array_key_exists( $gateway, $gateways ) ) { | |
continue; | |
} | |
$new_gateways[ $gateway ] = $gateways[ $gateway ]; | |
} | |
// Merge gateways in order with all other gateways. | |
$new_gateways = array_merge( $new_gateways, $gateways ); | |
// Return. | |
return $new_gateways; | |
} | |
\add_filter( 'rcp_payment_gateways', 'pronamic_pay_rcp_payment_methods_order', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment