I tried this code below to hide/disable Credit/Debit card and Direct bank transfer payment method on Woo commerce(WordPress) when the checkout total == 400 but did not work. Please any idea on how to achieve this? Thank you so kindly.
function payment_gateway_disable_total_amount( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['bacs'] ) && $woocommerce->cart->total == 400 ) {
unset( $available_gateways['bacs'] );
}
if ( isset( $available_gateways['youpay'] ) && $woocommerce->cart->total == 400 ) {
unset( $available_gateways['youpay'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_total_amount' );