Additional Order Details on the “View Order” and “Thank You” Pages

Below is the example of additional fields on the My Account > Orders > View Order page with active Storefront theme.

Additional order details on the View Order page.

woocommerce_view_order action hook is for the View Order page, woocommerce_thankyou is for the Order Received page. The code for your functions.php below.

add_action( 'woocommerce_thankyou', 'misha_view_order_and_thankyou_page', 20 );
add_action( 'woocommerce_view_order', 'misha_view_order_and_thankyou_page', 20 );

function misha_view_order_and_thankyou_page( $order_id ){  ?>
    <h2>Gift Order</h2>
    <table class="woocommerce-table shop_table gift_info">
                <th>Is gift?</th>
                <td><?php echo ( $is_gift = get_post_meta( $order_id, 'is_gift', true ) ) ? 'Yes' : 'No'; ?></td>
            <?php if( $is_gift ) : ?>
                <th>Gift Wrap</th>
                <td><?php echo get_post_meta( $order_id, 'gift_wrap', true ); ?></td>
                <th>Recipient name</th>
                <td><?php echo get_post_meta( $order_id, 'gift_name', true ); ?></td>
                <th>Gift message</th>
                <td><?php echo wpautop( get_post_meta( $order_id, 'gift_message', true ) ); ?></td>
            <?php endif; ?>
<?php }

If the order is not marked as a gift, the Gift Wrap, Recipient name and Gift Message fields won’t be displayed.

Misha Rudrastyh

Misha Rudrastyh

I develop websites since 2008, so it is total of 13 years of experience, oh my gosh. Most of all I love love love to create websites with WordPress and Gutenberg, some ideas and thoughts I share throughout my blog.

Need some developer help? Contact me

Follow me on Twitter