• Resolved Benoit

    (@bmasson)


    Hi,

    I would like to display the cart of vendor random for the equality. But I have already test orderby=”rand” but it doesn’t work.

    Have you any solution ?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Tanjir Al Mamun

    (@tanjiralmamun)

    Hi @bmasson,

    Currently, displaying stores randomly on the store list page is unavailable in Dokan.

    Thank you,

    Hi @bmasson ,

    If you want to bring any modification on the Vendor Listing page, you will need to modify the store-lists-filter.php file.

    You can find the file by navigating to wp-content > plugins > dokan-lite > templates > store-lists-filter.php

    I hope this helps.

    Thank you.

    Thread Starter Benoit

    (@bmasson)

    Hi,

    What do I need to change in the file store-lists-filter.php so that the sellers are displayed randomly?

    Have you already done this?

    Thank you for your help`

    Plugin Support Nazmul Hassan

    (@nazmulhassann20)

    Hello @bmasson,

    If you want to show store randomly on the store-page on each page load then you can use the below codes on your child-theme functions.php file –

    function dokan_store_listing_orderby_ramdom_filter( $seller_args ) {
        $seller_args['orderby'] = 'dokan_store_rand';
        return $seller_args;
    }
    add_filter( 'dokan_seller_listing_args', 'dokan_store_listing_orderby_ramdom_filter', 99 );
    function dokan_store_listing_orderby_filter_query( $query ) {
        if ( $query->query_vars['orderby'] === 'dokan_store_rand' ) {
            $order_by = [
                'ID',
                'user_login, ID',
                'user_email',
                'user_registered, ID',
                'user_nicename, ID'
            ];
            if ( false === ( $selected_orderby = get_transient( 'dokan_store_listing_random_orderby' ) ) ) {
                $selected_orderby = $order_by[ array_rand( $order_by, 1 ) ];
                set_transient( 'dokan_store_listing_random_orderby', $selected_orderby, MINUTE_IN_SECONDS * 10 );
            }
            $query->query_orderby = "ORDER BY $selected_orderby";
        }
    }
    add_action( 'pre_user_query' , 'dokan_store_listing_orderby_filter_query' );

    This will show the store thumbnail randomly on the store-list page after each page load by the customer. Please note that if you need more modification then feel free to use my given code and extend as you need.

    Hi Nazmul,

    I tried this but it doesn’t seem to work. When I first install the code, it will rearrange my stores…but their placements don’t change with new views after that. They just remain in the same positions. Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to order by random vendor list’ is closed to new replies.