Hello @hystericallyme ,
Thanks for trying our product.
I will request you to check the fact that the function you are trying to use requires an array as args to provide the correct data.
You can also use the default WordPress query to pull all the vendors. Here is an example –
<div class="seller-list">
<?php
$user_query = new WP_User_Query( array( 'role' => 'seller' ) );
$sellers = $user_query->get_results();
?>
<select>
<?php foreach ( $sellers as $key => $user): ?>
<option value="<?php echo esc_attr( $user->ID ) ?>" <?php selected( $selected, $user->ID ); ?>><?php echo esc_html( $user->display_name ); ?></option>
<?php endforeach ?>
</select>
</div>
I hope the above solution works for you.
So I have to make my own query then? The function above I found researching for help online. It comes from this plugin, and what I saw was that it took an integer parameter. I understand WP_Query takes an array, but this was a different function I had found in the article.
Hello @hystericallyme ,
Please try the below format I prepared. I tested and it works –
<div class="seller-list-2">
<?php
$sellers = dokan_get_sellers(
array(
'number' => 15,
)
);
?>
<select>
<?php foreach ( $sellers['users'] as $seller):
$store_info = dokan_get_store_info( $seller->ID );
$store_name = isset( $store_info['store_name'] ) ? esc_html( $store_info['store_name'] ) : __( 'N/A', 'dokan' );
$store_url = dokan_get_store_url( $seller->ID );
?>
<option value="<?php echo $store_url ?>" <?php selected( $selected, $seller->ID ); ?>><?php echo esc_html( $store_name ); ?></option>
<?php endforeach ?>
</select>
</div>
Thank you.
Thanks for responding and giving me an example with the Dokan function! I just like to use built in functions when possible so it’s less likely to break with future updates.
The article I found must have been outdated (not on your website), this is very helpful. Just wish there were more resources for developers looking to expand with your plugin 🙂
Hello @hystericallyme ,
Thanks for the compliments. If you need further help do not forget to contact us.
Regards,