• Resolved lidiyam

    (@lidiyam)


    Hi,

    I have created one custom field in dokan registeration as gst no. The gst number is storing in user_meta table. Now my question is how to send that particular product’s vendor gst no in invoice.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    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!

    Thread Starter lidiyam

    (@lidiyam)

    Hi,

    Thanks a Lot. It’s worked for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to send seller GST NO in invoice?’ is closed to new replies.