Created
July 21, 2016 16:10
-
-
Save growdev/aa781f43dbbdd2948172d3506f646eb7 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
if cart is have over 2 select shipping, then we can not use this function.
it is flat_rate:1:1 or flat:1:2 , ....