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

In the first post of this series we added our own custom checkout fields, in the second post we customized Order Details metabox in admin area. Today we’ll add order custom fields to user pages: Order Received page and View Order page in My Account.


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.

More about Order Meta

Misha Rudrastyh

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 10 yrs of experience.

Need some custom developer help? Let me know

Follow Misha

Need some help with WooCommerce?

If you need some professional developer help, I will be happy to assist you.

Contact me Who I am?

Comments — 5

Leave a comment

php js HTML CSS Code