woocommerce remove payment method when totla is 0

Solutions on MaxInterview for woocommerce remove payment method when totla is 0 by the best coders in the world

showing results for - "woocommerce remove payment method when totla is 0"
Leane
09 Jul 2018
1function payment_gateway_disable_total_amount( $available_gateways ) {
2global $woocommerce;
3if ( isset( $available_gateways['paypal'] ) && $woocommerce->cart->total == 0 ) {
4    unset(  $available_gateways['paypal'] );
5}
6    return $available_gateways;
7}
8add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_total_amount' );
9