Using this code
_product_new, _product_almost_new, _product_old
function custom_vtp_shop_order($q){
if ( ! $q->is_main_query() ) return;
if (! is_admin() && (is_shop() || is_archive) ) {
$q->set( 'tax_query', array(array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'Sold', 'Service' ),
'operator' => 'NOT IN'
)));
$q->set('meta_query', array(array(
'relation' => 'OR',
'product_new' => array(
'key' => '_product_new',
'value' => '1',
),
'product_almost_new' => array(
'key' => '_product_almost_new',
'value' => '1',
),
'product_old' => array(
'key' => '_product_old',
'value' => '1',
)
)));
/*THIS HAS NO EFFECT*/
$q->set('orderby', array(array(
'product_new' => 'DESC',
'product_old' => 'DESC',
'product_almost_new' => 'DESC',
)
));
}
}
my desirable order of products is
- product_new
- product_old
- product_almost_new
After using $q->set('orderby', array(......) there is no effect. Products always being ordered product_old, product_almost_new, product_new