Wc Multivendor Marketplace Shortcodes

Below, you’ll find a detailed guide on how to add the Wc Multivendor Marketplace Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Wc Multivendor Marketplace Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Wc Multivendor Marketplace Plugin and the shortcodes it provides:

Plugin Icon
WCFM Marketplace – Best Multivendor Marketplace for WooCommerce

"WCFM Marketplace is a top-rated multivendor marketplace plugin for WooCommerce. It enables easy and efficient management of your online store, enhancing your eCommerce experience."

★★★★☆ (410) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [wcfm_stores]
  • [wcfm_stores_map]
  • [wcfm_stores_carousel]
  • [wcfm_store_sold_by]
  • [wcfm_store_info]
  • [wcfm_store_hours]
  • [wcfm_shipping_time]
  • [wcfm_more_offers]
  • [wcfm_store_fb_feed]
  • [wcfm_store_twitter_feed]
  • [wcfm_products_store_filter]
  • [fee]

Wc Multivendor Marketplace [wcfm_stores] Shortcode

The wc-multivendor-marketplace plugin shortcode is responsible for displaying a list of all stores on a page. It provides several customization options, such as the number of stores per page, search functionality, and various filter options.

Shortcode: [wcfm_stores]

Parameters

Here is a list of all possible wcfm_stores shortcode parameters and attributes:

  • per_page – number of stores displayed on each page
  • sidebar – enable or disable the sidebar
  • orderby – determines the store display order
  • filter – enable or disable the filter option
  • search – enable or disable the search option
  • category – enable or disable the category filter
  • country – enable or disable the country filter
  • state – enable or disable the state filter
  • radius – enable or disable the radius filter
  • map – enable or disable the map display
  • map_zoom – set the default zoom level of the map
  • auto_zoom – enable or disable automatic zoom
  • per_row – set the number of stores displayed per row
  • includes – specify included stores
  • excludes – specify excluded stores
  • include_membership – include stores with certain memberships
  • exclude_membership – exclude stores with certain memberships
  • search_term – predefine a search term
  • search_country – predefine a country for search
  • search_state – predefine a state for search
  • search_city – predefine a city for search
  • search_zip – predefine a zip code for search
  • search_category – predefine a category for search
  • search_radius_range – predefine a radius range for search
  • search_radius_lat – predefine a latitude for radius search
  • search_radius_lng – predefine a longitude for radius search
  • store_category – predefine a store category
  • theme – set the theme of the store list
  • has_orderby – enable or disable the order by option
  • has_product – filter stores that have products
  • has_sidebar – enable or disable the sidebar
  • has_filter – enable or disable the filter
  • has_search – enable or disable the search
  • has_category – enable or disable the category
  • has_country – enable or disable the country
  • has_state – enable or disable the state
  • has_city – enable or disable the city
  • has_zip – enable or disable the zip code
  • has_radius – enable or disable the radius
  • has_map – enable or disable the map

Examples and Usage

Basic example – Displaying the default store list with 12 items per page and a sidebar.

[wcfm_stores]

Advanced examples

Displaying the store list with 20 items per page, without a sidebar, ordered by newness in descending order, and with search and filter options disabled.

[wcfm_stores per_page="20" sidebar="no" orderby="newness_desc" filter="no" search="no"]

Displaying the store list with 10 items per page, with a sidebar, ordered by newness in ascending order, and with search and filter options enabled. Additionally, it only includes stores with specific membership IDs and excludes stores with other specific membership IDs.

[wcfm_stores per_page="10" sidebar="yes" orderby="newness_asc" filter="yes" search="yes" include_membership="1,2,3" exclude_membership="4,5,6"]

Displaying the store list with 15 items per page, without a sidebar, ordered by newness in descending order, and with search and filter options disabled. Additionally, it only includes specific stores and excludes other specific stores.

[wcfm_stores per_page="15" sidebar="no" orderby="newness_desc" filter="no" search="no" includes="1,2,3" excludes="4,5,6"]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_stores] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_stores', array(&$this, 'wcfmmp_stores_shortcode'));

Shortcode PHP function:

