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