Archived topic
Element support
1 reply · Started by chris on June 29, 2021
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;
}
Hi there,
Filters cannot be added as an element.
Try one of these methods instead:
Adding PHP: https://docs.generatepress.com/article/adding-php/