Vendor Product Shortcode for "current ID"

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #121292
      hallo-7405
      Participant

      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

    • #121405

      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 page

      add_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 in wc-multivendor-marketplace/views/store folder

      Thanks.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.