Maybe someone knows, how to add a condition: if the payment amount is less than 3000 – certain payment method is hidden?
For example, there are 2 payment methods:
- cash
- online payment
If the amount is less than 3000, the "cash" method is hidden.
As far as I understand, I need to get the payment gateway ID, and then apply the snippet:
add_filter( 'woocommerce_available_payment_gateways', 'custom_paypal_disable_manager' );
function custom_paypal_disable_manager( $available_gateways ) {
if ( $total_amount < 3000 ) {
unset( $available_gateways['ID payment gateway'] );
return $available_gateways;
}
But I don’t know how to get the payment gateway ID (there are several payment methods and they are all implemented by different plugins).
Perhaps there is a way to get all IDs of payment gateways in a list.
I would be grateful for any information.
2
Answers
Get the payment method ID in WooCommerce Checkout page
Using the following code, will display on checkout payment methods, the payment ID visible only to the admins:
Code goes in functions.php file of your active child theme (or active theme).
Once used, remove it.
You should be able to get the IDs with Developer Tools in your browser I believe. For me, code above shows exactly the same values I can see in code.