How to display a custom product field value of a specific category on a Woo Commerce checkout page?

Try something like this, I am unable to test this at the moment.

add_action('woocommerce_before_calculate_totals', 'personalization_check_category_in_cart');

function personalization_check_category_in_cart() {
    // loop through all products in the Cart        
    foreach (WC()->cart->get_cart() as $cart_item) {
        // if cart has category term, set variable $cat_in_cart to true
        if (has_term( 'Personalize', 'product_cat', $cart_item['product_id'])) {
            $product = $cart_item['data']; // get product data
            $product_id = $product->get_id(); // get product ID
            $note = get_post_meta( $product->get_id(), 'product_personalization_note', true ); // get meta
            echo '<div class="checkout-personalization-message-container"><p>' . $note . '</p></div>';
        }
    }
}

error code: 523