[英]Removing payment gateways from WooCommerce
I have a WooCommerce shop (running local) but I want to remove the payment gateways. 我有一个WooCommerce商店(在本地运行),但我想删除支付网关。 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. 我无法真正找到禁用它的地方,它似乎不是WooCommerce的标准。
Have tried disabling all the payment gateways in the backend, but you have to leave one payment gateway enabled. 尝试禁用后端中的所有支付网关,但您必须启用一个支付网关。
Thanks in advance! 提前致谢!
只需在您的主题中的functions.php中添加以下行: 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. 我认为在大多数情况下,您只需要在购物车结帐时使用货到付款,并使用不同的付款方式(如Stripe)进行发票付款方式。
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). 使用以下过滤器根据您是否在order-pay
端点(用于发票付款的页面)打开和关闭网关。
/** * 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']);
当然,如果您在order-pay
页面上使用条带以外的网关,则需要确保更新未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! 您的网站现在将根据您是否在发票付款页面上显示不同的网关!
Other option would be using BACS payment method, where you could explain the client that he will be invoiced later. 其他选择是使用BACS支付方式,您可以向客户解释他将在以后开具发票。
You can even add some info at the email that is sent when BACS is used. 您甚至可以在使用BACS时发送的电子邮件中添加一些信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.