-
-
Save monecchi/93849bc1d300aef4240ffeeaafd588ce to your computer and use it in GitHub Desktop.
WooCommerce - Remove Shipping Method if Shipping Zone Selected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'woocommerce_available_payment_gateways', 'filter_gateways', 1); | |
| function filter_gateways( $gateways ) { | |
| $method = WC()->session->get( 'chosen_shipping_methods' ); | |
| // get the value of the radio button on the checkout page | |
| if ( 'flat_rate:1' != $method[0] ) { | |
| unset( $gateways['paypal'] ); | |
| } | |
| return $gateways; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment