[Resuelto] WooCommerce Featured Flag in Views Filter
Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.
Problem:
How to add a Views filter for the built-in WooCommerce "featured" product feature.
Solution:
WooCommerce stores this as a taxonomy term, namely the "Product Visibilty" taxonomy which can be included as a filter in Views.
This support ticket is created hace 6 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Tell us what you are trying to do?
I'm trying to use the inbuilt Woocommerce "Featured Product" flag in a Views filter. This is the one that shows stars on the product listing page.
Is there any documentation that you are following? https://toolset.com/forums/topic/featured-flag-in-woocommerceviews/
This thread gives instructions on how to add _featured to the views filter, but the thread is from 5 years ago so maybe things have changed since.
I've selected a number of items as Featured on the product listing page.
I've been to Settings > Front End Content >> Hidden Custom Fields and clicked on "Select custom fields". However _featured is not in the list of fields, nor is any other field that looks like it might be the one.
I also tried this on another Woocommerce site just to check if it was something site-specific. It was the same there.
I just checked on a local test site and I marked a product as featured (by clicking the star on the product listing page in the backend).
I then went to the wp_postmeta table of the database and checked the custom fields for that product post.
There is no such field as _featured.
I guess WooCommerce have changed how/where they store this data.
If it is stored in a custom table then it wouldn't be amenable to using in a Views filter, but I would first try to establish where WC now store this data.
(I would look myself but the queue is currently very loaded and I'm trying to help as many clients as possible.)
OK I see what you mean. Right, Woocommerce now stores "Featured" as a Taxonomy. I have found it in my 'terms' table, and found the relationships between that taxonomy and the products in the 'term_relationships' table.
For some reason it's not shown on the Dashboard for taxonomies for products. Nor does it appear in the taxonomy filter selection. I don't know what criteria Views uses to pick which to display but my guess it that WC sets the taxonomy up in a very basic way so views doesn't find some of the info it would need.
I know it's low priority so don't spend time on it unless you clear all the important stuff 🙂