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

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on Twitter