Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › List of all vendor with info in functions file
- This topic has 6 replies, 2 voices, and was last updated 4 years, 6 months ago by kadsyy.
- AuthorPosts
- June 4, 2020 at 10:21 am #138228kadsyyParticipant
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. - June 4, 2020 at 2:04 pm #138283Sarmistha ChakrabortyMember
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.
- June 4, 2020 at 9:03 pm #138435kadsyyParticipant
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.
- June 5, 2020 at 10:21 pm #138886Sarmistha ChakrabortyMember
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.
- June 6, 2020 at 8:05 am #138983kadsyyParticipant
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.
- June 6, 2020 at 9:11 pm #139109Sarmistha ChakrabortyMember
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
- June 8, 2020 at 10:04 am #139437kadsyyParticipant
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!
- AuthorPosts
- You must be logged in to reply to this topic.