• Resolved Bolder Elements

    (@hystericallyme)


    I hope it’s okay to write here, I’m hoping someone can help! I’ve been working on compatibility between Dokan and my shipping plugin. A user recently brought to my attention that the vendors select box I created was not loading more than 10 vendors. I’ve tried things like

    dokan_get_sellers(-1);
    dokan_get_sellers(9999);

    But no matter what, it always pulls just 10 vendors. Can you help determine how I can populate the select box will ALL registered vendors? Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thread Starter Bolder Elements

    (@hystericallyme)

    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.

    Thread Starter Bolder Elements

    (@hystericallyme)

    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,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Help with a Dokan Function’ is closed to new replies.