• Good day

    is it possible to display woocommerce error message and other notification any where with shortcode? If yes, can you provide me with the code please

Viewing 1 replies (of 1 total)
  • Hi there!

    You can display WooCommerce notices (such as error messages, success messages, and other notifications) anywhere using the wc_print_notices() function. However, WooCommerce does not provide a built-in shortcode for this.

    If you’d like to use a shortcode, you can add the following custom code to your theme’s functions.php file or a custom plugin:

    function custom_woocommerce_notices_shortcode() {
    ob_start();
    wc_print_notices();
    return ob_get_clean();
    }
    add_shortcode('woocommerce_notices', 'custom_woocommerce_notices_shortcode');

    I would suggest you use the code snippet plugin to add that code on your site. https://wordpress.org/plugins/code-snippets/

    After adding this, you can use [woocommerce_notices] in your pages or templates to display WooCommerce notices.

    Please note that custom code is outside the scope of our support in this forum. If you need further assistance with implementing this, I can recommend WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the  WooCommerce Community Slack as custom code falls outside our usual scope of support.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.