//Disable Payment Gateway For Specific Shipping Method
add_filter( 'woocommerce_available_payment_gateways', 'wpninja_gateway_disable_shipping_326' );
function wpninja_gateway_disable_shipping_326( $available_gateways ) {
global $woocommerce;
if ( !is_admin() ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
if ( isset( $available_gateways['cod'] ) && 0 === strpos( $chosen_shipping, 'free_shipping' ) ) {
unset( $available_gateways['barion'] );
}
}
return $available_gateways;
}
Leave a Reply