Show product custom field in the wishlist items table

Sometimes your products have custom fields that do not get displayed in the wishlist items table when the products are shown. In order to display these custom fields so that your customers can see them, you need to add a little code.

The example below shows how to add a product custom field below the title of the items in the table. The custom fields can however be added anywhere on the table you want, with the right action hook.

/**
 * Show a product custom field below the product title in the
 * wishlist items table
 *
 * @param array $args Arguments supplied to the template
 */
function my_nmgr_show_item_custom_field( $args ) {
	// The wishlist item object is usually in the $args array, let's get it
	$item = $args[ 'item' ];

	// Then let's get the product from the wishlist item
	$product = $item->get_product();

	// Then we can get the custom field from the product
	// For simplicity, let's just assume here that the custom field is the product price
	$custom_field = $product->get_price();

	// Now let's display the custom field
	echo '<div>' . __( 'Custom field - price: ' ) . esc_html( $custom_field ) . '</div>';
}

add_action( 'nmgr_item_view_after_title', 'my_nmgr_show_item_custom_field' );