Cannot deactivate payment gateway programmatically
-
My custom theme has a filter to deactivate all payment gateways except Bank Transfer (BACS) on a specific condition, it works perfectly with all available methods (we have Stripe, PayPal and several others) but not with Satispay. Consider the following code:
add_filter('woocommerce_available_payment_gateways','umm_filter_gateways',1); function umm_filter_gateways($gateways){ if ( ! is_admin() ) {//front-end only $session = WC()->session; if ($session){//null check if ( $session->get( 'my_custom_condition_trigger' ) ){ foreach ($gateways as $key => $value) { if ($key != "bacs"){//if not BACS unset($gateways[$key]);//remove gateway from array } } } } } return $gateways; }
Unfortunately all other methods are successfully removed under that condition, while Satispay remains available. I’ve also tried saving a custom debug option in the DB with
update_option('MY_DEBUG_LOG', json_encode($gateways));
before returning the $gateways array at the end of the function, and the array only contains the ‘bacs’ gateway, so my function works as expected. Why does the plugin show Satispay as an available payment gateway when it shouldn’t?
- You must be logged in to reply to this topic.