function wcfmmp_stores_shortcode( $atts ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $includes;
		$WCFM->nocache();
		
		$defaults = array(
			'per_page'           	=> 12,
			'sidebar'            	=> 'yes',
			'orderby'            	=> 'newness_asc',
			'filter'             	=> 'yes',
			'search'             	=> 'yes',
			'category'           	=> 'yes',
			'country'            	=> 'yes',
			'state'              	=> 'yes',
			'radius'             	=> 'yes',
			'map'                	=> 'yes',
			'map_zoom'           	=> 5,
			'auto_zoom'          	=> 'yes',
			'per_row'            	=> 3,
			'includes'           	=> '',
			'excludes'           	=> '',
			'include_membership' 	=> '',
			'exclude_membership' 	=> '',
			'search_term'        	=> '',
			'search_country'     	=> '',
			'search_state'       	=> '',
			'search_city'        	=> '',
			'search_zip'         	=> '',
			'search_category'    	=> '',
			'search_radius_range' 	=> '',
			'search_radius_lat' 	=> '',
			'search_radius_lng' 	=> '',
			'store_category'     	=> '',
			'theme'              	=> 'classic',
			'has_orderby'        	=> 'yes',
			'has_product'        	=> 'no',
			'has_sidebar'        	=> 'yes',
			'has_filter'         	=> 'yes',
			'has_search'         	=> 'yes',
			'has_category'       	=> 'yes',
			'has_country'        	=> 'yes',
			'has_state'          	=> 'yes',
			'has_city'           	=> 'no',
			'has_zip'            	=> 'no',
			'has_radius'         	=> 'yes',
			'has_map'            	=> 'yes',
		);

		$attr   = shortcode_atts( apply_filters( 'wcfmmp_stores_default_args', $defaults ), $atts );
		$paged  = max( 1, get_query_var( 'paged' ) );
		$length = apply_filters( 'wcfmmp_stores_per_page', $attr['per_page'] );
		$offset = ( $paged - 1 ) * absint( $length );
		
		$search_country = isset( $attr['search_country'] ) ? $attr['search_country'] : '';
		$search_state   = isset( $attr['search_state'] ) ? $attr['search_state'] : '';
		
		// GEO Locate Support
		if( apply_filters( 'wcfmmp_is_allow_store_list_by_user_location', true ) ) {
			if( is_user_logged_in() && !$search_country ) {
				$user_location = get_user_meta( get_current_user_id(), 'wcfm_user_location', true );
				if( $user_location ) {
					$search_country = $user_location['country'];
					$search_state   = $user_location['state'];
				}
			}
					
			if( apply_filters( 'wcfm_is_allow_wc_geolocate', true ) && class_exists( 'WC_Geolocation' ) && !$search_country ) {
				$user_location = WC_Geolocation::geolocate_ip();
				$search_country = $user_location['country'];
				$search_state   = $user_location['state'];
			}
		}

		$orderby          = isset( $_GET['orderby'] ) ? sanitize_sql_orderby( $_GET['orderby'] ) : apply_filters( 'wcfmmp_stores_default_orderby', $attr['orderby'] );
		$search_term      = isset( $_GET['wcfmmp_store_search'] ) ? sanitize_text_field( $_GET['wcfmmp_store_search'] ) : $attr['search_term'];
		
		$search_country   = isset( $_GET['wcfmmp_store_country'] ) ? sanitize_text_field( $_GET['wcfmmp_store_country'] ) : '';
		$search_state     = isset( $_GET['wcfmmp_store_state'] ) ? sanitize_text_field( $_GET['wcfmmp_store_state'] ) : '';
		$search_city      = isset( $_GET['wcfmmp_store_city'] ) ? sanitize_text_field( $_GET['wcfmmp_store_city'] ) : $attr['search_city'];
		$search_zip       = isset( $_GET['wcfmmp_store_zip'] ) ? sanitize_text_field( $_GET['wcfmmp_store_zip'] ) : $attr['search_zip'];
		
		$search_category  = isset( $_GET['wcfmmp_store_category'] ) ? sanitize_text_field( $_GET['wcfmmp_store_category'] ) : $attr['search_category'];
		$store_category   = isset( $_GET['wcfmsc_store_categories'] ) ? sanitize_text_field( $_GET['wcfmsc_store_categories'] ) : $attr['store_category'];

		$search_radius_range	= isset( $_GET['wcfmmp_radius_range'] ) ? sanitize_text_field( $_GET['wcfmmp_radius_range'] ) : $attr['search_radius_range'];
		$search_radius_lat   	= isset( $_GET['wcfmmp_radius_lat'] ) ? sanitize_text_field( $_GET['wcfmmp_radius_lat'] ) : $attr['search_radius_lat'];
		$search_radius_lng 		= isset( $_GET['wcfmmp_radius_lng'] ) ? sanitize_text_field( $_GET['wcfmmp_radius_lng'] ) : $attr['search_radius_lng'];
		
		$search_category  = apply_filters( 'wcfmmp_stores_default_search_category', $search_category );
		$has_product      = apply_filters( 'wcfmmp_stores_list_has_product', wc_string_to_bool( $attr['has_product'] ) );
		
		$has_sidebar      = isset( $attr['sidebar'] ) ? $attr['sidebar'] : 'yes';
		$has_sidebar      = isset( $attr['has_sidebar'] ) ? $attr['has_sidebar'] : $has_sidebar;
		
		$has_filter       = isset( $attr['filter'] ) ? $attr['filter'] : 'yes';
		$has_filter       = isset( $attr['has_filter'] ) ? $attr['has_filter'] : $has_filter;
		
		$has_search       = isset( $attr['search'] ) ? $attr['search'] : 'yes';
		$has_search       = isset( $attr['has_search'] ) ? $attr['has_search'] : $has_search;
		
		$has_category     = isset( $attr['category'] ) ? $attr['category'] : 'yes';
		$has_category     = isset( $attr['has_category'] ) ? $attr['has_category'] : $has_category;
		
		$has_country      = isset( $attr['country'] ) ? $attr['country'] : 'yes';
		$has_country      = isset( $attr['has_country'] ) ? $attr['has_country'] : $has_country;
		
		$has_state        = isset( $attr['state'] ) ? $attr['state'] : 'yes';
		$has_state        = isset( $attr['has_state'] ) ? $attr['has_state'] : $has_state;
		
		$has_city         = isset( $attr['has_city'] ) ? $attr['has_city'] : 'no';
		
		$has_zip          = isset( $attr['has_zip'] ) ? $attr['has_zip'] : 'no';
		
		$has_radius       = isset( $attr['radius'] ) ? $attr['radius'] : 'yes';
		$has_radius       = isset( $attr['has_radius'] ) ? $attr['has_radius'] : $has_radius;
		
		$has_map          = isset( $attr['map'] ) ? $attr['map'] : 'yes';
		$has_map          = isset( $attr['has_map'] ) ? $attr['has_map'] : $has_map;
		
		$search_data     = array();
		if( $store_category ) {
			$search_data['wcfmsc_store_categories'] = $store_category;
		}
		if( $search_country ) {
			$search_data['wcfmmp_store_country'] = $search_country;
		}
		if( $search_state ) {
			$search_data['wcfmmp_store_state'] = $search_state;
		}
		if( $search_city ) {
			$search_data['wcfmmp_store_city'] = $search_city;
		}
		if( $search_zip ) {
			$search_data['wcfmmp_store_zip'] = $search_zip;
		}
		if( $search_radius_range ) {
			$search_data['wcfmmp_radius_range'] = $search_radius_range;
		}
		if( $search_radius_lat ) {
			$search_data['wcfmmp_radius_lat'] = $search_radius_lat;
		}
		if( $search_radius_lng ) {
			$search_data['wcfmmp_radius_lng'] = $search_radius_lng;
		}
		if( isset( $_POST['search_data'] ) ) {
			parse_str($_POST['search_data'], $search_data);
			$search_data = wc_clean( wp_unslash( $search_data ) );
		} elseif( isset( $_GET['orderby'] ) ) {
			$search_data = wc_clean( wp_unslash($_GET) );
		} else {
			$search_data['orderby'] = $orderby;
		}
		
		// Exclude Membership
		$exclude_members = array();
		$exclude_membership = isset( $attr['exclude_membership'] ) ? sanitize_text_field( $attr['exclude_membership'] ) : '';
		if( $exclude_membership ) $exclude_membership = explode(",", $exclude_membership);
		if( !empty( $exclude_membership ) && is_array( $exclude_membership ) ) {
			foreach( $exclude_membership as $wcfm_membership ) {
				$membership_users = (array) get_post_meta( $wcfm_membership, 'membership_users', true );
				$exclude_members  = array_merge( $exclude_members, $membership_users );
			}
		}
		if( $exclude_members ) $exclude_members = implode(",", $exclude_members);
		else $exclude_members = '';
		
		// Excluded Stores from List
		$excludes = !empty( $attr['excludes'] ) ? sanitize_text_field( $attr['excludes'] ) : $exclude_members;
		$search_data['excludes'] = $excludes;
		
		// Include Membership
		$include_members = array();
		$include_membership = isset( $attr['include_membership'] ) ? sanitize_text_field( $attr['include_membership'] ) : '';
		if( $include_membership ) $include_membership = explode(",", $include_membership);
		if( !empty( $include_membership ) && is_array( $include_membership ) ) {
			foreach( $include_membership as $wcfm_membership ) {
				$membership_users = (array) get_post_meta( $wcfm_membership, 'membership_users', true );
				$include_members  = array_merge( $include_members, $membership_users );
			}
		}
		if( $include_members ) $include_members = implode(",", $include_members);
		else $include_members = '';
		
		// Include Store List
		$includes = !empty( $attr['includes'] ) ? sanitize_text_field( $attr['includes'] ) : $include_members;
		if( $includes ) $includes = explode(",", $includes);
		else $includes = array();
		
		// Radious Search
		$enable_wcfm_storelist_radius  = isset( $WCFMmp->wcfmmp_marketplace_options['enable_wcfm_storelist_radius'] ) ? $WCFMmp->wcfmmp_marketplace_options['enable_wcfm_storelist_radius'] : 'no';
		$has_radius = wc_string_to_bool( $has_radius);
		if( ( $enable_wcfm_storelist_radius == 'yes' ) && $has_radius ) $has_radius = true;
		else $has_radius = false;
		$api_key = isset( $WCFMmp->wcfmmp_marketplace_options['wcfm_google_map_api'] ) ? $WCFMmp->wcfmmp_marketplace_options['wcfm_google_map_api'] : '';
		$wcfm_map_lib = isset( $WCFMmp->wcfmmp_marketplace_options['wcfm_map_lib'] ) ? $WCFMmp->wcfmmp_marketplace_options['wcfm_map_lib'] : '';
		if( !$wcfm_map_lib && $api_key ) { $wcfm_map_lib = 'google'; } elseif( !$wcfm_map_lib && !$api_key ) { $wcfm_map_lib = 'leaftlet'; }
		if ( ($wcfm_map_lib == 'google') && empty( $api_key ) ) $has_radius = false;
		if( $has_radius ) {
			$has_country = 'no';
			$has_state   = 'no';
			$has_city    = 'no';
			$has_zipcode = 'no';
		}
		
		$search_data = apply_filters( 'wcfmmp_stores_search_data', $search_data );
		
		$stores = $WCFMmp->wcfmmp_vendor->wcfmmp_search_vendor_list( true, $offset, $length, $search_term, $search_category, $search_data, $has_product, $includes );

		$template_args = apply_filters( 'wcfmmp_stores_args', array(
			'stores'          		=> $stores,
			'limit'           		=> $length,
			'offset'          		=> $offset,
			'includes'        		=> $includes,
			'excludes'        		=> $excludes,
			'paged'           		=> $paged,
			'image_size'      		=> 'full',
			'orderby'         		=> $orderby,
			'search_term'     		=> $search_term,
			'search_country'  		=> $search_country,
			'search_state'    		=> $search_state,
			'search_city'     		=> $search_city,
			'search_zip'      		=> $search_zip,
			'search_category' 		=> $search_category,
			'store_category'  		=> $store_category,
			'search_radius_range'	=> $search_radius_range,
			'search_radius_lat' 	=> $search_radius_lat,
			'search_radius_lng' 	=> $search_radius_lng,
			'search_data'     		=> $search_data,
			'has_product'     		=> $has_product,
			'has_orderby'     		=> wc_string_to_bool( $attr['has_orderby'] ),
			'sidebar'         		=> wc_string_to_bool( $has_sidebar ),
			'filter'          		=> wc_string_to_bool( $has_filter ),
			'search'          		=> wc_string_to_bool( $has_search ),
			'category'        		=> wc_string_to_bool( $has_category ),
			'country'         		=> wc_string_to_bool( $has_country ),
			'state'           		=> wc_string_to_bool( $has_state ),
			'has_city'        		=> wc_string_to_bool( $has_city ),
			'has_zip'         		=> wc_string_to_bool( $has_zip ),
			'map'             		=> wc_string_to_bool( $has_map ), 
			'radius'          		=> $has_radius,
			'map_zoom'        		=> apply_filters( 'wcfmmp_map_default_zoom_level', $attr['map_zoom'] ),
			'auto_zoom'       		=> wc_string_to_bool( apply_filters( 'wcfmmp_is_allow_map_auto_zoom', $attr['auto_zoom'] ) ),
			'per_row'         		=> $attr['per_row'],
			'theme'           		=> $attr['theme']
		), $attr, $search_data );
		
		ob_start();
		$WCFMmp->template->get_template( 'store-lists/wcfmmp-view-store-lists.php', $template_args );
		return ob_get_clean();
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_stores_map] Shortcode

The wc-multivendor-marketplace plugin shortcode ‘wcfm_stores_map’ creates a map displaying all the stores in a multi-vendor marketplace. It allows users to search and filter stores based on various criteria such as product availability, location, and categories. The shortcode also includes options for pagination and map zoom.

Shortcode: [wcfm_stores_map]

Parameters

