I would like to have my products archive show products marked as being featured first, and then alphabetically as a secondary sort. However, I don't see the WooCommerce featured option listed under the possible fields to sort on. Can you assist? The ability to mark a product featured is built-in with WooCommerce so I'm hoping this field can be used as a sort. Thanks.
- Aaron
Hello and thank you for contacting Toolset support.
WooCommerce featured products are handled through a hidden custom taxonomy "product_visibility" instead of a custom field. Toolset views are just a wrapper around the WP_Query class from WordPress. WordPress does not offer a supported way of ordering with a custom taxonomy. However, it can be achievable through some custom code. Check these pages:
- https://stackoverflow.com/questions/46246614/get-woocommerce-featured-products-in-a-wp-query
- https://stackoverflow.com/questions/60494185/promote-featured-products-to-top-of-category-in-woocommerce
- https://stackoverflow.com/questions/50278914/woocommerce-display-featured-products-at-top-of-category-page
- enlace oculto
This being said, the easiest way, I can imagine, to achieve what you want is using a custom field. Create a select or radio field for the products, and add two possible options(Featured/Not featured) with the respective values(1/0). And "Not featured(0)" is the default option. Then manually make update this field on the products. That way, you can choose this field in the primary order, and choose the product's title.
You may create a custom code that can mirror this for you upon product saving https://developer.wordpress.org/reference/hooks/save_post/
Or, you may just display the featured products using a shortcode above the archive loop, and let them appear in the loop too. They may be duplicated by the page, but that would be the easy solution.
https://docs.woocommerce.com/document/woocommerce-shortcodes/#section-9
I hope this answers your question. Let me know if you have any further questions.