WooCommerce add custom notice to cart

Last Updated:September 2, 2023

How can you show custom notice above the cart?

Add the following code to functions.php

function display_custom_message_in_cart() {
    $custom_message = WC()->session->get('cart_custom_message');
    if ($custom_message) {
        echo '<p class="custom-message">Custom Message: ' . esc_html($custom_message) . '</p>';
    }
}
add_action('woocommerce_before_cart', 'display_custom_message_in_cart');