Skip Navigation

[Closed] Visibility issue for WooCommerce products

This support ticket is created 2 years, 8 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 2 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2309751
2260415-Schermafbeelding_2022_01_06_om_21.25.43.png

Tell us what you are trying to do?
This is a follow up for ticket #2260415
Back then I did not have a testsite available. Now it's there for you to continue to look into this. I can share access to this website.

but it doesn't work for me. I cannot find the product visibility as a taxonomy when adding a filter. It just isn't there. The instruction seems ok, but is also a bit short. Anything that I need to check to be able to filter on this taxonomy?

Attached image is in Dutch - I would expect the ' product visibility' in this list. But it isn't neither anything in Dutch that looks like it. Is this the right place to look for it?

Is there any documentation that you are following?
https://toolset.com/forums/topic/exclude-products-from-view-if-woocommerce-catalog-visibility-is-set-to-hidden/

Is there a similar example that we can see?

What is the link to your site?
Testsite at hidden link

#2309917

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL where you want to display the products and what view you created and tell me with what product you set the visibility and what products you would like to display.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2311073

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please try to add the following filter code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

add_filter('pre_get_posts','func_exclude_catalog_hidden_products',99,1);
function func_exclude_catalog_hidden_products( $query ) {
    
    if (!is_admin() && $query->is_main_query() and  $query->is_tax( 'pa_darts-item' ) ) {
     
      $args = array(
   				 'visibility' => 'hidden',
   				  'return' => 'ids'
				);
		
      $hidden_products = wc_get_products( $args );
     $query->query_vars['post__not_in'] = $hidden_products; 
    }
     
  return $query;
}

- feel free to adjust the above code for your any other additional tax archive

I setup the archive and I can see its not displaying the hidden product:
- hidden link

#2311583

Hi Minesh
Thank you for checking and the code
On the test site, the product still shows on the product category, which was the originally reported issue: hidden link
So it wasn't solved.
And by the way, isn't this something that should work out of the box, without having to add custom code?

Please have another look why the items are still showing on the category pages.
Thanks! Best regards Robbert

#2311585

Sorry I pasted the wrong link.
Something is now broken on the testsite
The original link hidden link completely lost its formatting now.
It should look like this: hidden link
And now is just a list of items. What happened here?
Thanks Robbert

#2312179

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The thing is that product_visibility taxonomy is a hidden taxonomy and its managed by WooCommerce.

To get filter products with product visibility on archive we will require to use the pre_get_posts hook.

The original link hidden link completely lost its formatting now.
===>
I had set the archive to display using archive created using Toolset:
- hidden link

I've now stop to use Toolset archive and now it does displays the archive correctly as you want:
- hidden link

I've set the following product visibility as hidden:
- hidden link

And I can see that its not get displayed with archive:
- hidden link

#2312575
Schermafbeelding 2022-03-09 om 20.13.43.png

Ok thanks, that for itself is clear, but not a solution.
I created the archive page with Toolset, because on every product we're showing some of the additional fields (see attached).
In other words, I need the toolset archive - and to have it look like I had it before. Is that still possible if I add the code you sent earlier?

#2312831

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - irrespective of either you use normal archive or archive created using Toolset.

The hook "pre_get_posts" will run in both cases.
=> https://developer.wordpress.org/reference/hooks/pre_get_posts/

If you still see its not working as expected with your site, please share access details to your site where you see its not working and I'm happy to take a look at it.

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Visibility issue for WooCommerce products’ is closed to new replies.