在Woocommerce结帐页面中为访客用户显示自定义消息 [英] Display a custom message for guest users in Woocommerce checkout page
问题描述
可以在functions.php中使用hook(hack)在woocommerce结帐页面中为访客用户显示自定义消息吗?或者以其他方式?在woocommerce帐户设置中。或在结帐设置标签中启用访客结帐。
,因为停用此选项和来宾选项时。结帐页面上显示一条消息(来自woocommerce语言文件),例如说更改了编辑语言文件。
我将在激活(启用)选项时向访问者显示我的自定义消息。
总结;我的自定义消息将显示给未登录的用户(访客),并为登录的访问者隐藏。
我们将不胜感激。
要在结帐页面上为未登录的用户显示自定义通知:
add_action( 'woocommerce_before_checkout_form','my_custom_message');
函数my_custom_message(){
if(!is_user_logged_in()){
wc_print_notice(__('This is my custom message'),'notice');
}
}
代码会出现在您活跃孩子的function.php文件中主题(或活动主题)。经过测试,可以正常工作。
can use hook (hack) in functions.php show custom message for guest users in woocommerce checkout page? Or from another way?
i need show message when active enabled registration on the checkout page. in woocommerce account settings. or enable guest checkout in checkout settings tab. because when deactivate this option, and guest option. one message show in checkout page (from woocommerce language file) esay change from edit language files.
I would show my custom message to visitors when options is active (enabled). In summary; my custom message show to unlogged users (visitors) and hide for logged visitors.
Any help is appreciated.
To display a custom notice in checkout page for non logged users:
add_action('woocommerce_before_checkout_form', 'my_custom_message');
function my_custom_message() {
if ( ! is_user_logged_in() ) {
wc_print_notice( __('This is my custom message'), 'notice' );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
这篇关于在Woocommerce结帐页面中为访客用户显示自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!