dimanche 29 avril 2018

how to show product randomly in woo-commerce slider

how to show product randomly in woo-commerce slider. now I use this code in function.php and some of my page work random but slider not working.

this is webpage : fidarabzar.ir

 [fusion_products_slider picture_size="auto" cat_slug="مته" number_posts="30" carousel_layout="title_on_rollover" autoplay="yes" columns="5" column_spacing="" scroll_items="" show_nav="yes" mouse_scroll="no" show_cats="yes"show_price="yes" show_buttons="yes" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""][/fusion_products_slider ]

php code

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;
}




Aucun commentaire:

Enregistrer un commentaire