I have a WooCommerce shop (running local) but I want to remove the payment gateways. The customer should be able to place an order without paying any cent, I will send them an invoice manually.
I can not really find where to disable this, it seems not to be standard in WooCommerce.
Have tried disabling all the payment gateways in the backend, but you have to leave one payment gateway enabled.
Thanks in advance!
All you have to do is Just copy and paste the code snippet written below in your theme's functions. php file. // Disable all payment gateways on the checkout page and replace the "Pay" button by "Place order" add_filter( 'woocommerce_cart_needs_payment', '__return_false' );
Go to PR menu > Payment Gateways to check if payment method is enabled. Also, Membership field needs to be added when payment gateway is enable on registration form. By looking into your form, payment gateway is disable in your website.
To delete a credit card from your account, go to Purchases → Payment Methods in your profile settings. Under the Manage Your Credit Cards section, click Delete next to any card to delete it.
You can define the default payment gateway by moving it to the top of the list of payment gateways via WooCommerce → Settings → Payments.
Just add this line in functions.php in your theme:
add_filter('woocommerce_cart_needs_payment', '__return_false');
Leave 'Cash on Delivery' enabled, and it won't take a payment at the checkout. You can easily change the 'Cash on Delivery' titles and labels to something like 'No Payment Required' or similar.
Something that the other answers to this question haven't addressed is the fact that you need a way for the customer to eventually pay the invoice. Using Cash on Delivery (renamed to suit your needs) perfectly accomplishes not having the user actually pay at checkout, but the problem is that if Cash on Delivery was your only payment method, it will still be the only payment method when you send them the invoice.
I think in most cases you're going to want only cash on delivery during the cart checkout, and a different payment method (like Stripe) for the invoice payment method.
Here's the full workflow to create a deferred payment setup.
Use the following filter to turn on and off gateways based on whether or not you're on the order-pay
endpoint (the page used for invoice payments).
/**
* Only show Cash on Delivery for checkout, and only Stripe for order-pay
*
* @param array $available_gateways an array of the enabled gateways
* @return array the processed array of enabled gateways
*/
function so1809762_set_gateways_by_context($available_gateways) {
global $woocommerce;
$endpoint = $woocommerce->query->get_current_endpoint();
if ($endpoint == 'order-pay') {
unset($available_gateways['cod']);
} else {
unset($available_gateways['stripe']);
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'so1809762_set_gateways_by_context');
Of course, if you're using a gateway other than stripe for the order-pay
page, you'll want to make sure that you update unset($available_gateways['stripe']);
to the proper array key.
After that, you should be good to go! Your site will now display different gateways based on whether or not you're on the invoice pay page!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With