wordpress 从 WooCommerce 中删除支付网关
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16729643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing payment gateways from WooCommerce
提问by Arko Elsenaar
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.
我有一家 WooCommerce 商店(在本地运营),但我想删除支付网关。客户应该能够下订单而无需支付任何费用,我将手动向他们发送发票。
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!
提前致谢!
回答by Mateusz Paulski
Just add this line in functions.php in your theme:
add_filter('woocommerce_cart_needs_payment', '__return_false');
只需在您的主题中的functions.php 中添加这一行:
add_filter('woocommerce_cart_needs_payment', '__return_false');
回答by crdunst
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.
启用“货到付款”,它不会在结账时付款。您可以轻松地将“货到付款”的标题和标签更改为“无需付款”或类似内容。
回答by Pete
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 onlypayment method, it will stillbe 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 cartcheckout, and a different payment method (like Stripe) for the invoice payment method.
我认为在大多数情况下,您在购物车结账时只需要货到付款,以及发票付款方式的不同付款方式(如 Stripe)。
Here's the full workflow to create a deferred payment setup.
这是创建延期付款设置的完整工作流程。
- Like @crdunst mentions, you should use Cash on Delivery and rename it to "Wait for Invoice" or something.
- Enable all of the payment gateways that you ever want to use (in this example, we'll just use Cash on Delivery and Stripe. Cash on Delivery will be our "checkout" payment gateway, and Stripe will be our invoice payment gateway.
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');
- 就像@crdunst 提到的那样,您应该使用货到付款并将其重命名为“等待发票”或其他名称。
- 启用您想要使用的所有支付网关(在此示例中,我们将只使用货到付款和 Stripe。货到付款将是我们的“结帐”支付网关,而 Stripe 将是我们的发票支付网关。
根据您是否在
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']);
to the proper array key.
当然,如果您为order-pay
页面使用条带以外的网关,您需要确保更新unset($available_gateways['stripe']);
到正确的数组键。
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!
在那之后,你应该很高兴!您的站点现在将根据您是否在发票支付页面上显示不同的网关!
回答by Gabriel Reguly
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 时发送的电子邮件中添加一些信息。