[Resolved] WooCommerce "Featured" field is not available in Views list of custom fields.

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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

This topic contains 4 replies, has 2 voices, and was last updated by  alisonC 1 week ago. The support staff assigned to this topic is Shane.

Viewing 5 posts - 1 through 5 (of 5 total)
Author
Posts
#569687

I know that I should be able to add custom fields, including the WooCommerce "Featured" field, to the Views GUI so that I can filter by them, etc.

Currently, the WooCommerce "Featured" field doesn't display in the list of custom fields in the Views settings.

I see someone else has already reported this problem: https://wp-types.com/forums/topic/toolset-views-not-showing-_featured-in-view-gui-for-woocommerce/

The fix suggested there does work for now, but this is obviously something that should be on the bug list.

#569763

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi Alison,

Thank you for contacting our support forum.

Unfortunately the for the featured items you will need to use a custom hook to achieve this.

Add the following to your functions.php file and it should only display the featured products.

/* --------------------------------------------- */
// WooCommerce 3+ featured products filter
// Only include "featured" products
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;
}

Just change the $view_id to the id of your view and it should work.

Thanks,
Shane

#569782

Thanks Shane. Like I said, that solution does work for me, but I wanted to file a bug report, given that WooCommerce custom fields are something Views typically supports.

#569796

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi Alison,

Actually this was the reason why this filter is being used because woocommerce moved from using a hidden custom field to a hidden taxonomy so the only way to filter for that term is by using the hook.

We found this out after doing some investigation on the field itself.

Thanks,
Shane

#569976

Ah, that makes sense. Thanks for the explanation!

Viewing 5 posts - 1 through 5 (of 5 total)

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Known issues and their solutions

We document known issues and their solutions in Toolset erratas. Save time by checking there first and seeing if what you are facing is a known issue. This list is kept short. We do our best to resolve all known issues with every release of Toolset plugins.

Support Policy

Toolset staff will help you use the Toolset plugins correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

For more information, read our full Customer Support Policy.

Need custom programming work for your site? Check out our certified partners.