• I recently edited Woocommerce’s Products On-Sale widget making it display random products marked on-sale by changing the line ‘orderby’ => ‘date’, to ‘orderby’ => ‘rand’,. Now I want to edit the Featured Products widget to do the same. However, I can’t seem to get it to work. I have changed to the code to:

    $query_args['meta_query'][] = array(
    'key' => '_featured',
    'value' => 'yes',
    'orderby' => 'rand'
    );

    but it still does not display random products marked featured. Can anyone please help me out. Thanks in advance!

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor James Koster

    (@jameskoster)

    That’s because you’re modifying the _meta query_.

    In 2.1 you can order the products randomly.

    I changed the line 84 and worked fine:

    <?php $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => 'rand');

    Just in case anyone stumbles upon b/c they wish to change the Products On-Sale widget to random like I did, here is the file you must edit:

    woocommerce/classes/widgets/class-wc-widget-onsale.php

    Search for orderby like peer_012 stated and change ‘date’ to ‘rand’

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce Featured Products widget’ is closed to new replies.