I am trying to: create view loop for featured items in toolset. I have marked a couple of woocommerce products as featured, and went to toolset > settings > front-end content > select custom fields (From hidden custom fields) and the "_featured" field is not showing. I have run this on another site i built, and it was there, i noticed that the other site wasn't running the most current version ,so i updated it to match, and it still showed. I also on the current site i'm building deactivated and deleted both woocommerce and every thing from toolset i had installed, but it did not fix the problem.
Interesting, if I start from scratch using WooCommerce 3.0.5, then create a featured product, the _featured field is not available in the hidden fields dialog.
However if I start from scratch using WooCommerce 2.6.14, create a featured product, the field is available. If I then update to WC 3.0.5, the _featured field remains available. Let me reach out to our 2nd tier supporters for some assistance here. I'm not sure if this is a bug, or something that WooCommerce has purposefully hidden. I'll update you as soon as I receive some information from them, please standby.
It appears that WooCommerce has moved the "featured" product setting around a bit since 3.0. Before, the featured setting was maintained in a custom field related to products. Now, this setting has been moved into a hidden product taxonomy called "product_visibility". As such, Views is unable to access that hidden taxonomy in order to be able to filter on it. So any products that were set as "_featured" before 3.0 can be filtered using the custom field that already existed. However, any products set as featured since 3.0 cannot currently be filtered by Views without some custom code.
I've passed this information along to our developers, who will likely decide to add a fix for this in a future version of WooCommerce Views.
In the meantime, I may be able to provide you some code that will apply this new taxonomy term in a filter on the back-end without adding it through the front-end Views filter GUI. Try adding the following code to functions.php:
add_filter( 'wpv_filter_query', 'featured_products',99,3 );
function featured_products( $query_args,$views_settings, $view_id) {
if ($view_id == 10){
$query_args = array(
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN'
),
),
);
}
return $query_args;
}
Please replace "10" with the ID of the View where you want to display featured products. Let me know the results and we can go from there.