Here is a list of all possible wcfm_stores_map shortcode parameters and attributes:

  • filter – Shows or hides the filter option in the store list.
  • search – Enables or disables the search functionality.
  • category – Shows or hides the category filter option.
  • country – Shows or hides the country filter option.
  • state – Shows or hides the state filter option.
  • radius – Enables or disables the radius search functionality.
  • map – Shows or hides the map displaying the stores.
  • map_zoom – Controls the zoom level of the map.
  • auto_zoom – Allows or prevents the map from automatically adjusting the zoom level.
  • limit – Controls the number of stores displayed per page.
  • per_row – Determines the number of stores displayed per row.
  • includes – Allows specific stores to be included.
  • excludes – Allows specific stores to be excluded.
  • include_membership – Allows specific membership stores to be included.
  • exclude_membership – Allows specific membership stores to be excluded.
  • search_term – Prefills the search term input field.
  • search_city – Prefills the city search input field.
  • search_zip – Prefills the zip code search input field.
  • search_category – Prefills the category search input field.
  • search_radius_range – Prefills the radius range search input field.
  • search_radius_lat – Prefills the latitude for radius search input field.
  • search_radius_lng – Prefills the longitude for radius search input field.
  • store_category – Prefills the store category search input field.
  • theme – Determines the theme of the store list.
  • has_product – Filters the stores that have products.
  • has_sidebar – Shows or hides the sidebar in the store list.
  • has_filter – Shows or hides the filter option in the store list.
  • has_search – Enables or disables the search functionality.
  • has_category – Shows or hides the category filter option.
  • has_country – Shows or hides the country filter option.
  • has_state – Shows or hides the state filter option.
  • has_city – Shows or hides the city filter option.
  • has_zip – Shows or hides the zip code filter option.
  • has_radius – Enables or disables the radius search functionality.
  • has_map – Shows or hides the map displaying the stores.

Examples and Usage

Basic example – Display stores with default settings.

[wcfm_stores_map]

Advanced examples

Display stores with a specific theme and limit the number of stores displayed to 5.

[wcfm_stores_map theme="classic" limit=5]

Display stores with search and filter options disabled, and set the map zoom level to 10.

[wcfm_stores_map filter="no" search="no" map_zoom=10]

Include specific stores by ID, exclude certain membership levels, and set the number of stores displayed per row to 4.

[wcfm_stores_map includes="1,2,3" exclude_membership="4,5" per_row=4]

Display stores that only have products, with the sidebar enabled, and set the display theme to “simple”.

[wcfm_stores_map has_product="yes" sidebar="yes" theme="simple"]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_stores_map] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_stores_map', array(&$this, 'wcfmmp_stores_map_shortcode'));

Shortcode PHP function:

function wcfmmp_stores_map_shortcode( $atts ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query;
		$WCFM->nocache();
		
		$defaults = array(
			'filter'             	=> 'yes',
			'search'             	=> 'yes',
			'category'           	=> 'yes',
			'country'            	=> 'yes',
			'state'              	=> 'yes',
			'radius'             	=> 'yes',
			'map'                	=> 'yes',
			'map_zoom'           	=> 5,
			'auto_zoom'          	=> 'yes',
			'limit'              	=> 10,
			'per_row'            	=> 3,
			'includes'           	=> '',
			'excludes'           	=> '',
			'include_membership' 	=> '',
			'exclude_membership' 	=> '',
			'search_term'        	=> '',
			'search_city'        	=> '',
			'search_zip'         	=> '',
			'search_category'    	=> '',
			'search_radius_range' 	=> '',
			'search_radius_lat' 	=> '',
			'search_radius_lng' 	=> '',
			'store_category'     	=> '',
			'theme'              	=> 'classic',
			'has_product'        	=> 'no',
			'has_sidebar'        	=> 'yes',
			'has_filter'         	=> 'yes',
			'has_search'         	=> 'yes',
			'has_category'       	=> 'yes',
			'has_country'        	=> 'yes',
			'has_state'          	=> 'yes',
			'has_city'           	=> 'no',
			'has_zip'            	=> 'no',
			'has_radius'         	=> 'yes',
			'has_map'            	=> 'yes',
		);
		
		$attr   = shortcode_atts( apply_filters( 'wcfmmp_stores_map_default_args', $defaults ), $atts );
		
		$search_term      = isset( $_GET['wcfmmp_store_search'] ) ? sanitize_text_field( $_GET['wcfmmp_store_search'] ) : $attr['search_term'];
		
		$search_country   = isset( $_GET['wcfmmp_store_country'] ) ? sanitize_text_field( $_GET['wcfmmp_store_country'] ) : '';
		$search_state     = isset( $_GET['wcfmmp_store_state'] ) ? sanitize_text_field( $_GET['wcfmmp_store_state'] ) : '';
		$search_city      = isset( $_GET['wcfmmp_store_city'] ) ? sanitize_text_field( $_GET['wcfmmp_store_city'] ) : $attr['search_city'];
		$search_zip       = isset( $_GET['wcfmmp_store_zip'] ) ? sanitize_text_field( $_GET['wcfmmp_store_zip'] ) : $attr['search_zip'];
		
		$search_category  = isset( $_GET['wcfmmp_store_category'] ) ? sanitize_text_field( $_GET['wcfmmp_store_category'] ) : $attr['search_category'];
		$store_category   = isset( $_GET['wcfmsc_store_categories'] ) ? sanitize_text_field( $_GET['wcfmsc_store_categories'] ) : $attr['store_category'];

		$search_radius_range	= isset( $_GET['wcfmmp_radius_range'] ) ? sanitize_text_field( $_GET['wcfmmp_radius_range'] ) : $attr['search_radius_range'];
		$search_radius_lat   	= isset( $_GET['wcfmmp_radius_lat'] ) ? sanitize_text_field( $_GET['wcfmmp_radius_lat'] ) : $attr['search_radius_lat'];
		$search_radius_lng 		= isset( $_GET['wcfmmp_radius_lng'] ) ? sanitize_text_field( $_GET['wcfmmp_radius_lng'] ) : $attr['search_radius_lng'];
		
		$has_product      = apply_filters( 'wcfmmp_stores_list_has_product', wc_string_to_bool( $attr['has_product'] ) );

		$has_filter       = isset( $attr['filter'] ) ? $attr['filter'] : 'yes';
		$has_filter       = isset( $attr['has_filter'] ) ? $attr['has_filter'] : $has_filter;
		
		$has_search       = isset( $attr['search'] ) ? $attr['search'] : 'yes';
		$has_search       = isset( $attr['has_search'] ) ? $attr['has_search'] : $has_search;
		
		$has_category     = isset( $attr['category'] ) ? $attr['category'] : 'yes';
		$has_category     = isset( $attr['has_category'] ) ? $attr['has_category'] : $has_category;
		
		$has_country      = isset( $attr['country'] ) ? $attr['country'] : 'yes';
		$has_country      = isset( $attr['has_country'] ) ? $attr['has_country'] : $has_country;
		
		$has_state        = isset( $attr['state'] ) ? $attr['state'] : 'yes';
		$has_state        = isset( $attr['has_state'] ) ? $attr['has_state'] : $has_state;
		
		$has_city         = isset( $attr['has_city'] ) ? $attr['has_city'] : 'no';
		
		$has_zip          = isset( $attr['has_zip'] ) ? $attr['has_zip'] : 'no';
		
		$has_radius       = isset( $attr['radius'] ) ? $attr['radius'] : 'yes';
		$has_radius       = isset( $attr['has_radius'] ) ? $attr['has_radius'] : $has_radius;
		
		$has_map          = isset( $attr['map'] ) ? $attr['map'] : 'yes';
		$has_map          = isset( $attr['has_map'] ) ? $attr['has_map'] : $has_map;
		
		$search_data     = array();
		if( $store_category ) {
			$search_data['wcfmsc_store_categories'] = $store_category;
		}
		if( $search_country ) {
			$search_data['wcfmmp_store_country'] = $search_country;
		}
		if( $search_state ) {
			$search_data['wcfmmp_store_state'] = $search_state;
		}
		if( $search_city ) {
			$search_data['wcfmmp_store_city'] = $search_city;
		}
		if( $search_zip ) {
			$search_data['wcfmmp_store_zip'] = $search_zip;
		}
		if( $search_radius_range ) {
			$search_data['wcfmmp_radius_range'] = $search_radius_range;
		}
		if( $search_radius_lat ) {
			$search_data['wcfmmp_radius_lat'] = $search_radius_lat;
		}
		if( $search_radius_lng ) {
			$search_data['wcfmmp_radius_lng'] = $search_radius_lng;
		}
		if( isset( $_POST['search_data'] ) ) {
			parse_str($_POST['search_data'], $search_data);
			$search_data = wc_clean( wp_unslash( $search_data ) );
		}
		
		// Exclude Membership
		$exclude_members = array();
		$exclude_membership = isset( $attr['exclude_membership'] ) ? sanitize_text_field( $attr['exclude_membership'] ) : '';
		if( $exclude_membership ) $exclude_membership = explode(",", $exclude_membership);
		if( !empty( $exclude_membership ) && is_array( $exclude_membership ) ) {
			foreach( $exclude_membership as $wcfm_membership ) {
				$membership_users = (array) get_post_meta( $wcfm_membership, 'membership_users', true );
				$exclude_members  = array_merge( $exclude_members, $membership_users );
			}
		}
		if( $exclude_members ) $exclude_members = implode(",", $exclude_members);
		else $exclude_members = '';
		
		// Excluded Stores from List
		$excludes = !empty( $attr['excludes'] ) ? sanitize_text_field( $attr['excludes'] ) : $exclude_members;
		$search_data['excludes'] = $excludes;
		
		// Include Membership
		$include_members = array();
		$include_membership = isset( $attr['include_membership'] ) ? sanitize_text_field( $attr['include_membership'] ) : '';
		if( $include_membership ) $include_membership = explode(",", $include_membership);
		if( !empty( $include_membership ) && is_array( $include_membership ) ) {
			foreach( $include_membership as $wcfm_membership ) {
				$membership_users = (array) get_post_meta( $wcfm_membership, 'membership_users', true );
				$include_members  = array_merge( $include_members, $membership_users );
			}
		}
		if( $include_members ) $include_members = implode(",", $include_members);
		else $include_members = '';
		
		// Include Store List
		$includes = !empty( $attr['includes'] ) ? sanitize_text_field( $attr['includes'] ) : $include_members;
		if( $includes ) $includes = explode(",", $includes);
		else $includes = array();
		
		$pagination_base = '';
		
		// Radious Search
		$enable_wcfm_storelist_radius  = isset( $WCFMmp->wcfmmp_marketplace_options['enable_wcfm_storelist_radius'] ) ? $WCFMmp->wcfmmp_marketplace_options['enable_wcfm_storelist_radius'] : 'no';
		$has_radius = wc_string_to_bool( $has_radius);
		if( ( $enable_wcfm_storelist_radius == 'yes' ) && $has_radius ) $has_radius = true;
		else $has_radius = false;
		$api_key = isset( $WCFMmp->wcfmmp_marketplace_options['wcfm_google_map_api'] ) ? $WCFMmp->wcfmmp_marketplace_options['wcfm_google_map_api'] : '';
		$wcfm_map_lib = isset( $WCFMmp->wcfmmp_marketplace_options['wcfm_map_lib'] ) ? $WCFMmp->wcfmmp_marketplace_options['wcfm_map_lib'] : '';
		if( !$wcfm_map_lib && $api_key ) { $wcfm_map_lib = 'google'; } elseif( !$wcfm_map_lib && !$api_key ) { $wcfm_map_lib = 'leaftlet'; }
		if ( ($wcfm_map_lib == 'google') && empty( $api_key ) ) $has_radius = false;
		if( $has_radius ) {
			$has_country = 'no';
			$has_state   = 'no';
			$has_city    = 'no';
			$has_zipcode = 'no';
		}
		
		$stores = $WCFMmp->wcfmmp_vendor->wcfmmp_search_vendor_list( true, '', $attr['limit'], $search_term, $search_category, $search_data, $has_product, $includes );

		$template_args = apply_filters( 'wcfmmp_stores_map_args', array(
			'stores'          		=> $stores,
			'offset'          		=> 0,
			'excludes'        		=> $excludes,
			'search_term'     		=> $search_term,
			'search_country'  		=> $search_country,
			'search_state'    		=> $search_state,
			'search_city'     		=> $search_city,
			'search_zip'      		=> $search_zip,
			'search_category' 		=> $search_category,
			'store_category'  		=> $store_category,
			'search_radius_range'	=> $search_radius_range,
			'search_radius_lat' 	=> $search_radius_lat,
			'search_radius_lng' 	=> $search_radius_lng,
			'search_data'     		=> $search_data,
			'pagination_base' 		=> $pagination_base,
			'has_product'     		=> $has_product,
			'filter'          		=> wc_string_to_bool( $has_filter ),
			'search'          		=> wc_string_to_bool( $has_search ),
			'category'        		=> wc_string_to_bool( $has_category ),
			'country'         		=> wc_string_to_bool( $has_country ),
			'state'           		=> wc_string_to_bool( $has_state ),
			'has_city'        		=> wc_string_to_bool( $has_city ),
			'has_zip'         		=> wc_string_to_bool( $has_zip ),
			'map'             		=> wc_string_to_bool( $has_map ), 
			'radius'          		=> $has_radius,
			'map_zoom'        		=> apply_filters( 'wcfmmp_map_default_zoom_level', $attr['map_zoom'] ),
			'auto_zoom'       		=> wc_string_to_bool( apply_filters( 'wcfmmp_is_allow_map_auto_zoom', $attr['auto_zoom'] ) ),
			'includes'        		=> $includes,
			'per_row'         		=> $attr['per_row'],
			'limit'           		=> $attr['limit'],
			'orderby'         		=> '',
			'has_orderby'     		=> wc_string_to_bool( 'no' ),
			'sidebar'         		=> wc_string_to_bool( 'no' ),
			'theme'           		=> 'simple'
		) );
		
		ob_start();
		echo '<div id="wcfmmp-stores-map-wrapper">';
		$WCFMmp->template->get_template( 'store-lists/wcfmmp-view-store-lists-map.php', $template_args );
		if( wc_string_to_bool( $has_filter ) ) {
			if( wc_string_to_bool( $has_search ) || $has_radius || wc_string_to_bool( $has_category ) || wc_string_to_bool( $has_country ) || wc_string_to_bool( $has_state ) || wc_string_to_bool( $has_city ) || wc_string_to_bool( $has_zip ) ) { $WCFMmp->template->get_template( 'store-lists/wcfmmp-view-store-lists-search-form.php', $template_args ); }
		}
		echo '</div>';
		echo '<div class="wcfm-clearfix"></div>';
		return ob_get_clean();
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_stores_carousel] Shortcode

