Отображение имени поставщика докана на страницах отдельных продуктов Woocommerce

В woocommerce я использую плагин Dokan и пытаюсь отобразить название поставщика, рейтинг и местоположение поставщика на отдельных страницах продукта.

Я попытался этот код для отображения имени поставщика, но не повезло:

//show store name
add_action( 'woocommerce_single_product_summary', 'show_store_name', 20 );
function show_store_name() {
printf( '<b>Seller Name:</b> <a href="%s">%s</a>', dokan_get_store_url(
$author->ID ), $store_info['store_name'] );
}

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

1

Решение

Я не использую докан плагин. Вот способ получить (опубликовать) идентификатор автора и заставить ваш код работать:

add_action( 'woocommerce_single_product_summary', 'display_author_name', 20 );
function display_author_name() {
// Get the author ID (the vendor ID)
$vendor_id = get_post_field( 'post_author', get_the_id() );
// Get the WP_User object (the vendor) from author ID
$vendor = new WP_User($vendor_id);

$store_info  = dokan_get_store_info( $vendor_id ); // Get the store data
$store_name  = $store_info['store_name'];          // Get the store name
$store_url   = dokan_get_store_url( $vendor_id );  // Get the store URL

$vendor_name = $vendor->display_name;              // Get the vendor name
$address     = $vendor->billing_address_1;           // Get the vendor address
$postcode    = $vendor->billing_postcode;          // Get the vendor postcode
$city        = $vendor->billing_city;              // Get the vendor city
$state       = $vendor->billing_state;             // Get the vendor state
$country     = $vendor->billing_country;           // Get the vendor country

// Display the seller name linked to the store
printf( '<b>Seller Name:</b> <a href="%s">%s</a>', $store_url, $store_name );
}

Код помещается в файл function.php вашей активной дочерней темы (или активной темы). Это должно работать сейчас.

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

Код основан на эта связанная тема.

0

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

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

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