Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Vendor Product Shortcode for "current ID"
Tagged: shortcodes
- This topic has 1 reply, 2 voices, and was last updated 4 years, 8 months ago by Sarmistha Chakraborty.
- AuthorPosts
- April 21, 2020 at 2:27 pm #121292hallo-7405Participant
Hi there,
I bet this question already came up, but I couldn’t find the exact solution.
I’m not that keen on the current Vendor Tab Widget since I’d like to have a little more flexibility instead of “dropping the whole in on package”.
So I already know that the is the [products] shortcode and that you can filter this by adding the vendor’s ID.
But is there a way to let the shortcode automatically pick the “current” ID of the Vendor’s page you are visiting right now?
If that works, I would also be interested if there were the same Shortcodes for the Vendor’s “about” text, policies etc.
So basically all the items from the tab-widget, just separately.Thanks!
Tobias
- April 21, 2020 at 7:41 pm #121405Sarmistha ChakrabortyMember
Hello,
By-default we don’t have shortcode like this. But you can use this shortcode “[wcfm_store_info id=”” data=””]” for some vendor data.https://wclovers.com/knowledgebase/wcfm-marketplace-widgets-short-codes/
This requirement needs custom development.
Suppose for vendor’s product, using this shortcode([wcfm_store_related_products]) you will get vendor’s product in vendor’s store pageadd_shortcode('wcfm_store_related_products','fn_wcfm_store_related_products'); function fn_wcfm_store_related_products($attr) { global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post; $store_id = ''; if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); } if ( wcfm_is_store_page() ) { $wcfm_store_url = get_option( 'wcfm_store_url', 'store' ); $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) ); $store_id = 0; if ( !empty( $store_name ) ) { $store_user = get_user_by( 'slug', $store_name ); } $store_id = $store_user->ID; } if( is_product() ) { $store_id = $post->post_author; } if( !$store_id && is_single() && $post && is_object( $post ) && wcfm_is_vendor( $post->post_author ) ) { $store_id = $post->post_author; } echo do_shortcode('[products store="'.$store_id.'"]'); }
Add this above code in your functions.php.
Likewise you need to create shortcode for “about” text, policies etc. You will find the code how get values from vendor id-
files inwc-multivendor-marketplace/views/store
folderThanks.
- AuthorPosts
- You must be logged in to reply to this topic.