• Seems like this no longer works. Product still shows as visible. When I change product in the admin to hidden I cannot see any meta key or value changes. Odd.

Viewing 1 replies (of 1 total)
  • Currently working on a project for an existing woocommerce shop. I noticed exactly the same thing. Old products have this meta_key, new products do not. Also noticed the meta_value is no longer updated..

    So after a quick search i found the following info.

    A big focus for the WooCommerce dev team in 3.0 and especially in the upcoming 3.1 release is performance improvement.
    Doing queries on meta data requires extra SQL joins and is quite inefficient at scale. Querying WP terms is much more efficient and as a result, much faster.

    So they moved visibility and feature settings to a new product visibility taxonomy.

    Here a simple example to get featured products with Woo 3.0+

    
    $meta_query  = WC()->query->get_meta_query();
    $tax_query   = WC()->query->get_tax_query();
    $tax_query[] = array(
    	'taxonomy' => 'product_visibility',
    	'field'    => 'name',
    	'terms'    => 'featured',
    	'operator' => 'IN',
    	);
    
    $product_args = array(
    	'post_type'           => 'product',
    	'post_status'         => 'publish',
    	'posts_per_page'      => '-1',
    	'orderby'             => 'modified',
    	'order'               => 'DESC',
    	'meta_query'          => $meta_query,
    	'tax_query'           => $tax_query,
    );
    

    Best regards,
    Bjorn

    • This reply was modified 6 years, 5 months ago by bjornwebdesign. Reason: typo
Viewing 1 replies (of 1 total)
  • The topic ‘Setting the _visibility meta value to hidden’ is closed to new replies.