我使用以下代码在结账页面上向未登录的 WooCommerce 用户(访客)显示自定义消息。
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' );
}
}
这个论坛上的问题由@loictheaztec先生提出,与IT技术有关。我的之前的问题链接如下:
在Woocommerce结账页面为访客用户显示自定义消息
我想在代码中更改 woocommerce_before_checkout_form ,将我的消息移动到结账页面的顶部(第一行)。但是我不知道该如何做。 我只知道以下两个挂钩(与结账页面相关):
woocommerce_before_checkout_form
woocommerce_after_checkout_form