If someone wants to know how i did it:
past this in function.php of your theme:
/**
* List all (or limited) product categories.
*
* @param array $atts
* @return string
*/
function rand_product_categories( $atts ) {
global $woocommerce_loop;
$atts = shortcode_atts( array(
'number' => null,
'orderby' => 'name',
'order' => 'ASC',
'columns' => '4',
'hide_empty' => 1,
'parent' => '',
'ids' => ''
), $atts );
if ( isset( $atts['ids'] ) ) {
$ids = explode( ',', $atts['ids'] );
$ids = array_map( 'trim', $ids );
} else {
$ids = array();
}
$hide_empty = ( $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ) ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array(
'orderby' => $atts['orderby'],
'order' => $atts['order'],
'hide_empty' => $hide_empty,
'include' => $ids,
'pad_counts' => true,
'child_of' => $atts['parent']
);
$rand_product_categories = get_terms( 'product_cat', $args );
if ( '' !== $atts['parent'] ) {
$rand_product_categories = wp_list_filter( $rand_product_categories, array( 'parent' => $atts['parent'] ) );
}
if ( $hide_empty ) {
foreach ( $rand_product_categories as $key => $category ) {
if ( $category->count == 0 ) {
unset( $rand_product_categories[ $key ] );
}
}
}
if ( $atts['number'] ) {
$rand_product_categories = array_slice( $rand_product_categories, 0, $atts['number'] );
}
$columns = absint( $atts['columns'] );
$woocommerce_loop['columns'] = $columns;
ob_start();
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
if ( shuffle($rand_product_categories) ) {
woocommerce_product_loop_start();
foreach ( $rand_product_categories as $category ) {
wc_get_template( 'content-product_cat.php', array(
'category' => $category
) );
}
woocommerce_product_loop_end();
}
woocommerce_reset_loop();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
add_shortcode( 'rand_prod_cat', 'rand_product_categories' );
?>
your new shuffeld categories shortcode is:
[rand_prod_cat number="4" parent="0"]