Woocommerce Elementor Pro Product Sort Widget
Using Woocommerce Elementor Pro order by stock quantity solution. Also help with general sorting problems.
There is no sort by widget in elementor pro?
We need to sort our products! Our customers need to be able to see the most expensive or cheapest products. Here is what we did to solve the problem.
In your child theme functions.php add.
// Creating Shortcode for Product Sorting add_shortcode('wc_sorting','woocommerce_catalog_ordering');
Drag the Shortcode widget onto the elementor pro page builder and type [wc_sorting]
The sort by drop-down will appear to your customers.
If you don’t have a child theme read this https://elementor.com/blog/wordpress-child-theme/
Remove the Reviews from the dropdown
We have not enabled reviews on our products, so there are no reviews to be sorted by.
// Edit WooCommerce dropdown menu item of shop page// // Options: menu_order, popularity, rating, date, price, price-desc function my_woocommerce_catalog_orderby( $orderby ) { unset($orderby["rating"]); return $orderby; } add_filter( "woocommerce_catalog_orderby", "my_woocommerce_catalog_orderby", 20 );
Woocomerce Order by Stock Values
Some clients need large volumes of our products. Endless scrolling is not helping the customer experience.
We did install some of the popular sorting plugins but for some reason, they sorted stock alphabetically. 1,100,2,300 This doesn’t help our customers at all.
// Ordering products based on the stock quantity values function filter_woocommerce_get_catalog_ordering_args( $args, $orderby, $order ) { switch( $orderby ) { case 'availability': $args['orderby'] = 'meta_value_num'; $args['order'] = 'DESC'; $args['meta_key'] = '_stock'; break; } return $args; } add_filter( 'woocommerce_get_catalog_ordering_args', 'filter_woocommerce_get_catalog_ordering_args', 10, 3 ); // Orderby setting function filter_orderby( $orderby ) { $orderby['availability'] = __( 'Availability', 'woocommerce' ); return $orderby; } add_filter( 'woocommerce_default_catalog_orderby_options', 'filter_orderby', 10, 1 ); add_filter( 'woocommerce_catalog_orderby', 'filter_orderby', 10, 1 );
WooCommerce – Sorting problem sorted
When we first added the changes above, we were so happy! Then we realised the results were not in the correct order “What a pain!”. Don’t worry, there is a solution…
WooCommerce > Status > Tools > Product lookup tables – Click Regenerate
https://stackoverflow.com/questions/47056744/woocommerce-order-by-price-not-working-correctly
More help with woocommerce sorting options
Appearance > Customize > WooCommerce > Product Catalogue