Skip to content

Instantly share code, notes, and snippets.

@growdev
Created July 21, 2016 16:10
Show Gist options
  • Save growdev/aa781f43dbbdd2948172d3506f646eb7 to your computer and use it in GitHub Desktop.
Save growdev/aa781f43dbbdd2948172d3506f646eb7 to your computer and use it in GitHub Desktop.
WooCommerce - Remove Shipping Method if Shipping Zone Selected
<?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;
}
@ngothoai
Copy link

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 , ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment