Remove login form (and registration) on WooCommerce checkout page(删除WooCommerce结账页面上的登录表(和注册))
问题描述
我正在尝试从WordPress的WooCommerce插件中删除结账时的登录和注册 我试着为客人结账,但不起作用 我尝试了此代码
remove_action( 'woocommerce_before_checkout_form', $checkout );
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ) );
return;
}
当我注释If Condition Then时,它会打开结账表单,但当我单击Place Order时,它会显示以下错误:
"创建帐户密码是必填字段。帐户用户名是必填字段。"
我做错了什么?欢迎任何帮助。
推荐答案
要从WooCommerce结账中删除登录表单,请使用:
// Remove login form from checkout
add_action( 'woocommerce_before_checkout_form', 'remove_checkout_login_form', 4 );
function remove_checkout_login_form(){
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
}
要从WooCommerce结账中删除注册,只需使用:
add_filter( 'woocommerce_checkout_registration_enabled', '__return_false' );
这两个代码片段都放在活动子主题(或活动主题)的函数.php文件中。已测试并正常工作。
这篇关于删除WooCommerce结账页面上的登录表(和注册)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!