The wc-multivendor-marketplace plugin shortcode ‘wcfm_stores_carousel’ is used to display a carousel of stores in a WordPress site. It retrieves a list of stores based on various attributes and settings, such as per page limit, category, country, state, and city.

Shortcode: [wcfm_stores_carousel]

Parameters

Here is a list of all possible wcfm_stores_carousel shortcode parameters and attributes:

  • per_page – defines the number of stores displayed per page
  • category – enables or disables category filter
  • country – enables or disables country filter
  • state – enables or disables state filter
  • has_category – shows or hides stores with category
  • has_country – shows or hides stores with country
  • has_state – shows or hides stores with state
  • has_city – shows or hides stores with city
  • has_zip – shows or hides stores with zip code
  • has_loop – enables or disables carousel loop
  • has_autoplay – enables or disables carousel autoplay
  • has_nav – enables or disables carousel navigation
  • per_row – defines the number of stores per carousel row
  • includes – specifies included stores
  • excludes – specifies excluded stores
  • include_membership – includes stores with certain memberships
  • exclude_membership – excludes stores with certain memberships
  • search_term – defines the search term for stores
  • search_city – defines the search city for stores
  • search_zip – defines the search zip code for stores
  • search_category – defines the search category for stores
  • store_category – defines the store category
  • has_product – shows or hides stores with products
  • theme – sets the theme for the store carousel

Examples and Usage

Basic example – Displays a carousel of stores with default parameters.

[wcfm_stores_carousel]

Advanced examples

Display a carousel of stores with a limit of 10 stores per page, showing store categories and countries, but not states. The carousel will not loop and will not autoplay.

[wcfm_stores_carousel per_page=10 category='yes' country='yes' state='no' has_loop='no' has_autoplay='no']

Display a carousel of stores with a limit of 5 stores per page, excluding stores with membership IDs 1, 2, and 3. The carousel will loop, autoplay, and display navigation. The theme of the carousel will be ‘classic’.

[wcfm_stores_carousel per_page=5 exclude_membership='1,2,3' has_loop='yes' has_autoplay='yes' has_nav='yes' theme='classic']

Display a carousel of stores including only stores with membership IDs 4, 5, and 6. The carousel will display 3 stores per row and will not show city or zip information.

[wcfm_stores_carousel include_membership='4,5,6' per_row=3 has_city='no' has_zip='no']

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_stores_carousel] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_stores_carousel', array(&$this, 'wcfmmp_stores_carousel_shortcode'));

Shortcode PHP function:

