Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * list of vendors by location
- *
- * @param $atts shortcode attributs
- */
- function wc_vendors_location( $atts ) {
- $html = '';
- extract( shortcode_atts( array(
- 'orderby' => 'display_name',
- 'order' => 'ASC',
- 'per_page' => '12',
- 'columns' => '4',
- 'show_products' => 'yes',
- 'location' => '',
- 'org' => '',
- ), $atts ) );
- // Hook into the user query to modify the query to return users that have at least one product
- if ($show_products == 'yes') remove_action( 'pre_user_query', array( $this, 'vendors_with_products') );
- // Get all vendors
- $vendor_total_args = array (
- 'role' => 'vendor',
- 'meta_key' => 'pv_shop_slug',
- 'meta_value' => '',
- 'meta_key' => 'location',
- 'meta_value' => $location,
- 'meta_key' => 'organization',
- 'meta_value' => $org,
- 'orderby' => $orderby,
- 'order' => $order,
- );
- if ($show_products == 'yes') $vendor_total_args['query_id'] = 'vendors_with_products';
- $vendor_query = New WP_User_Query( $vendor_total_args );
- $all_vendors =$vendor_query->get_results();
- ob_start();
- // Loop through all vendors and output a simple link to their vendor pages
- foreach ($all_vendors as $vendor) {
- wc_get_template( 'vendor-list.php', array(
- 'shop_link' => WCV_Vendors::get_vendor_shop_page($vendor->ID),
- 'shop_name' => $vendor->pv_shop_name,
- 'vendor_id' => $vendor->ID,
- 'shop_description' => $vendor->pv_shop_description,
- ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
- } // End foreach
- $html .= '<ul class="wcv_vendorslist">' . ob_get_clean() . '</ul>';
- return $html;
- }
- add_shortcode('wc_vendors_location', 'wc_vendors_location');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement