简体   繁体   中英

How do insert/execute a shortcode within a wc_add_notice box?

I'm trying to add a shortcode into a wc_add_notice box. Please can someone show me how to do this, or indicate an alternative route which suits the usage.

Below is two pieces of code, one is the notice box, the other is an echo with the shortcode inside.

The end goal is to have a button inside the notice, which when clicked opens up a plugins popup sign up form.

Thanks,

wc_add_notice( __( 'Please Sign Up or Login', 'my-plugin ' ) );
    
<?php echo do_shortcode(' [arm_form id="102" logged_in_message="You are already logged in." popup="true" " link_title="Sign In/Signup to Enter" link-type="onload"] </body></html>'); ?>
<?php
}

Try instead the following (if your shortcode displays a button) :

$message = __( 'Please Sign Up or Login', 'my-plugin ' ) . do_shortcode('[arm_form id="102" logged_in_message="You are already logged in." popup="true" " link_title="Sign In/Signup to Enter" link-type="onload"]');

wc_add_notice( $message );

It could work. You will have to make your button float right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM