Display product optional cost in Woocommerce in order details

You just need this little peace of code to display this warranty option everywhere:

// Save warranty as order item custom meta data and display it everywhere
add_action('woocommerce_checkout_create_order_line_item', 'save_order_item_product_warranty', 10, 4 );
function save_order_item_product_warranty( $item, $cart_item_key, $values, $order ) {
    if( isset($values['warrenty_price']) && $values['warrenty_price'] > 0 ) {
        $key = __("Extra Warrenty", "woocommerce");
        $value = strip_tags( '+ '. wc_price( wc_get_price_to_display( $values['data'], array('price' => $values['warrenty_price']) ) ) );
        $item->update_meta_data( $key, $value );
    }
}

Code goes in function.php file of your active child theme (or active theme). tested and works.

In order received page (and all other order pages):

enter image description here

In admin order pages:

enter image description here

In email notifications:

enter image description here