questions

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

Rate this post

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
}

 

✔️Solution:

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.

Leave a Reply

Your email address will not be published.

Back to top button