WooCommerce: Show Product Weight in Admin Order Item Meta

For a weight based eCommerce store, when viewing WooCommerce order items, the admin may want to have the total weight of the individual items. In this tutorial, we are going to show how to add product weight in admin order item meta.

Show product weight in admin order item meta
Show product weight in admin order item meta

PHP Snippet: Show woocommerce product weight in admin order item meta

<?php
/**
 * @snippet		Show product weight in admin order item meta
 * @author		Anjan Phukan
 * @testedWith	WooCommerce 4.4.1
 * @tutorial	https://www.zealopers.com/woocommerce-tutorials/woocommerce-show-product-weight-in-admin-order-item-meta/
 */

add_action( 'woocommerce_after_order_itemmeta', 'zlp_show_weight_admin_order_item_meta', 10, 3 );

function zlp_show_weight_admin_order_item_meta( $item_id, $item, $product ) {
	
	// IF PRODUCT OR IT'S VARIATION HAS WEIGHT
	if($product->get_weight()){ ?>
		<table cellspacing="0" class="display_meta">
			<tbody>
				<tr>
					<th><?php _e( 'Total Weight:' ); ?></th>
					<td><p><?php echo ($item->get_quantity())*($product->get_weight())." ".get_option('woocommerce_weight_unit'); ?></p></td>
				</tr>
			</tbody>
		</table>
	<?php }
} 
To Customize the order meta box, we need to use the woocommerce hook called woocommerce_after_order_itemmeta. If you need more information on this hook then you can visit this link.

Where to add this snippet?

You can place this PHP snippet at the end of your child theme’s functions.php file. Please make sure you know what you are doing and take a backup of the file before making any changes.

Did it work for you?

Please let us know in the comments section below if the tutorial was helpful to you and the codes worked out for you as anticipated. The code was tested with Woocommerce version listed above.

Did it save your time and money? Please feel free to share it and/or Like us our Facebook Page.

Feel free to contact us if you need help to implement this.

Share this post:
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments