I have a problem with this code. I get warning: in_array() expects parameter 2 to be array, null given in file... on line...
/**
* Filter payment gateways
*/
function my_custom_available_payment_gateways( $gateways ) {
$chosen_shipping_rates = ( isset( WC()->session ) ) ? WC()->session->get( ‘chosen_shipping_methods’ ) : array();
if ( in_array( ‘flexible_shipping_6_1’, $chosen_shipping_rates ) ) :
unset( $gateways[‘cod’] );
elseif ( in_array( ‘flexible_shipping_6_4’, $chosen_shipping_rates ) ) :
unset( $gateways[‘bacs’] );
unset( $gateways[‘paypal’] );
endif;
return $gateways;
}
add_filter( ‘woocommerce_available_payment_gateways’, ‘my_custom_available_payment_gateways’ );
It will be nice if somebody can help me :-)