I am trying to get the custom field value of a WooCommerce product to display on different pages of the shop system. I succeeded to do so for the single product page, but the same code doesn't work for the cart.
For the single product I used this code within the functions.php, which works fine:
global $post;
echo '<p>' . get_post_meta($post->ID, 'my-custom-field', true) . '</p>';
I tried the same code for the cart, but this time the values don't show on the page. I also referred to this thread (Woocommerce getting custom attributes), changing $post to $product, but still no output...
Any suggestions?