function wcfmmp_stores_carousel_shortcode( $atts ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $includes;
		$WCFM->nocache();
		
		$defaults = array(
				'per_page'           => 20,
				'category'           => 'yes',
				'country'            => 'yes',
				'state'              => 'yes',
				'has_category'       => 'yes',
				'has_country'        => 'yes',
				'has_state'          => 'yes',
				'has_city'           => 'no',
				'has_zip'            => 'no',
				'has_loop'           => 'yes',
				'has_autoplay'       => 'yes',
				'has_nav'            => 'yes',
				'per_row'            => 3,
				'includes'           => '',
				'excludes'           => '',
				'include_membership' => '',
				'exclude_membership' => '',
				'search_term'        => '',
				'search_city'        => '',
				'search_zip'         => '',
				'search_category'    => '',
				'store_category'     => '',
				'has_product'        => '',
				'theme'              => 'classic'
		);

		$attr   = shortcode_atts( apply_filters( 'wcfmmp_stores_carousel_default_args', $defaults ), $atts );
		$paged  = max( 1, get_query_var( 'paged' ) );
		$length = apply_filters( 'wcfmmp_stores_per_page', $attr['per_page'] );
		$offset = ( $paged - 1 ) * $length;
		
		$search_country = '';
		$search_state   = '';
		
		// GEO Locate Support
		if( apply_filters( 'wcfmmp_is_allow_store_list_by_user_location', true ) ) {
			if( is_user_logged_in() && !$search_country ) {
				$user_location = get_user_meta( get_current_user_id(), 'wcfm_user_location', true );
				if( $user_location ) {
					$search_country = $user_location['country'];
					$search_state   = $user_location['state'];
				}
			}
					
			if( apply_filters( 'wcfm_is_allow_wc_geolocate', true ) && class_exists( 'WC_Geolocation' ) && !$search_country ) {
				$user_location = WC_Geolocation::geolocate_ip();
				$search_country = $user_location['country'];
				$search_state   = $user_location['state'];
			}
		}

		$search_term      = isset( $_GET['wcfmmp_store_search'] ) ? sanitize_text_field( $_GET['wcfmmp_store_search'] ) : $attr['search_term'];
		
		$search_country   = isset( $_GET['wcfmmp_store_country'] ) ? sanitize_text_field( $_GET['wcfmmp_store_country'] ) : $search_country;
		$search_state     = isset( $_GET['wcfmmp_store_state'] ) ? sanitize_text_field( $_GET['wcfmmp_store_state'] ) : $search_state;
		$search_city      = isset( $_GET['wcfmmp_store_city'] ) ? sanitize_text_field( $_GET['wcfmmp_store_city'] ) : $attr['search_city'];
		$search_zip       = isset( $_GET['wcfmmp_store_zip'] ) ? sanitize_text_field( $_GET['wcfmmp_store_zip'] ) : $attr['search_zip'];
		
		$search_category  = isset( $_GET['wcfmmp_store_category'] ) ? sanitize_text_field( $_GET['wcfmmp_store_category'] ) : $attr['search_category'];
		$store_category   = isset( $_GET['wcfmsc_store_categories'] ) ? sanitize_text_field( $_GET['wcfmsc_store_categories'] ) : $attr['store_category'];
		
		$search_category  = apply_filters( 'wcfmmp_stores_default_search_category', $search_category );
		$has_product      = apply_filters( 'wcfmmp_stores_list_has_product', $attr['has_product'] );
		
		$has_category     = isset( $attr['category'] ) ? $attr['category'] : 'yes';
		$has_category     = isset( $attr['has_category'] ) ? $attr['has_category'] : $has_category;
		
		$has_country      = isset( $attr['country'] ) ? $attr['country'] : 'yes';
		$has_country      = isset( $attr['has_country'] ) ? $attr['has_country'] : $has_country;
		
		$has_state        = isset( $attr['state'] ) ? $attr['state'] : 'yes';
		$has_state        = isset( $attr['has_state'] ) ? $attr['has_state'] : $has_state;
		
		$has_city         = isset( $attr['has_city'] ) ? $attr['has_city'] : 'no';
		
		$has_zip          = isset( $attr['has_zip'] ) ? $attr['has_zip'] : 'no';
		
		$search_data     = array();
		if( $store_category ) {
			$search_data['wcfmsc_store_categories'] = $store_category;
		}
		if( $search_country ) {
			$search_data['wcfmmp_store_country'] = $search_country;
		}
		if( $search_state ) {
			$search_data['wcfmmp_store_state'] = $search_state;
		}
		if( $search_city ) {
			$search_data['wcfmmp_store_city'] = $search_city;
		}
		if( $search_zip ) {
			$search_data['wcfmmp_store_zip'] = $search_zip;
		}
		if( isset( $_POST['search_data'] ) ) {
			parse_str($_POST['search_data'], $search_data);
			$search_data = wc_clean( wp_unslash( $search_data ) );
		}
		
		// Exclude Membership
		$exclude_members = array();
		$exclude_membership = isset( $attr['exclude_membership'] ) ? sanitize_text_field( $attr['exclude_membership'] ) : '';
		if( $exclude_membership ) $exclude_membership = explode(",", $exclude_membership);
		if( !empty( $exclude_membership ) && is_array( $exclude_membership ) ) {
			foreach( $exclude_membership as $wcfm_membership ) {
				$membership_users = (array) get_post_meta( $wcfm_membership, 'membership_users', true );
				$exclude_members  = array_merge( $exclude_members, $membership_users );
			}
		}
		if( $exclude_members ) $exclude_members = implode(",", $exclude_members);
		else $exclude_members = '';
		
		// Excluded Stores from List
		$excludes = !empty( $attr['excludes'] ) ? sanitize_text_field( $attr['excludes'] ) : $exclude_members;
		$search_data['excludes'] = $excludes;
		
		// Include Membership
		$include_members = array();
		$include_membership = isset( $attr['include_membership'] ) ? sanitize_text_field( $attr['include_membership'] ) : '';
		if( $include_membership ) $include_membership = explode(",", $include_membership);
		if( !empty( $include_membership ) && is_array( $include_membership ) ) {
			foreach( $include_membership as $wcfm_membership ) {
				$membership_users = (array) get_post_meta( $wcfm_membership, 'membership_users', true );
				$include_members  = array_merge( $include_members, $membership_users );
			}
		}
		if( $include_members ) $include_members = implode(",", $include_members);
		else $include_members = '';
		
		// Include Store List
		$includes = !empty( $attr['includes'] ) ? sanitize_text_field( $attr['includes'] ) : $include_members;
		if( $includes ) $includes = explode(",", $includes);
		else $includes = array();
			

		$stores = $WCFMmp->wcfmmp_vendor->wcfmmp_search_vendor_list( true, $offset, $length, $search_term, $search_category, $search_data, $has_product, $includes );

		$template_args = apply_filters( 'wcfmmp_stores_args', array(
				'stores'          => $stores,
				'limit'           => $length,
				'offset'          => $offset,
				'includes'        => $includes,
				'excludes'        => $excludes,
				'search_term'     => $search_term,
				'search_country'  => $search_country,
				'search_state'    => $search_state,
				'search_city'     => $search_city,
				'search_zip'      => $search_zip,
				'search_category' => $search_category,
				'store_category'  => $store_category,
				'search_data'     => $search_data,
				'has_product'     => $has_product,
				'category'        => wc_string_to_bool( $has_category ),
				'country'         => wc_string_to_bool( $has_country ),
				'state'           => wc_string_to_bool( $has_state ),
				'has_city'        => wc_string_to_bool( $has_city ),
				'has_zip'         => wc_string_to_bool( $has_zip ),
				'has_loop'        => wc_string_to_bool( $attr['has_loop'] ),
				'has_autoplay'    => wc_string_to_bool( $attr['has_autoplay'] ),
				'has_nav'         => wc_string_to_bool( $attr['has_nav'] ),
				'per_row'         => $attr['per_row'],
				'theme'           => $attr['theme']
		), $attr, $search_data);
		
		ob_start();
		$WCFMmp->template->get_template( 'store-lists/wcfmmp-view-store-lists-carousel.php', $template_args );
		return ob_get_clean();
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_store_sold_by] Shortcode

The WCFM Store Sold By shortcode is a dynamic tool that displays the vendor’s information on product pages. It checks if the post author is a vendor, fetches the store information, and verifies if the store is online. It triggers actions before and after the sidebar info, selects the template based on the vendor’s choice, and enqueues the CSS for styling. The content is then returned after being cleaned. This shortcode enhances the user experience by providing essential vendor details.

Shortcode: [wcfm_store_sold_by]

Examples and Usage

Basic example – Displays the ‘Sold By’ information for a store in a simple format.

[wcfm_store_sold_by]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_store_sold_by] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_store_sold_by', array(&$this, 'wcfmmp_store_sold_by_shortcode'));

Shortcode PHP function:

function wcfmmp_store_sold_by_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $post;

		if( !$post ) return;
		if( !wcfm_is_vendor( $post->post_author ) ) return;
		
		$store_user   = wcfmmp_get_store( $post->post_author );
		$store_info   = $store_user->get_shop_info();
		
		$is_store_offline = get_user_meta( $store_user->get_id(), '_wcfm_store_offline', true );
		if ( $is_store_offline ) {
			return;
		}
		
		ob_start();
		
		do_action( 'wcfmmp_store_before_sidebar_info', $store_user->get_id() );
		
		$vendor_sold_by_template = $WCFMmp->wcfmmp_vendor->get_vendor_sold_by_template();
		
		if( $vendor_sold_by_template == 'advanced' ) {
			$WCFMmp->template->get_template( 'sold-by/wcfmmp-view-sold-by-advanced.php', array( 'vendor_id' => $store_user->get_id() ) );
		} else {
			$WCFMmp->template->get_template( 'sold-by/wcfmmp-view-sold-by-simple.php', array( 'vendor_id' => $store_user->get_id() ) );
		}
		wp_enqueue_style( 'wcfmmp_product_css',  $WCFMmp->library->css_lib_url_min . 'store/wcfmmp-style-product.css', array(), $WCFMmp->version );

		do_action( 'wcfmmp_store_after_sidebar_info', $store_user->get_id() );
		
		$content = ob_get_clean();
		return $content;
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_store_info] Shortcode

