wordpress - WooCommerce 登录“以访客身份继续”按钮网关
问题描述
我有这串代码可以更改默认的 WooCommerce 结帐行为,当一个人在购物车中并单击“继续结帐”时,它会将他们重定向到 WooCommerce“我的帐户”登录页面。然后他们登录并重定向到结帐页面。我的问题是是否有一种方法可以实现这种行为,但允许人们通过在“以访客身份继续”的表单中添加一个按钮来绕过登录。所以客户可以在登录页面点击这个按钮,绕过确保客户登录的代码。
谢谢您的帮助!!!
add_action('template_redirect','check_if_logged_in');
function check_if_logged_in()
{
$pageid = 48; // your checkout page id
if(!is_user_logged_in() && is_page($pageid))
{
$url = add_query_arg(
'redirect_to',
get_permalink($pagid),
site_url('/account/') // your my acount url
);
wp_redirect($url);
exit;
}
if(is_user_logged_in())
{
if(is_page(50))//my-account page id
{
$redirect = $_GET['redirect_to'];
if (isset($redirect)) {
echo '<script>window.location.href = "'.$redirect.'";</script>';
}
}
}
}
解决方案
推荐阅读
- android - 如何从 XML 文件中选择特定元素?
- bash - 如何在 bash 脚本中将 STDOUT 发送到一个文件并将 STDOUT+STDERR 发送到另一个文件?
- node.js - 为什么此代码给出参考错误:db is not defined
- apache-spark - 如何在 spark 数据框中创建唯一的自动生成的 Id 列
- javascript - 如何从字符串开头删除下划线
- xpages - IBM Lotus - 更新房间预订,房间名称每次都附加到 LOCATION
- javascript - 无法导入 ES6 模块
- angular - Angular:按计数创建两列
- haskell - 未能捕获“纯”函数引发的异常
- python - 如何组织已下订单