Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Get all bookings/products for a vendor
- This topic has 5 replies, 2 voices, and was last updated 5 years, 10 months ago by WCFM Forum.
- AuthorPosts
- January 25, 2019 at 4:20 pm #45194hello4Participant
Hello there,
What’s the best way to obtain all bookings for the logged in vendor? For WC Product Vendors, I use the following to get product ids first and then retrieve bookings through those:
//Get all product ids for the logged in vendor
$product_ids = WC_Product_Vendors_Utils::get_vendor_product_ids();Could you kindly help me with the WCMM equivalent to get either all bookings or products for the logged in vendor?
Many thanks in advance!
- January 26, 2019 at 6:57 am #45259WCFM ForumMember
Hi,
$product_ids = WC_Product_Vendors_Utils::get_vendor_product_ids();
Well, this code will give you products, not bookings.
Which you are looking for products or bookings?
Well, WCFM has a function like this, that can be use like this –
global $WCFM; $products_list = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor( $vendor_id, apply_filters( 'wcfm_limit_check_status', 'any' ), array( 'suppress_filters' => 1 ) );
First argument – Vendor ID
Second Argument – Product Status
Third Argument – Tweak any argument for WP “get_posts” function – https://codex.wordpress.org/Template_Tags/get_posts, or just do not pass thisThank You
- January 26, 2019 at 12:56 pm #45301hello4Participant
Hello there,
Thanks for the reply. What I am trying to do is to get a list of all booking IDs for a given vendor (currently logged in vendor). With WC Product Vendors what I did was: I took all product ids of the vendor first, and then checked all orders ids raised against those items and finally got the booking ids using those order ids.
I can do the same for WCMM using the function you’ve given but in order to do that, how can I get the vendor id of the currently logged in user? Or is there a quicker way to get all bookings of the logged in vendor?
Thanks and regards,
- January 26, 2019 at 2:41 pm #45328WCFM ForumMember
Hi,
Just use this code, it will give you logged in vendor’s bookings ids –
$vendor_bookings = apply_filters( 'wcfm_wcb_include_bookings', '' );
Thank you
- January 26, 2019 at 5:56 pm #45356hello4Participant
It worked! Many thanks!
Just a suggestion. Maybe you can host a snippets site similar to other plugins on github or somewhere with all these useful code snippets so we can search there before troubling you guys in here.
Best regards,
- January 27, 2019 at 8:10 am #45397WCFM ForumMember
Hi,
Great … you are welcome 🙂
Well, we are already working on that part.
Thank You
- AuthorPosts
- The topic ‘Get all bookings/products for a vendor’ is closed to new replies.