0

I have an ACF meta custom field in each product called "product_acf_description"

am looking to get it displayed in the cart after the item name and data

what code I should use?

i found the below code from: Add product description to cart items in Woocommerce

it shows the description instead of a custom field, in the correct place and format

add_filter( 'woocommerce_get_item_data', 'customizing_cart_item_data', 10, 2 );
function customizing_cart_item_data( $cart_data, $cart_item ) {
    $description = $cart_item['data']->get_description(); // Get the product description

    // For product variations when description is empty
    if( $cart_item['variation_id'] > 0 && empty( $description ) ){
        // Get the parent variable product object
        $parent_product = wc_get_product( $cart_item['product_id'] );
        // Get the variable product description
        $description = $parent_product->get_description();
    }

    // If product or variation description exists we display it
    if( ! empty( $description ) ){
        $cart_data[] = array(
            'key'      => __( 'Description', 'woocommerce' ),
            'value'    => $description,
            'display'  => $description,
        );
    }
    return $cart_data;
}
Al Suboh
  • 1
  • 1

0 Answers0