Title: Cannot deactivate payment gateway programmatically
Last modified: July 11, 2024

---

# Cannot deactivate payment gateway programmatically

 *  [lupusyon](https://wordpress.org/support/users/lupusyon/)
 * (@lupusyon)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/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:
 *     ```wp-block-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
 *     ```wp-block-code
       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?

The topic ‘Cannot deactivate payment gateway programmatically’ is closed to new 
replies.

 * ![](https://ps.w.org/woo-satispay/assets/icon-256x256.png?rev=3098775)
 * [Satispay for WooCommerce](https://wordpress.org/plugins/woo-satispay/)
 * [Support Threads](https://wordpress.org/support/plugin/woo-satispay/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-satispay/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-satispay/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-satispay/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [lupusyon](https://wordpress.org/support/users/lupusyon/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/cannot-deactivate-payment-gateway-programmatically/)
 * Status: not resolved