How to Get Vendor ID?

To get the vendor ID in WC Vendors, it will depend on the object you are querying. For anything that is stored in the wp_posts table, we use the post_author field. For anything related to the vendor, it is stored in the wp_users table.

Post Types

  • Product (product)
  • Vendor Order (shop_order_vendor)
  • Coupon (shop_coupon)
  • Booking (booking)

The following code can be used with any of the above post types or any other post types that have been exposed to the vendor dashboard.

$vendor_id = get_post_field( 'post_author', $post_id ); 

Vendors

$vendor_id = get_current_user_id(); 
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support