Adding a search/sort parameter for quantity
-
I was shuttled over here by the devs at GIT. Hopefully someone here will be able to help me out.
Perhaps my attempt was overly simplistic. Suffice to say, it didn’t work:
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); function custom_woocommerce_get_catalog_ordering_args( $args ) { $orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); if ( 'by_quantity' == $orderby_value ) { $args['orderby'] = 'meta_value'; $args['order'] = 'desc'; $args['meta_key'] = 'stock'; } return $args; }
What I’d rather do is filter class-wc-settings-products.php and add the ability to do a default sort by quantity in the settings, since that’s really what they want. If I can add it to the base code, then I can make it a default directly through the WP Settings.
Could one of you help me out with that filter?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Adding a search/sort parameter for quantity’ is closed to new replies.