List of all vendor with info in functions file

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!

Viewing 3 reply threads
  • Author
    Posts
    • #138228
      kadsyy
      Participant

      Hi, i’m trying to make a shortcode to list all vendors with some info ( store description and store image) in my functions file.
      I have refer the code from wcfmmp-view-store-lists-card.php but cant seems to get the loop working.

    • #138283

      Hello,

      The loop function is written in “wcfmmp-view-store-lists-loop.php” file. In the “wcfmmp-view-store-lists-card.php” file you will find the vendor data.
      To get vendor banner image –

      $banner_type     = $store_user->get_list_banner_type();
      if( $banner_type == 'video' ) {
      	$banner_video = $store_user->get_list_banner_video();
      } else {
      	$banner          = $store_user->get_list_banner();
      	if( !$banner ) {
      		$banner = !empty( $WCFMmp->wcfmmp_marketplace_options['store_list_default_banner'] ) ? wcfm_get_attachment_url($WCFMmp->wcfmmp_marketplace_options['store_list_default_banner']) : $WCFMmp->plugin_url . 'assets/images/default_banner.jpg';
      		$banner = apply_filters( 'wcfmmp_list_store_default_bannar', $banner );
      	}
      }

      And to get vendor’s description –
      $wcfm_shop_description = apply_filters( 'wcfmmp_store_about', apply_filters( 'woocommerce_short_description', $store_user->get_shop_description() ), $store_user->get_shop_description() );

      You will find the “$store_user” value from “store id/vendor id” –
      $store_user = wcfmmp_get_store( $store_id );

      Thanks.

    • #138435
      kadsyy
      Participant

      Hi, thanks for your reply. I have adjust my code, this is what i get so far

      <?php
      
      function vendor_list_function()
      {
      	global $WCFM, $WCFMmp, $post;
      
      	$store_user      = wcfmmp_get_store($store_id);
      	$store_info      = $store_user->get_shop_info();
      	$store_name      = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'wc-multivendor-marketplace');
      	$store_name      = apply_filters('wcfmmp_store_title', $store_name, $store_id);
      	$store_url       = wcfmmp_get_store_url($store_id);
      	$store_description = $store_user->get_shop_description();
      	$wcfm_shop_description = apply_filters('wcfmmp_store_about', apply_filters('woocommerce_short_description', $store_user->get_shop_description()), $store_user->get_shop_description());
      
      ?>
      	<div class="wcfmmp-stores-content-holder">
      		<div class="wcfmmp-stores-content">
      
      			list vendor with info
      			<ul class="wcfmmp-store-wrap">
      				<?php
      				foreach ($store_user as $store_id) {
      					$args['store_id'] = $store_id;
      					echo '<li> name: '. $store_name . '</li>';
      					echo '<li> address: '. $store_address . '</li>';
      					echo '<li> url: '. $store_url. '</li>';
      					echo '<li> description: '. $wcfm_shop_description  . '</li>';
      					echo '=================';
      				}
      				?>
      				<div class="wcfm-clearfix"></div>
      			</ul>
      		</div>
      	</div>
      
      <?php }
      add_shortcode('vendor_list_test', 'vendor_list_function');

      unfortunately the loop give incorrect and empty data. i know this code got a lot of problems since im totally newbie in php. i hope u dont mind walk me thru this. thanks again.

    • #138886

      Hello,

      The shortcode which you have written is not correct. May we know the purpose why you want to create another shortcode to display store lists, we have already “[wcfm_stores]” this shortcode which will display all store lists.

      Thanks.

      • #138983
        kadsyy
        Participant

        Because i want to make several customizations on the listing. i know i can copy the template file from’views/store-list/’ folder and put in my theme but it will affect to all “[wcfm_stores]” shortcode right?

        i believe i can add another css style and define it in the template file but what if i want to change the layout which involve changing some divs etc?

        is there a way i can make another theme/template for “[wcfm_stores]” shortcode? this is basically my purpose for the shortcode i written.

        Thanks.

        • #139109

          Hi,

          Okay! understand.
          This is not possible using code snippet.
          It requires some custom development, and this will be a paid one.

          We can guide you, but it will need PHP knowledge for implementation.
          Please check these file class-wcfmmp-shortcode.php(function name : wcfmmp_stores_shortcode) and “store-lists” folder files(under views) , here you can see how we have created this “[wcfm_stores]” shortcode, and follow the code to create your custom shortcode.

          Thank You

          • #139437
            kadsyy
            Participant

            Hi,

            Letting u know that i successfully created the custom shortcode. thank you so much for pointing out the ‘class-wcfmmp-shortcode.php(function name : wcfmmp_stores_shortcode)’ file. It’s really helped a lot. I cant thank you enough i wish i can give u a hug. Thanks again and u have a great day ahead!

Viewing 3 reply threads
  • You must be logged in to reply to this topic.