I have been looking for a solution for a while all over internet but couldn't find any proper solution. I am using several custom fields in my product page like, 'Minimum-Cooking-Time', 'Food-Availability' etc. So, I like to show this custom field's value in my cart and checkout page.
I tried snippets in function file and editing woocommerce cart file too. I have tried several codes but they are not pulling any data from my custom fields.
As you can see in the screenshot below, I want to show 'Minimum-Cooking-Time' in that black rectangular area for every product:
I have used the following code:
add_filter( 'woocommerce_get_item_data', 'wc_add_cooking_to_cart', 10, 2 );
function wc_add_cooking_to_cart( $other_data, $cart_item ) {
$post_data = get_post( $cart_item['product_id'] );
echo '<br>';
$Add = 'Cook Time: ';
echo $test;
$GetCookTime = get_post_meta( $post->ID, 'minimum-cooking-time', true );
$GetCookTime = array_filter( array_map( function( $a ) {return $a[0];}, $GetCookTime ) );
echo $Add;
print_r( $GetCookTime );
return $other_data;
}
But, this shows the label 'Cook Time' but not showing any value beside it.
Any help would be appreciated.
Thank you.