Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Set conditional payments method based on shipping method select by the user.
// Hide payment gateways based on shipping method
function payment_gateway_disable( $available_gateways ) {
global $woocommerce;
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
if( $chosen_shipping == 1479475819 ) {
return $available_gateways;
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.