Easy Digital Downloads lets you enable multiple payment gateways to give customers a choice about how they want to pay. The core plugin also lets you choose a default option, but it doesn’t let you choose the order that options are presented at checkout. That can lead to odd UX where the default selected option appears second, or third in the list:
Fortunately, it’s pretty easy to change this order – simply paste the following function into your theme’s functions.php
file, or use a functionality plugin. Just change the $gateway_order
array to the gateways you have enabled, in the order you want them, and you’re good to go.
function lw_edd_enabled_payment_gateways($gateways) { $gateway_order = array( 'stripe', 'paypal', 'manual', ); $new_gateways = array(); foreach ( $gateway_order as $gateway ) { if ( ! empty( $gateways[$gateway] ) ) { $new_gateways[$gateway] = $gateways[$gateway]; } } return $new_gateways; } add_filter( 'edd_enabled_payment_gateways', 'lw_edd_enabled_payment_gateways', 10, 1 );
Here’s what our revised default checkout looks like – much neater.
February 2, 2015 at 5:36 am
Please fix line 9
if ( ! emptyempty(
it says the word “empty” twice and the plugin won’t work.
February 2, 2015 at 8:28 am
Good spot – looks like an issue with the syntax highlighter I’m using. I’ve turned it off for now.
Thanks
February 2, 2015 at 8:30 am
Sure, I left a comment so that in case other users try to use this code don’t have to struggle for hours like I did 🙂
Thanks for sharing though.