Hide WooCommerce Product If Price Is Zero

To add alphabetical sorting in your WooCommerce store, Add this code in your theme’s functions.php file of your active child theme (or theme).

Save the file and see you have just created a new product sorting option. Reload the shop and settings pages to see the change in action.

//Adding Alphabetical sorting option to shop and product settings pages
function alphabetical_shop_ordering( $sort_args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'alphabetical' == $orderby_value ) {
$sort_args['orderby'] = 'title';
$sort_args['order'] = 'asc';
$sort_args['meta_key'] = '';
}
return $sort_args;
}
add_filter( 'woocommerce_get_catalog_ordering_args', 'alphabetical_shop_ordering' );

function custom_wc_catalog_orderby( $sortby ) {
$sortby['alphabetical'] = 'Sort by Name: Alphabetical';
return $sortby;
}
add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_wc_catalog_orderby' );
add_filter( 'woocommerce_catalog_orderby', 'custom_wc_catalog_orderby' );

Leave a Comment

Scroll to Top