The wc-multivendor-marketplace shortcode is used to display specific information about a store in a WC Multivendor Marketplace. This shortcode fetches and displays data such as the store’s name, URL, address, email, phone, avatar, banner, customer support details, social links, location, rating, badges, and registration date. The information displayed depends on the ‘data’ attribute passed to the shortcode. The shortcode also allows customization of the label and icon for the displayed data. It checks if the store is offline and, if so, does not display any information. The shortcode can be used on the store page, a product page, or a single post page.

Shortcode: [wcfm_store_info]

Parameters

Here is a list of all possible wcfm_store_info shortcode parameters and attributes:

  • id – The unique identifier of the store
  • data – Specifies the type of store data to display
  • label – The label text to show before the data
  • icon – The icon to show before the label text

Examples and Usage

Basic example – Displaying the store name of a specific vendor.

[wcfm_store_info id=5 data=store_name]

Advanced examples

Displaying the store address of a specific vendor with an accompanying label and icon.

[wcfm_store_info id=5 data=store_address label="Address" icon="map-marker-alt"]

Displaying the store email of a specific vendor with a label, but without an icon.

[wcfm_store_info id=5 data=store_email label="Email"]

Displaying the store phone number of a specific vendor with an icon, but without a label.

[wcfm_store_info id=5 data=store_phone icon="phone"]

Displaying the store social media links of a specific vendor without label and icon.

[wcfm_store_info id=5 data=store_social]

Displaying the store rating of a specific vendor with a label and icon.

[wcfm_store_info id=5 data=store_rating label="Rating" icon="star"]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_store_info] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_store_info', array(&$this, 'wcfmmp_store_info_shortcode'));

Shortcode PHP function:

function wcfmmp_store_info_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;
		
		$store_id = '';
		if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }
		
		if ( !$store_id && wcfm_is_store_page() ) {
			$wcfm_store_url = wcfm_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( !$store_id && 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;
		}
		
		$data_info = '';
		if ( isset( $attr['data'] ) && !empty( $attr['data'] ) ) { $data_info = $attr['data']; }
		
		if( !$store_id ) return;
		if( !$data_info ) return;
		
		$is_store_offline = get_user_meta( $store_id, '_wcfm_store_offline', true );
		if ( $is_store_offline ) {
			return;
		}
		
		$label = '';
		if ( isset( $attr['label'] ) && !empty( $attr['label'] ) ) { $label = $attr['label']; }
		
		$icon = '';
		if ( isset( $attr['icon'] ) && !empty( $attr['icon'] ) ) { $icon = $attr['icon']; }
		
		$store_user  = wcfmmp_get_store( $store_id );
		$store_info  = $store_user->get_shop_info();
		
		$content = '<div class="wcfmmp_store_info wcfmmp_store_info_' . $data_info . '">';
		
		if( $icon ) {
			$content .= '<i style="display:inline-block" class="wcfmfa fa-' . $icon . ' wcfmmp_store_info_icon wcfmmp_store_info_iconl_' . $data_info . '"></i>&nbsp&nbsp';
		}
		
		if( $label ) {
			$content .= '<span style="display:inline-block" class="wcfmmp_store_info_label wcfmmp_store_info_label_' . $data_info . '">' . $label . '</span>:&nbsp';
		}
		
		switch( $data_info ) {
			case 'store_name':
				$content .= $WCFM->wcfm_vendor_support->wcfm_get_vendor_store_name_by_vendor( $store_id );
				break;
				
			case 'store_url':
				$content .=  $WCFM->wcfm_vendor_support->wcfm_get_vendor_store_by_vendor( $store_id );
				break;
				
			case 'store_address':
				$content .= '<span style="display:inline-block" class="wcfmmp_store_info_content wcfmmp_store_info_content_' . $data_info . '">' . apply_filters( 'wcfmmp_additional_store_info', $store_user->get_address_string(), $data_info, $store_id ) . '</span>';
				break;
				
		  case 'store_email':
				$content .= '<span style="display:inline-block" class="wcfmmp_store_info_content wcfmmp_store_info_content_' . $data_info . '">' . apply_filters( 'wcfmmp_additional_store_info', apply_filters( 'wcfmmp_mailto_email', $store_user->get_email(), $store_id ), $data_info, $store_id ) . '</span>';
				break;
			
			case 'store_phone':
				$content .=  '<span style="display:inline-block" class="wcfmmp_store_info_content wcfmmp_store_info_content_' . $data_info . '">' . apply_filters( 'wcfmmp_additional_store_info', $store_user->get_phone(), $data_info, $store_id ) . '</span>';
				break;
				
			case 'store_gravatar':
				$content .=  '<img src="' . esc_url( $store_user->get_avatar() ) . '" />';
				break;
				
			case 'store_banner':
				$content .=  '<img src="' . esc_url( $store_user->get_banner() ) . '" />';
				break;
				
			case 'store_support':
				$content .=  $store_user->get_customer_support_details();
				break;
				
		  case 'store_social':
		  	ob_start();
		  	$WCFMmp->template->get_template( 'store/wcfmmp-view-store-social.php', array( 'store_user' => $store_user, 'store_info' => $store_info ) );
				$content .=  ob_get_clean();
				if( !wcfmmp_is_store_page() && !is_product() ) {
					wp_enqueue_style( 'wcfmmp_product_css',  $WCFMmp->library->css_lib_url . 'store/wcfmmp-style-product.css', array(), $WCFMmp->version );
				}
				break;
				
			case 'store_location':
				$api_key = isset( $WCFMmp->wcfmmp_marketplace_options['wcfm_google_map_api'] ) ? $WCFMmp->wcfmmp_marketplace_options['wcfm_google_map_api'] : '';
				$wcfm_map_lib = isset( $WCFMmp->wcfmmp_marketplace_options['wcfm_map_lib'] ) ? $WCFMmp->wcfmmp_marketplace_options['wcfm_map_lib'] : '';
				if( !$wcfm_map_lib && $api_key ) { $wcfm_map_lib = 'google'; } elseif( !$wcfm_map_lib && !$api_key ) { $wcfm_map_lib = 'leaftlet'; }
				$store_lat    = isset( $store_info['store_lat'] ) ? esc_attr( $store_info['store_lat'] ) : 0;
				$store_lng    = isset( $store_info['store_lng'] ) ? esc_attr( $store_info['store_lng'] ) : 0;
	
				if ( ( ( ($wcfm_map_lib == 'google') && !empty( $api_key ) ) || ($wcfm_map_lib == 'leaflet') ) && !empty( $store_lat ) && !empty( $store_lng ) ) {
					ob_start();
					$WCFMmp->template->get_template( 'store/widgets/wcfmmp-view-store-location.php', array( 
																												 'store_user' => $store_user, 
																												 'store_info' => $store_info,
																												 'store_lat'  => $store_lat,
																												 'store_lng'  => $store_lng,
																												 'map_id'     => 'wcfm_sold_by_widget_map_'.rand(10,100)
																												 ) );
					$content .=  ob_get_clean();
					
					if( !wcfmmp_is_store_page() ) {
						wp_enqueue_style( 'wcfmmp_product_css',  $WCFMmp->library->css_lib_url . 'store/wcfmmp-style-product.css', array(), $WCFMmp->version );
						wp_enqueue_script( 'wcfmmp_store_js', $WCFMmp->library->js_lib_url . 'store/wcfmmp-script-store.js', array('jquery' ), $WCFMmp->version, true );
						$WCFMmp->library->load_map_lib();
					}
				}
				break;
				
			case 'store_rating':
				ob_start();
				$store_user->show_star_rating();
				$content .=  ob_get_clean();
				break;
				
			case 'store_badges':
				ob_start();
				do_action('wcfmmp_single_product_sold_by_badges', $store_id );
				$content .=  ob_get_clean();
				break;
				
			case 'register_on':
				$data_value = get_user_meta( $store_id, 'wcfm_register_on', true );
				if( $data_value ) {
					$content .=  '<span style="display:inline-block" class="wcfmmp_store_info_content wcfmmp_store_info_content_' . $data_info . '">' . apply_filters( 'wcfmmp_additional_store_info', date( wc_date_format(), $data_value ), $data_info, $store_id ) . '</span>';
				}
				break;
				
			default:
				$data_value = get_user_meta( $store_id, $data_info, true );
				if( $data_value && is_array( $data_value ) ) {
					$data_value = implode( ", ", $data_value );
				}
				$content .=  '<span style="display:inline-block" class="wcfmmp_store_info_content wcfmmp_store_info_content_' . $data_info . '">' . apply_filters( 'wcfmmp_additional_store_info', $data_value, $data_info, $store_id ) . '</span>';
			  break;
		}
		
		$content .= '</div>';
		
		return $content;
		
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_store_hours] Shortcode

