Lee Willis

Change order of payment gateways in Easy Digital Downloads

| 3 Comments

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:

Screenshot from 2014-10-28 22:10:46

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.
Screenshot from 2014-10-28 22:15:48

3 Comments

  1. Please fix line 9

    if ( ! emptyempty(

    it says the word “empty” twice and the plugin won’t work.

  2. 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.

Leave a Reply

Required fields are marked *.