Default sorting SKU changes frontpage widgets query
-
After setting the default sorting to SKU, the homepage widget “New in” sorts with this default also.
I need the default sorting for the catalogue to be according to SKU, while the “New in” should show new products.
How is this done?
-
Hi,
What is this “New in” widget you are referring to?
Sorry it’s not a widget. It’s part of Storefront’s homepage template. It’s the storefront_recent_products:
<?php /** * Functions hooked in to homepage action * * @hooked storefront_homepage_content - 10 * @hooked storefront_product_categories - 20 * @hooked storefront_recent_products - 30 * @hooked storefront_featured_products - 40 * @hooked storefront_popular_products - 50 * @hooked storefront_on_sale_products - 60 * @hooked storefront_best_selling_products - 70 */ do_action( 'homepage' ); ?>Hum, Ok I think I got it now.
Please add this to your functions.phpadd_filter( 'woocommerce_default_catalog_orderby', function ( $default ) { if ( ! is_shop() ) { return $default; } return 'sku-asc'; } );This will make the default sorting to SKU programmatically, but only on shop page.
Now you can set the default sorting to most recent.-
This reply was modified 7 years, 8 months ago by
Pablo Pacheco.
Hi and thanks for the response,
this didn’t really solve the issue but worked as a workaround. By changing the above filter to this:
add_filter( 'woocommerce_default_catalog_orderby', function ( $default ) { if ( ! is_shop() ) { return 'date-asc'; } return $default; } );Anytime 🙂
Great! Thanks for letting me know.
I’ll close the ticket then but if you have more questions let me know.See you
-
This reply was modified 7 years, 8 months ago by
The topic ‘Default sorting SKU changes frontpage widgets query’ is closed to new replies.