by default custom order + name is set in my woocommerce product sorting. we have products with certain order and we want when someone enters the category to sort items first by the order we have them set and then from less to more price. i was trying the below code but that isn't working and i don't understand further.
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 ( 'new_default_list' == $orderby_value ) {
$args['orderby'] = 'menu_order price';
$args['order'] = 'asc';
$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['new_default_list'] = 'Menu Order + Price';
return $sortby;
}