Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Remove Payment Gateways From WooCommerce?

WooCommerce offers a variety of payment gateways to facilitate online transactions. However, for businesses that primarily offer express store pickup as their only delivery method, displaying all available payment gateways can create unnecessary complexity and confusion for customers. In such cases, it is better to remove all payment gateways as store owners prefer to accept cash as a payment method for local pickup items.

This post will help you to remove payment gateways from the WooCommerce checkout page.

Where to Add Custom Code in WooCommerce?

It is advisable to add the code snippets to the functions.php file of your child theme. Access the file directly from Appearance->Theme File Editor->Locating the child theme’s functions.php from the right sidebar. You can also access it from your theme’s directory file. Insert the following code snippet in functions.php. The alternative & easy option is to install & activate the Code Snippets plugin. You can then add the code as a new snippet via the plugin.

Solution: Remove the Payment Gateways From WooCommerce

Consider an online clothing store that primarily serves customers in its local area. They offer local pickup as the only shipping method and want to prevent customers from trying to pay online for their orders. With the below snippet, you can able to remove the payment gateways from WooComerce.

 add_filter('woocommerce_cart_needs_payment', '__return_false');

Output

When the customer adds a product to their cart and proceeds to checkout, the payment gateways are removed from the Checkout WooCommerce page.

How to Remove Payment Gateways From WooCommerce? - Tyche Softwares
How to Remove Payment Gateways From WooCommerce? - Tyche Softwares

Easily Set Fees & Discounts For Payment Gateways

Finding it difficult to manage all payment gateway fees and adjusting your product pricing accordingly?

The Payment Gateway Based Fees & Discounts plugin is designed to set up fees & discounts for each of your payment modes and simplify your payment process.

Code Explanation

Let’s break down the snippet to understand its purpose:-

  • add_filter: This function is used to add a filter to a specific hook.
  • woocommerce_cart_needs_payment‘: This is the hook to which the filter is being added. In WooCommerce, hooks are points in the code where you can add your own custom code. The woocommerce_cart_needs_payment hook is typically used to determine whether the cart needs payment or not.
  • __return_false: This is a special function that simply returns the value false. In the context of filters, using __return_false means that the original value that the filter is modifying will be replaced with false.

Conclusion

This code snippet can simplify the checkout process for local pickup orders. And, if your store offers other shipping methods, you can enable/disable a specific payment method based on certain conditions such as disable payment method for specific category @WooCommerce checkout or enable a WooCommerce payment method when the order total is above a certain value.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x