Home Forums Theme Support Dokan Store list display

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  towhid 3 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #65206

    Hjalte
    Member
    Post count: 1

    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.

    #65365

    towhid
    Participant
    Post count: 4505

    Hello Hjalte,

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

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Store list display’ is closed to new replies.