add_filter('woocommerce_get_catalog_ordering_args', 'woocommerce_get_catalog_ordering_name_args');
function woocommerce_get_catalog_ordering_name_args($args)
{
if (isset($_GET['orderby'])) {
switch ($_GET['orderby']):
case 'name_list_asc':
$args['orderby'] = 'meta_value';
$args['order'] = 'ASC';
$args['meta_key'] = 'courses-page_description_start_date';
break;
case 'price-desc':
$args['orderby'] = '_regular_price';
$args['order'] = 'DESC';
$args['type'] = 'product';
$args['meta_key'] = '_price';
break;
case 'name_list_desc':
$args['orderby'] = 'title';
$args['order'] = 'DESC';
$args['meta_key'] = '';
break;
endswitch;
} else {
$args['orderby'] = 'meta_value';
$args['order'] = 'ASC';
$args['meta_key'] = 'courses-page_description_start_date';
}
return $args;
}
<?php
add_filter('woocommerce_catalog_orderby', 'wc_customize_product_sorting');
function wc_customize_product_sorting($sorting_options){
$sorting_options = array(
'popularity' => __( 'Популярные', 'woocommerce' ),
'date' => __( 'Новинки', 'woocommerce' ),
'price' => __( 'Сначала дешёвые', 'woocommerce' ),
'price-desc' => __( 'Сначала дорогие', 'woocommerce' ),
'rating' => __( 'Высокий рейтинг', 'woocommerce' ),
);
return $sorting_options;
}
?>