The ‘wcfm_store_hours’ shortcode from the wc-multivendor-marketplace plugin displays the operating hours of a store. It checks if the store is online and if it has ‘store hours’ capability. It fetches the store hours data, including off days and daily timings, and generates a formatted output. If the store doesn’t have set hours, the shortcode returns nothing.

Shortcode: [wcfm_store_hours]

Parameters

Here is a list of all possible wcfm_store_hours shortcode parameters and attributes:

  • id – Represents the unique identifier of the store

Examples and Usage

Basic example – Display the store hours of a specific store by referencing the store ID.

[wcfm_store_hours id=1 /]

Advanced examples

Display the store hours of a specific store by referencing the store ID and customize the display of the store hours using additional parameters.

[wcfm_store_hours id=1 enable="yes" off_days="Saturday,Sunday" day_times="9:00-18:00" /]

In this advanced example, the shortcode will display the store hours of the store with ID 1. The ‘enable’ parameter is set to ‘yes’, meaning the store hours will be displayed. The ‘off_days’ parameter is set to ‘Saturday,Sunday’, meaning these two days will be marked as off days. The ‘day_times’ parameter is set to ‘9:00-18:00’, meaning the store hours will be displayed as 9:00 to 18:00.

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_store_hours] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_store_hours', array(&$this, 'wcfmmp_store_hours_shortcode'));

Shortcode PHP function:

function wcfmmp_store_hours_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;
		
		if( !apply_filters( 'wcfm_is_pref_store_hours', true ) ) return;
		
		$store_id = '';
		if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }
		
		if (  wcfm_is_store_page() ) {
			$wcfm_store_url = wcfm_get_option( 'wcfm_store_url', 'store' );
			$store_name = 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 ) return;
		
		$is_store_offline = get_user_meta( $store_id, '_wcfm_store_offline', true );
		if ( $is_store_offline ) {
			return;
		}
		
		if( !$WCFM->wcfm_vendor_support->wcfm_vendor_has_capability( $store_id, 'store_hours' ) ) return;
		
		$store_user  = wcfmmp_get_store( $store_id );
		
		$wcfm_vendor_store_hours = get_user_meta( $store_id, 'wcfm_vendor_store_hours', true );
		if( !$wcfm_vendor_store_hours ) {
			return;
		}
		
		$wcfm_store_hours_enable = isset( $wcfm_vendor_store_hours['enable'] ) ? 'yes' : 'no';
		if( $wcfm_store_hours_enable != 'yes' ) return;
		
		$wcfm_store_hours_off_days  = isset( $wcfm_vendor_store_hours['off_days'] ) ? $wcfm_vendor_store_hours['off_days'] : array();
		$wcfm_store_hours_day_times = isset( $wcfm_vendor_store_hours['day_times'] ) ? $wcfm_vendor_store_hours['day_times'] : array();
		if( empty( $wcfm_store_hours_day_times ) ) return;
		
		$weekdays = array( 0 => __( 'Monday', 'wc-multivendor-marketplace' ), 1 => __( 'Tuesday', 'wc-multivendor-marketplace' ), 2 => __( 'Wednesday', 'wc-multivendor-marketplace' ), 3 => __( 'Thursday', 'wc-multivendor-marketplace' ), 4 => __( 'Friday', 'wc-multivendor-marketplace' ), 5 => __( 'Saturday', 'wc-multivendor-marketplace' ), 6 => __( 'Sunday', 'wc-multivendor-marketplace') );
		
		$content = '<div class="wcfmmp_store_hours">';
		$content .= '<span class="wcfmmp-store-hours widget-title"><span class="wcfmfa fa-clock"></span>&nbsp;' . apply_filters( 'wcfm_store_hours_label', __( 'Store Hours', 'wc-multivendor-marketplace' ) ) . '</span><div class="wcfm_clearfix"></div>';
		
		ob_start();
		$WCFMmp->template->get_template( 'store/widgets/wcfmmp-view-store-hours.php', array( 
			                                             'wcfm_store_hours_day_times' => $wcfm_store_hours_day_times, 
			                                             'wcfm_store_hours_off_days'  => $wcfm_store_hours_off_days,
			                                             'weekdays' => $weekdays,
			                                             'store_id' => $store_id,
			                                             ) );
		$content .= ob_get_clean();
		
		$content .= '</div>';
		
		return $content;
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_shipping_time] Shortcode

The WCFM Marketplace shortcode is designed to display shipping information for a particular product. It checks if shipping is enabled for the store and if the product needs shipping. If true, it fetches the vendor ID and product ID. Then, it retrieves and displays the shipping information from the ‘wcfmmp-view-shipping-info.php’ template.

Shortcode: [wcfm_shipping_time]

Examples and Usage

Basic example – Display the shipping time of a product on a WooCommerce store page using the shortcode.

[wcfm_shipping_time]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_shipping_time] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_shipping_time', array(&$this, 'wcfmmp_shipping_time_shortcode'));

Shortcode PHP function:

function wcfmmp_shipping_time_shortcode() {
		global $WCFM, $WCFMmp, $post;
  	
  	if( !apply_filters( 'wcfm_is_allow_store_shipping', true ) ) return; 
		if( !apply_filters( 'wcfm_is_allow_shipping_processing_time_info', true ) ) return;
		if( !is_product() ) return;
		
		$wcfm_shipping_options = get_option( 'wcfm_shipping_options', array() );
		$wcfmmp_store_shipping_enabled = isset( $wcfm_shipping_options['enable_store_shipping'] ) ? $wcfm_shipping_options['enable_store_shipping'] : 'yes';
		if( $wcfmmp_store_shipping_enabled != 'yes' ) return;
			
		$vendor_id = 0;
		$product_id = 0;
		if( is_product() && $post && is_object( $post ) ) {
			$product_id = $post->ID;
			$vendor_id = wcfm_get_vendor_id_by_post( $product_id );
		}
		if( !$product_id ) return;
		if( !$WCFM || !$WCFM->frontend || !$WCFM->frontend->is_wcfm_needs_shipping( $product_id ) ) return;
		if( !$vendor_id ) return;
		
		if( $WCFMmp->wcfmmp_vendor->is_vendor_sold_by( $vendor_id ) ) {
			ob_start();
			$WCFMmp->template->get_template( 'shipping/wcfmmp-view-shipping-info.php', array( 'vendor_id' => $vendor_id, 'product_id' => $product_id ) );
			$content = ob_get_clean();
			return $content;
    }
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_more_offers] Shortcode

The WCFM Marketplace shortcode ‘wcfm_more_offers’ displays additional offers for a specific product. It’s only functional when viewing a product and if product multivendor is enabled.

Shortcode: [wcfm_more_offers]

Examples and Usage

Basic example – To display more offers in the product page, use the shortcode without any parameters.

[wcfm_more_offers]

Advanced examples

While the shortcode provided does not include parameters in its function, it does allow for the application of filters. This allows for customization of the output based on your specific needs.

For instance, you can change the ‘Store Hours’ label to something else using the ‘wcfm_store_hours_label’ filter:


add_filter('wcfm_store_hours_label', function($label) {
    return 'Our Operating Hours';
});

In this example, the ‘Store Hours’ label is changed to ‘Our Operating Hours’.

Remember, the ‘wcfm_more_offers’ shortcode will only work on product pages due to the ‘is_product()’ condition in the function. This is because it’s designed to display more offers related to the current product.

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_more_offers] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_more_offers', array(&$this, 'wcfmmp_more_offers_shortcode'));

Shortcode PHP function:

function wcfmmp_more_offers_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;
		
		if( !apply_filters( 'wcfm_is_pref_product_multivendor', true ) ) return;
		
		if( !is_product() ) return;
		
		//$content = '<div class="wcfmmp_more_offers">';
		//$content .= '<span class="wcfmmp-more-offers widget-title"><span class="wcfmfa fa-clock"></span>&nbsp;' . apply_filters( 'wcfm_store_hours_label', __( 'Store Hours', 'wc-multivendor-marketplace' ) ) . '</span><div class="wcfm_clearfix"></div>';
		
		ob_start();
		$WCFMmp->template->get_template( 'product_multivendor/wcfmmp-view-more-offers.php' );
		$content = ob_get_clean();
		
		//$content .= '</div>';
		
		return $content;
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_store_fb_feed] Shortcode

The WCFM Store Facebook Feed shortcode is designed to display a Facebook widget on a store page. It fetches the store’s Facebook URL and displays it within a custom-styled widget. The shortcode fetches the store’s ID, verifies it, and retrieves the store’s Facebook URL. If the URL is valid, it creates a Facebook page widget with specific dimensions and styles. The widget includes the store’s Facebook feed, allowing visitors to follow the store’s updates directly from the website. The shortcode also enqueues a script to handle the widget’s functionality.

