WooCommerce 仅显示登录客户的支付网关 [英] WooCommerce Show Payment Gateways for Logged In Customers Only

查看:45
本文介绍了WooCommerce 仅显示登录客户的支付网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Wordpress 和 WooCommerce 建立一个电子商务网站.我们正在使用 wordpress 会员帐户来跟踪客户信息,我们需要一种方法登录会员才能选择信用"购买他们的购物车,这意味着无需付款命令.基本上我所做的是劫持检查"选项(因为我们在其他任何地方都不需要它)并将其重命名为信用",因为它允许我们需要的功能.

I am setting up an ecommerce site using Wordpress and WooCommerce. We are using the wordpress member accounts to track customer information, and we need a way for logged in members only to be able to choose to purchase their cart "on credit", meaning no payment is required to place the order. Basically what I have done is hi-jacked the "Check" option (since we don't need it anywhere else) and renamed it "Credit" since it allows for the functionality we need.

但是,我需要一种方法让信用"(检查)选项仅在用户登录时显示.如果用户未登录,有什么方法可以取消"此选项?这似乎很容易做到,但我找不到任何关于它的信息.任何帮助表示赞赏.

However, I need a way for the "Credit" (check) option to only display if the user is logged in. Is there any way I can just "unhook" this option if the user isn't logged in? This seems like something that would be easy to do, but I couldn't find anything about it. Any help is appreciated.

推荐答案

我刚刚找到了解决方案.在 class-wc-cheque.php 文件中,使用 add_filter('woocommerce_payment_gateways', 'add_cheque_gateway' ); 挂钩支票或支票"(疯狂英国人)选项.所以解决方案只是将此代码添加到我的 functions.php 文件中:

I just found the solution. In the class-wc-cheque.php file, the check or "cheque" (crazy brits) option is hooked using add_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );. So the solution was simply to add this code to my functions.php file:

 if(!is_user_logged_in()){
     remove_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );
 }

希望这会有所帮助!

这篇关于WooCommerce 仅显示登录客户的支付网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