php - Can't display products custom fields under title in Woo commerce Cart section


I have created some custom fields for my product in wocommerce. I want to add those custom fields under title in cart page. This is the code I am using but with no result.

add_filter( 'woocommerce_cart_item_name', 'add_isbn_in_cart', 20, 3);

function add_isbn_in_cart( $title, $values, $cart_item_key ) {

    $custom_isbn = get_post_meta( get_the_ID(), '_isbn_field', true );  
    return $title . $custom_isbn;




get_the_ID() would be returning the ID of the cart page, whereas you need the ID of the product post. You need to get the ID from the$values array.

$custom_isbn = get_post_meta( $values['product_id'], '_isbn_field', true );

People are also looking for solutions to the problem: php - How can i send parameters to translation file in symfony2 validator engine?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.