Display a custom message for guest users in Woocommerce checkout page

左心房为你撑大大i 提交于 2019-12-01 11:18:51

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/51126758/display-a-custom-message-for-guest-users-in-woocommerce-checkout-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!