Store list display

This topic contains 1 reply and 2 voices, and was last updated by towhid 9 years, 3 months ago
Viewing 1 Posts - 1 through 1 (of 1 total)
Author Posts
August 4, 2015 at 2:19 pm 65206
towhid Hi, Im sitting here with your Dokan plugin for WordPress, and im trying to create a Enable / Disable button for the store owners if they are currently editing or doing something else with their site, that they don’t want users to see the process of. I have succesfully created at Enable / Disable button in the Dashboard settings and a argument on the store page that makes it that the store only shows if it is enabled, I did this by editing the dokan_get_store_info() function in theme-functions.php to this (and created at form input in the template-settings.php to edit this value):
function dokan_get_store_info( $seller_id ) {
    $info = get_user_meta( $seller_id, 'dokan_profile_settings', true );
    $info = is_array( $info ) ? $info : array();

    $defaults = array(
        'store_name' => ‘',
	// EDIT HERE - Added ‘store_enabled'
        'store_enabled' => 'no',
        'social'     => array(),
        'payment'    => array( 'paypal' => array( 'email' ), 'bank' => array() ),
        'phone'      => '',
        'show_email' => 'off',
        'address'    => '',
        'location'   => '',
        'banner'     => 0
    );

    $info               = wp_parse_args( $info, $defaults );
    $info['store_name'] = empty( $info['store_name'] ) ? get_user_by( 'id', $seller_id )->display_name : $info['store_name'];

    return $info;
}
(I have added the ‘store_enabled’ argument to the default array) All this works like a charm, the store page displays when it is enabled, and does not display when it is disabled. Now my question / problem is in the Store Listing page (www.domain.com/store-listing) - I would like to make it so that shops that are disabled should not be displayed on the store-listing page.. I dug down in the theme-functions.php file and found the function ( dokan_get_sellers() ) that the /store-listing page use to get the enabled shops, but i’m currently lost on how to get the ‘store_enabled’ for each shop and checking if it is enabled, and then create a new return array only with the shops that have the ’store_enabled’ set to yes:
/**
 * Get seller listing
 *
 * @param int $number
 * @param int $offset
 * @return array
 */
function dokan_get_sellers( $number = 10, $offset = 0 ) {
    $args = apply_filters( 'dokan_seller_list_query', array(
        'role' => 'seller',
        'number'     => $number,
        'offset'     => $offset,
        'orderby'    => 'registered',
        'order'      => 'ASC',
        'meta_query' => array(
            array(
                'key'     => 'dokan_enable_selling',
                'value'   => 'yes',
                'compare' => '='
            )
        )
    ) );

    $user_query = new WP_User_Query( $args );

    $sellers    = $user_query->get_results();

    return array( 'users' => $sellers, 'count' => $user_query->total_users );
}
Any ideas? clues? All help is appreciated, Thank you.
August 5, 2015 at 11:47 am 65365
towhid towhid

Hello Hjalte,

Please allow me some time. I have to check this code for me.

Thanks

Viewing 1 Posts - 1 through 1 (of 1 total)