Filter for only allowing ePDQ payment method for adminstrators

You may find the need not to want the ePDQ payment method to appear from your customers if your site is already live and still testing live transactions.

Step 1

You’ll have to copy the code (WooCommerce filter) below:

add_filter( ‘woocommerce_available_payment_gateways’, ‘ePDQ_enable_manager’ );
function ePDQ_enable_manager( $available_gateways ) {
if ( isset( $available_gateways[‘ag_epdq_checkout’] ) && ! current_user_can( ‘manage_woocommerce’ ) ) {
unset( $available_gateways[‘ag_epdq_checkout’] );
}    
return $available_gateways;
}

 

Step 2 

You’ll have to install a code snippet plugin like CodeSnippets and paste the code using it.
Note: We recommend using this plugin as an error on the code you’ve pasted; it won’t cause the site to crash.
The ePDQ payment method should now only be available for administrator users, and your customers shouldn’t see it from their end.

Was this helpful?