WooCommerce is a powerful WordPress plugin that allows you to sell products or services.
However, there are chances you do not want your customers to use a particular payment method or any payment options at all on your checkout page. How do you go about this?
WooCommerce Remove Payment Options From Checkout
This brief tutorial will show you an easy solution to remove a certain payment method and remove all payment options without breaking your site.
Additionally, I will share a custom PHP code snippet that I created for disabling a payment gateway for a specific user role on the WooCommerce checkout page. For example, you may want to disable PayPal for the shop manager role.
Steps to Change a Specific Payment Method on the Checkout Page
By default, this is how WooCommerce payment gateways are arranged on the checkout page:
The next step now is to remove a specific payment method.
For illustration purposes, I will remove the direct bank transfer payment method.
Here are the steps that you need to follow:
- Log into your WordPress site and access the dashboard as the admin user.
- Click the Settings link under WooCommerce.
- Click on the Payments tab. You will see all the payment methods and their settings.
- To remove the direct bank transfer payment method, uncheck the button on the Enabled column as shown below:
- With this simple method, you can easily disable any payment gateway of your choice. Once you are done, remember to save the changes.
- After that, go straight to the front end of your site, and refresh the checkout page. You will notice that the direct bank transfer payment gateway does not appear on the checkout page:
Steps to Remove All Payment Methods on the Checkout Page
This solution involves the use of a custom PHP code snippet. Here are the steps that you need to follow:
- Log into your WordPress site and access the dashboard as the admin user.
- From the dashboard menu, click on the Appearance Menu > Theme Editor Menu. When the theme editor page is opened, look for the theme functions file with the extension functions.php. Open this functions file to add the function to remove all payment gateways on the checkout page.
- Add the following line of code to the functions.php file:
// Disable all payment gateways on the checkout page and replace the "Pay" button with "Place order". add_filter( 'woocommerce_cart_needs_payment', '__return_false' );
- This is the outcome:
- Alternatively, you can disable a specific payment gateway for a specific user role. For example, the following code snippet will disable the PayPal payment option for the shop manager role. You should add it in the functions.php file:
/** * Disable Payment Gateway for a Specific User Role | WooCommerce */ add_filter( 'woocommerce_available_payment_gateways', 'njengah_paypal_disable_manager' ); function njengah_paypal_disable_manager( $available_gateways ) { if ( isset( $available_gateways['paypal'] ) && current_user_can( 'manage_woocommerce' ) ) { unset( $available_gateways['paypal'] ); } return $available_gateways; }
Conclusion
In this post, you have seen how you can disable any payment gateway using the built-in WooCommerce option. However, if you are tech-savvy, you can use the custom PHP scripts I have shared.
If you want to hide a specific payment gateway using PHP, remember to add the correct payment gateway ID. If you are not able to add the code correctly, please consider hiring a WordPress developer.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Move WooCommerce Coupon Field Checkout Page
- How to Add Date Field to Checkout In WooCommerce
- How to Remove the Checkout Button WooCommerce
- How to Add WooCommerce Checkout Default Country
- How to Add WooCommerce Payment Icons In the Footer [HTML]
- How to Change WooCommerce Payment Gateway Icons
- How to Change PayPal Icon On WooCommerce Checkout Page
- How to Create Checkbox Field in WooCommerce Checkout Page
- How to Add Logout Option Menu WooCommerce Storefront Theme [Example]
- How to Auto Approve Orders in WooCommerce
- How to Get Payment Methods in WooCommerce » Code Example
- How to Disable Payment Method for Specific Category
- How to Temporarily Disable Checkout In WooCommerce
- How to Edit Required WooCommerce Checkout Fields
- How to Move WooCommerce Checkout Field
- How to Create WooCommerce Conditional Checkout Fields
- How to Add Custom WooCommerce Payment Icons Checkout Page
- How to Set Up WooCommerce Checkout Field Placeholder
- How to Integrate Stripe With WooCommerce