Quote from jelemk on September 9, 2020, 01:28
I purchased the filter plugin through CodeCanyon and it's working well. I however want to add an extra 'orderby' to my WooCommerce product query, so that all out of stock products are shown last. The code underneath is working. The out of stock products are shown last, and the user can still filter.
function woocommerce_order_out_of_stock_products_last($args) {
if(is_woocommerce() && !is_admin() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
$args['orderby'] = " wc_product_meta_lookup.stock_status ASC, " . $args['orderby'];
}
return $args;
}
add_filter( 'posts_clauses', 'woocommerce_order_out_of_stock_products_last', 999, 1 );
However, only the price filter is showing up when using this and all of the other filters are not showing up. It seems to interfere with the plugin's code.
How can I make sure the filters do show up when using this snippet?
I purchased the filter plugin through CodeCanyon and it's working well. I however want to add an extra 'orderby' to my WooCommerce product query, so that all out of stock products are shown last. The code underneath is working. The out of stock products are shown last, and the user can still filter.
function woocommerce_order_out_of_stock_products_last($args) {
if(is_woocommerce() && !is_admin() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
$args['orderby'] =" wc_product_meta_lookup.stock_status ASC," . $args['orderby'];
}
return $args;
}
add_filter( 'posts_clauses', 'woocommerce_order_out_of_stock_products_last', 999, 1 );
However, only the price filter is showing up when using this and all of the other filters are not showing up. It seems to interfere with the plugin's code.
How can I make sure the filters do show up when using this snippet?