Last active
April 11, 2017 06:25
-
-
Save aliciaiceland/79cfe51aed793329dcc0446c500cd09c to your computer and use it in GitHub Desktop.
Disable payment gateway for shipping method
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
function disable_payment_gateways( $gateways ) { | |
$chosen_shipping_rates = WC()->session->get( 'chosen_shipping_methods' ); | |
// if 'local delivery' is chosen as shipping rate | |
if ( in_array( 'local_delivery', $chosen_shipping_rates ) ) : | |
// Removing bank transfer payment gateway, you can unset other gateways too. | |
unset( $gateways['bacs'] ); | |
endif; | |
return $gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'disable_payment_gateways' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment