I have 15 product categories and 50+ products into my WooCommerce website. I want to arrange (sort) products from a specific category with an array of product ids.
This is my code attempt:
add_filter( 'woocommerce_get_catalog_ordering_args', 'my_ordering_function', 10, 2 );
function my_ordering_function( $args ) {
$product_category = 'engineering-service';
if( ! is_product_category($product_category) ) return $args;
$args['post__in'] = array( 181, 8622, 8689, 8832 );
$args['orderby'] = 'post__in';
$args['order'] = 'ASC';
return $args;
}
This doesn't work.
Which hooked function do I need to use? How can I do that programmatically?