问题
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