Skip Navigation

[Resolved] Woocommerce hidden products are visible

This thread is resolved. Here is a description of the problem and solution.

Problem: A search filter option for "hidden products" is visible in my custom search archive for the Products post type (Shop archive), and Products that should be hidden are displayed in the search results.

Solution: Remove the undesired "hidden products" term from the Product Categories taxonomy, and update to the latest versions of all Toolset plugins.

This support ticket is created 3 years, 7 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 11 replies, has 3 voices.

Last updated by Waqar 2 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#2029483

Tell us what you are trying to do?

Make sure that no hidden products can be seen in the shop.

Is there any documentation that you are following?

I've tried to implement a few snippets of code I've found in functions.php but nothing is working.

Is there a similar example that we can see?

Not that I can think of.

What is the link to your site?

hidden link - you'll need the login details

#2029763
Screen Shot 2021-04-22 at 8.48.37 AM.png

Hello, can you tell me more about how you have "hidden" products? Are they hidden with the catalog visibility feature (screenshot here), or "draft" post status, or some other feature of WooCommerce or one of its extensions?

If you would like to provide login credentials in the private fields here I can take a closer look as well.

#2031697

Hi Christian

I made some changes with reference to one of your earlier support threads - https://toolset.com/forums/topic/hide-woocommerce-products-in-views/ which is a workaround but it gets us closer to finishing the site before Monday's launch.

I also added some jQuery - $('#product_cat-hidden-products').parent().remove(); to remove the category from the Taxonomy Filter. There's probably a better way to do that but I couldn't figure it out.

Many thanks
Steve

#2032507

Okay there is a term called "Hidden Products" in your site's Product Category taxonomy, and one Product (Basil MP) has that term assigned. The "Hidden Products" term that actually manages the status in WC is in a taxonomy called "Product Visibility". The term slug is "hidden_products" but the taxonomy slug is now "product_visibility", not "product_cat". So I think you should unassign the Hidden Product term from this Product:
hidden link

Then you should delete the Hidden Products term from the Product Category taxonomy here:
hidden link

That should remove the term from the taxonomy in the backend, and also remove the term from the filter options list in custom search Archives/Views.

After managing the Hidden Product term term in this manner, I suggest removing conditionals from the loop, and removing any custom code you have placed in functions.php to help facilitate hiding results. Once we have established that baseline, we can go about replacing any necessary custom code or conditionals. Please let me know once this is complete, and we can go from there.

FYI - I think the term "Reusable bags" is spelled incorrectly in the Product Category taxonomy. It's currently spelled "Resuable bags", and would be pretty easy to miss in final checks before launch.

#2034729

I've cloned the site to hidden link so we're not disrupting the other people working on product updates. All login credentials remain the same, and FTP access will now take you to the root of dev.unclefills.im.

I've unassigned the Hidden Product term from Basil MP, and I've deleted the Hidden Products term from the Product Category taxonomy. I've also removed conditionals from the loop, and removed anything in functions.php and any Javascript that was hiding results.

Thanks for the heads up about the Resuable bags error which I've passed on. There are quite a few more!

#2035527
Screen Shot 2021-04-28 at 9.33.41 AM.png
Screen Shot 2021-04-28 at 9.32.24 AM.png
Screen Shot 2021-04-28 at 9.32.11 AM.png

Okay thanks for the update and the dev environment. I can see that the "hidden products" filter is no longer visible, so removing that term seems to have fixed that issue. Next, I loaded the shop and saw that the first product displayed upon page load is "Ruby's Garlic Mayo":
hidden link

I edited that product and set the catalog visibility to "hidden", then reloaded the Shop page. Now that product no longer appears in the shop. So that "hidden" setting seems to be working as expected in this simple test scenario. I went through about twenty products shown in the shop but didn't find any that should be hidden, so I'm not sure what I should be looking for here. Can you describe a scenario that produces invalid results now, so I can investigate further?

I have reverted the Ruby's change so you can try the same test if you'd like. Ruby's is again showing in the shop.

#2037235

When the front page loads all products with their visibility set to hidden are hidden. But if you sort them alphabetically, and then sort by latest products, you'll see products appear that are supposed to be hidden. The same thing happens if you search for anything so it looks like something that happens whenever a Query Filter is used.

I've set visibility to hidden for Ruby's Garlic Mayo. If you load the front page you won't see it, but if you hit Go and submit an empty search it will appear.

I don't think this has any bearing on the problem because Ruby's Garlic Mayo doesn't fit the criteria, but we use the WooCommerce Product Bundles plugin so we can link child products to hidden products which hold the inventory. This allows us to enable purchasing of quantities greater than one. The hidden products all have MP in their title e.g 'Basil MP'.

#2039727

Okay thanks for the additional information. I'm able to see the problem you described on the dev environment, but I'm not able to replicate the same problem on my local test site. In my local environment, the hidden setting is respected in search results, so I'm not sure what could be the problem here. Is it okay for me to update your Toolset plugins to the latest versions in the dev environment and run a few more tests, like disabling other plugins temporarily while I test the results?

#2039867

Ok, thanks for the update. Please feel free to make whatever changes you need to in the dev environment.

#2040937

Thanks, I've updated to the latest versions of Toolset plugins and I'm no longer seeing Ruby's or any other products with MP in the title after performing a search. Can you take another look in the dev environment and tell me any specific products that should not be shown after performing a search?

#2045075

It all works now thanks Christian. I wasn't aware that the plugins weren't up-to-date. I don't remember seeing any prompts from WordPress about updates being available.

They deployed the site today so I'll have to wait for an opportunity before I can apply the fixes. I have other problems I need to look at but I'll raise another support ticket for that.

Many thanks for your help.

#2451167

Update: For someone looking for a way to exclude the 'hidden' WooCommerce products from the "Search", "Shop" and "Product Category" archive pages, this code snippet from Beda, can prove useful:
https://toolset.com/forums/topic/toolset-image-field-not-compatible-with-wps-new-image-scaling-feature/#post-2449883

For any follow-up questions, you're welcome to start a new ticket.