• I have a question about displaying the Notices in a custom wrapper on my page.

    In the past I populated my wrapper with this PHP:
    <div class:"my-wrapper">
    <?php woocommerce_output_all_notices(); ?>
    </div>

    This approach doesn’t seem to work anymore on new sites with the introduction of the WC Blocks.

    Do you have any suggestions on how I can handle this with the new WC version?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @heinperu,

    With the introduction of WooCommerce Blocks, there have been some changes in how notices are handled. The function woocommerce_output_all_notices() may not work as expected.

    Instead, you can use the ‘Notice’ block provided by WooCommerce Blocks. You can add this block to your page, and it will automatically display any store notices.

    Let us know if this helps!

    Thread Starter heinvv

    (@heinperu)

    How can I add the ‘Notice’ block to my page programmatically? Do you have any code examples for that?
    I would like to create a container element inside my plugin, that will be populated with the Cart and Checkout notices.

    Zee

    (@doublezed2)

    Hello heinvv

    Thank you for your reply.

    For displaying WooCommerce notices within your plugin’s container element, you can refer to the wc_print_notices() function. This function is designed to output any queued notices, which would include Cart and Checkout notices.

    Please keep in mind that, as per our guidelines at WooCommerce, we do not provide direct support for custom coding solutions.

    If you have further questions about WooCommerce features or need assistance with something else, feel free to reach out. 🙂

    Best regards.

    Thread Starter heinvv

    (@heinperu)

    Hi Zubair,

    I don’t think this function still works with the introduction of the WooCommerce Blocks. I think we will need a JavaScript approach now.

    Plugin Support Shameem – a11n

    (@shameemreza)

    Hi @heinperu,

    You are correct; with the introduction of WooCommerce Blocks, the handling of notices has shifted more towards a JavaScript approach.

    For reference, these particular forums are meant for general support with the core functionality of WooCommerce itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question.

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.

    Thread Starter heinvv

    (@heinperu)

    Hi @shameenreza,

    I was mistaken. I realized that the Notice template are still being rendered with PHP and that the old code is still functioning.

    I have asked in the slack channel if there is a straight forward PHP approach to check which Notice template is being used.

    Zee

    (@doublezed2)

    Hello heinvv

    Thank you for your reply.

    I am glad to know that you were able to find the right direction.
    Interacting on the Slack channel for further assistance is a good move and I hope you will find a solution.

    Please don’t hesitate to contact us again if you have more questions or concerns. We are here to help. 🙂

    Best regards.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Display Notices within a custom wrapper element’ is closed to new replies.