Skip to content

Instantly share code, notes, and snippets.

@monecchi
Forked from growdev/functions.php
Created February 23, 2017 17:12
Show Gist options
  • Select an option

  • Save monecchi/93849bc1d300aef4240ffeeaafd588ce to your computer and use it in GitHub Desktop.

Select an option

Save monecchi/93849bc1d300aef4240ffeeaafd588ce 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment