Hi! We have some examples on retrieving user meta in the documentation here: Displaying user data. However, this assumes that the user data needs to be retrieved from the customers profile, if I understand correctly you want to retrieve it from the vendor’s profile… That’s a bit more complex because 1) you need to get the user ID for the vendor first and 2) orders can have multiple vendors.
I think this should get you on track:
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_dokan_vendor_meta', 10, 2 );
function wpo_wcpdf_dokan_vendor_meta ($template_type, $order) {
// dokan_get_seller_id_by_order returns 0 (='empty')when an order has multiple vendors
// seller ID is the WP User ID
$seller_id = dokan_get_seller_id_by_order( $order->get_id() );
if ( !empty($seller_id) ) {
$meta_key = '_custom_field'; // change this to your meta key / custom field name
$custom_field = get_user_meta( $seller_id, $meta_key, true );
?>
<tr class="custom-user-meta">
<th>GST no:</th>
<td><?php echo $custom_field; ?></td>
</tr>
<?php
}
}
Hope that helps!