If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)

captcha

Featured templates

Woocommerce. How to set random order for products

This tutorial provides a description of how to set random order for products in Woocommerce store.

Woocommerce. How to set random order for products

In order to set random order for products, you should perform the following:

  1. Navigate to the following directory in your cpanel or FTP: wp-content/themes/themeXXXXX/includes, locate a custom-function.php file, and click an Edit button (or edit it with the help of a text editor):

    Woocommerce._How_to_set_random_order_for_products
  2. Paste the following piece of code to the bottom of the file before the last ?>:

    			add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
    			
    			function custom_woocommerce_get_catalog_ordering_args( $args ) {
    			$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
    			
    			if ( 'random_list' == $orderby_value ) {
    			$args['orderby'] = 'rand';
    			$args['order'] = '';
    			$args['meta_key'] = '';
    			}
    			return $args;
    			}
    			
    			add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' );
    			add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' );
    			
    			function custom_woocommerce_catalog_orderby( $sortby ) {
    			$sortby['random_list'] = 'Random';
    			return $sortby;
    			}
    		
    Woocommerce._How_to_set_random_order_for_products1
  3. Save the changes and navigate to the following directory in your WooCommerce Settings: Products–>Display:

    Woocommerce._How_to_set_random_order_for_products2
  4. Check out the Random option under Default Product Sorting directory:

    Woocommerce._How_to_set_random_order_for_products4

Feel free to check the detailed video tutorial below:

Woocommerce. How to set random order for products
 
Live Chat
We help you to choose the right product.
Start chat