Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Getting the numbers of registered vendors
Tagged: number, store venders amount, total
- This topic has 3 replies, 2 voices, and was last updated 4 years, 10 months ago by Sushobhan.
- AuthorPosts
- February 26, 2020 at 5:26 pm #108902Steven KuijpersParticipant
Hi there. I want to display the total number of store vendors on my website. So the amount of companies that have a webstore in our marketplace.
What is database entry that I can display? For example to get in a function in functions.php
Thanks!
- February 26, 2020 at 6:37 pm #108913SushobhanKeymaster
Hi,
Thanks for getting in touch.
You can use the following snippet to do that. You can use the shortcode like this[wcfm_vendor_count]
or[wcfm_vendor_count status="active/inactive/all"]
, if you don’t pass status attribute it will show count of active vendors only.function wcfm_vendor_count_shortcode( $attr ) { $status = 'active'; $result = count_users(); $avail_roles = array_merge( array( 'wcfm_vendor' => 0, 'disable_vendor' => 0 ), $result['avail_roles'] ); if ( isset( $attr['status'] ) && in_array( $attr['status'], array('all', 'active', 'inactive') ) ) $status = $attr['status']; if($status === 'inactive') return absint( $avail_roles['disable_vendor'] ); if($status === 'all') return absint( $avail_roles['wcfm_vendor'] ) + absint( $avail_roles['disable_vendor'] ); return absint( $avail_roles['wcfm_vendor'] ); } add_shortcode( 'wcfm_vendor_count', 'wcfm_vendor_count_shortcode' );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Let me know how it goes.
- February 26, 2020 at 6:55 pm #108916Steven KuijpersParticipant
That works perfectly! Thank you.
Did you just write that or was it an existing function. Can I find others like this somewhere?
- February 26, 2020 at 6:57 pm #108917SushobhanKeymaster
Hello,
It is a custom function that I wrote for you 🙂
If there is anything else, you can let me know.
Thanks!
- AuthorPosts
- You must be logged in to reply to this topic.