Site logo

Archived topic

Element support

1 reply · Started by chris on June 29, 2021

Viewing posts 1–2 of 2

Hi im trying to impliment this to a hook element for the product arcive only. to make out of stock products display last. Im wondering how i can go about running this through the hook element?

I have tried
<script>
<script type="text/javascript">
and made sure to run php. not sure how to to get it to work.

Code:

add_filter( 'woocommerce_get_catalog_ordering_args', 'bbloomer_first_sort_by_stock_amount', 9999 );
 
function bbloomer_first_sort_by_stock_amount( $args ) {
   $args['orderby'] = 'meta_value';
   $args['order'] = 'ASC';
   $args['meta_key'] = '_stock_status';
   return $args;
}
This archived topic is closed to new replies.