Skip to content

Instantly share code, notes, and snippets.

@rvdsteege
Last active November 12, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvdsteege/a1d71cf95ae9989812c6915eef599ba2 to your computer and use it in GitHub Desktop.
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.
<?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