Список поставщиков Dokan по короткому коду местоположения в Woocommerce

Я хочу, чтобы мои пользователи на моем рынке Dokan могли фильтровать поставщиков по местоположению. Я написал следующий код в моем файле functions.php:

/**
*  list of vendors by location
*
*  @param $atts shortcode attributs
*/
function dokan_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) {
dokan_get_template( 'vendor-list.php', array(
'shop_link'         => Dokan_Vendors::get_vendor_shop_page($vendor->ID),
'shop_name'         => $vendor->pv_shop_name,
'vendor_id'         => $vendor->ID,
'shop_description'  => $vendor->pv_shop_description,
), 'dokan-vendors/front/', wcv_plugin_dir . 'templates/front/' );
} // End foreach

$html .= '<ul class="dokan_vendorslist">' . ob_get_clean() . '</ul>';
return $html;
}
add_shortcode('dokan_vendors_location', 'dokan_vendors_location');

/* END */

Но сейчас, когда я вставляю шорткод на свой сайт, я вижу пустое место.

Что я делаю не так в этом коде?

Любая помощь приветствуется.

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector