Woocommerce elementor sort order by stock quantity
Using Woocommerce Elementor order by stock quantity. Also, help with general sorting problems. We also need to sort order stock. Our clients, clients often need large quantities of products for their projects.
If a client can’t afford a bespoke shoopping website, we recommend woocommerce for wordpress. This is compatible with Elementor Pro and Rank Math.
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.
If you don’t have a child theme read this https://elementor.com/blog/wordpress-child-theme/
// 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.
Remove the Reviews from the dropdown
We have not enabled reviews on our products, so there are no reviews to be sorted by.
woocommerce elementor sort order by stock quantity
// 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 Sort Order by Stock Values
Some clients need large volumes of our products. Endless scrolling is not helping the customer experience.
Alphabetically sort numerical values Why? 100 before 2
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 Order By Price Not Working Correctly
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