Shortcode: [wcfm_store_fb_feed]

Examples and Usage

Basic example – Displays the Facebook feed of a store on a WC Multivendor Marketplace site by using the ‘wcfm_store_fb_feed’ shortcode. This shortcode doesn’t require any parameters as it automatically fetches the store ID based on the page it’s placed on.

[wcfm_store_fb_feed /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_store_fb_feed] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_store_fb_feed', array(&$this, 'wcfmmp_store_fb_widget_shortcode'));

Shortcode PHP function:

function wcfmmp_store_fb_widget_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;
		
		$store_id  = 0;
		if (  wcfm_is_store_page() ) {
			$wcfm_store_url = wcfm_get_option( 'wcfm_store_url', 'store' );
			$store_name = get_query_var( $wcfm_store_url );
			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 ) return;
		
		$store_user   = wcfmmp_get_store( $store_id );
		$store_info   = $store_user->get_shop_info();
		
		if( !isset( $store_info['social']['fb'] ) || empty( $store_info['social']['fb'] ) ) return;
		
		$facebook_url = wcfmmp_generate_social_url( $store_info['social']['fb'], 'facebook' );
		
		if( !$facebook_url ) return;
		
		$custom_css = apply_filters( 'wcfmmp_fb_widget_custom_style', '' );
		
		$content = '';
		
		ob_start();
		
		echo '<div class="wcfm_store_fb_widget" style="margin-bottom:50px;">';
		
		echo '<div id="fb-root"></div>';
    echo '<div class="fb-page" data-href="' . esc_url($facebook_url) . '" 
                               data-width="400" 
                               data-height="500" 
                               data-small-header="true" 
                               data-adapt-container-width="true" 
                               data-hide-cover="false" 
                               data-show-facepile="false" 
                               data-show-posts="true" 
                               style="' . $custom_css . '"></div>';
		
		echo '</div>';
		
		$content .= ob_get_clean();
		
		wp_register_script( 'wcfm_store_fb_widget_script', $WCFMmp->library->js_lib_url_min . 'store/wcfmmp-script-fb-widget.js', array('jquery') );
    wp_enqueue_script( 'wcfm_store_fb_widget_script' );
    $local_variables = array( 'app_id' => '503595753002055', 'select_lng' => 'en_US' );
    wp_localize_script( 'wcfm_store_fb_widget_script', 'wcfm_store_fb_widget_vars', $local_variables );
		
		return $content;
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_store_twitter_feed] Shortcode

The ‘wcfm_store_twitter_feed’ shortcode from the wc-multivendor-marketplace plugin is designed to display a store’s Twitter feed. First, it checks if the page is a store page or a product page and retrieves the store ID accordingly. If no store ID is found, the function ends. Then, it fetches the Twitter URL from the store’s social information. If no Twitter URL is found, the function ends again. Next, it sets up parameters for the Twitter widget and generates the necessary script to display the Twitter feed. The Twitter feed is then displayed within a div element with a custom CSS class. It also includes a script tag to load the Twitter widget script. Finally, the function returns the generated HTML content.

Shortcode: [wcfm_store_twitter_feed]

Examples and Usage

Basic example – A simple usage of the wcfm_store_twitter_feed shortcode to display the Twitter feed of a store.

[wcfm_store_twitter_feed]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_store_twitter_feed] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_store_twitter_feed', array(&$this, 'wcfmmp_store_twitter_widget_shortcode'));

Shortcode PHP function:

function wcfmmp_store_twitter_widget_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;
		
		$store_id  = 0;
		if (  wcfm_is_store_page() ) {
			$wcfm_store_url = wcfm_get_option( 'wcfm_store_url', 'store' );
			$store_name = get_query_var( $wcfm_store_url );
			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 ) return;
		
		$store_user   = wcfmmp_get_store( $store_id );
		$store_info   = $store_user->get_shop_info();
		
		if( !isset( $store_info['social']['twitter'] ) || empty( $store_info['social']['twitter'] ) ) return;
		
		$twitter_url = wcfmmp_generate_social_url( $store_info['social']['twitter'], 'twitter' );
		
		if( !$twitter_url ) return;
		
		$custom_css = apply_filters( 'wcfmmp_twitter_widget_custom_style', '' );
		
		$oembed_params = array( 'omit_script' => 1, 'lang' => 'en', 'maxwidth' => 300, 'maxheight' => 400, 'chrome' => '', 'url' => $twitter_url );
		
		$QUEUE_HANDLE = 'twitter-wjs';
		$URI = 'https://platform.twitter.com/widgets.js';
		$script = 'window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src=' . wp_json_encode( $URI ) . ';fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,"script",' . wp_json_encode( $QUEUE_HANDLE ) . '));';
		
		$content = '';
		
		ob_start();
		
		echo '<div class="wcfm_store_twitter_widget" style="margin-bottom:50px;">';
		
    echo '<div class=" wcfmmp_twitter twitter-timeline-profile">
          <a class="twitter-timeline" data-lang="en" 
                                      data-width="100%" 
                                      data-height="400" 
                                      href="' . esc_url($twitter_url) . '?ref_src=twsrc%5Etfw">Recent Tweets</a></div>';
                                      
		echo '<script>' . esc_js($script) . '</script>';
		
		echo '</div>';
		
		$content .= ob_get_clean();
		
		return $content;
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [wcfm_products_store_filter] Shortcode

The WCFM Marketplace shortcode is used to filter products by store in the WooCommerce shop. It’s activated only on shop and product taxonomy pages. This shortcode triggers the ‘wcfmmp_products_store_filter_shortcode’ function. It fetches a template that displays a geolocation-based product list, allowing users to filter products by vendor location.

Shortcode: [wcfm_products_store_filter]

Examples and Usage

Basic example – Display the store filter on your shop or product taxonomy page.

[wcfm_products_store_filter]

PHP Function Code

In case you have difficulties debugging what causing issues with [wcfm_products_store_filter] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wcfm_products_store_filter', array(&$this, 'wcfmmp_products_store_filter_shortcode'));

Shortcode PHP function:

function wcfmmp_products_store_filter_shortcode( $attr ) {
		global $WCFM, $WCFMmp, $wp;

		if ( ! is_shop() && ! is_product_taxonomy() ) {
				return;
		}
		
		$args = array(); // For future use
		
		ob_start();
		$WCFMmp->template->get_template( 'product-geolocate/wcfmmp-view-product-lists-vendor-filter.php', $args );
		return ob_get_clean();
	}

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/core/class-wcfmmp-shortcode.php

Wc Multivendor Marketplace [fee] Shortcode

The WC-Multivendor-Marketplace plugin shortcode ‘fee’ calculates a fee based on a given percentage, with minimum and maximum limits. It takes three attributes: ‘percent’, ‘min_fee’, and ‘max_fee’. The ‘percent’ attribute is used to calculate the fee. If the calculated fee is less than ‘min_fee’ or more than ‘max_fee’, it adjusts to the set limit.

Shortcode: [fee]

Parameters

Here is a list of all possible fee shortcode parameters and attributes:

  • percent – defines the percentage used for fee calculation
  • min_fee – sets the minimum fee amount possible
  • max_fee – establishes the maximum fee amount possible

Examples and Usage

Basic example – A simple usage of the ‘fee’ shortcode with a percentage attribute.

[fee percent=10 /]

This shortcode will calculate the fee based on 10% of the fee cost.

Advanced examples

Using the ‘fee’ shortcode with both ‘percent’ and ‘min_fee’ attributes.

[fee percent=10 min_fee=100 /]

In this example, the shortcode will calculate the fee based on 10% of the fee cost. However, if the calculated fee is less than 100, it will return 100 as the fee.

Using the ‘fee’ shortcode with ‘percent’, ‘min_fee’, and ‘max_fee’ attributes.

[fee percent=10 min_fee=100 max_fee=500 /]

In this advanced example, the shortcode will calculate the fee based on 10% of the fee cost. If the calculated fee is less than 100, it will return 100. However, if the calculated fee is more than 500, it will return 500 as the fee.

PHP Function Code

In case you have difficulties debugging what causing issues with [fee] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'fee', array( $this, 'fee' ) );

Shortcode PHP function:

function fee( $atts ) {
      $atts = shortcode_atts( array(
          'percent' => '',
          'min_fee' => '',
          'max_fee' => '',
      ), $atts, 'fee' );

      $calculated_fee = 0;

      if ( $atts['percent'] ) {
          $calculated_fee = $this->fee_cost * ( floatval( $atts['percent'] ) / 100 );
      }

      if ( $atts['min_fee'] && $calculated_fee < $atts['min_fee'] ) {
          $calculated_fee = $atts['min_fee'];
      }

      if ( $atts['max_fee'] && $calculated_fee > $atts['max_fee'] ) {
          $calculated_fee = $atts['max_fee'];
      }

      return $calculated_fee;
  }

Code file location:

wc-multivendor-marketplace/wc-multivendor-marketplace/includes/shipping-gateways/class-wcfmmp-shipping-by-zone.php

Conclusion

Now that you’ve learned how to embed the Wc Multivendor Marketplace Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *