Hiding certain payment gateways based on selected shipping method
-
Is this code still applicable to the new version of Woocommerce with Shipping Zones in effect? For some reason this doesn’t work anymore ever since I upgraded to the new version of Woocommerce. Thanks!
<?php
/**
* Filter payment gatways
*/
function my_custom_available_payment_gateways( $gateways ) {
$chosen_shipping_rates = WC()->session->get( ‘chosen_shipping_methods’ );
// When ‘local delivery’ has been chosen as shipping rate
if ( in_array( ‘local_delivery’, $chosen_shipping_rates ) ) :
// Remove bank transfer payment gateway
unset( $gateways[‘bacs’] );
endif;
return $gateways;
}
add_filter( ‘woocommerce_available_payment_gateways’, ‘my_custom_available_payment_gateways’ );
The topic ‘Hiding certain payment gateways based on selected shipping method’ is closed to new replies.