1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Prices Premium
  4. Product Visibility
  5. Why Do Products Not Show In Regular Searches When Prices Premium Is Active?
  1. Home
  2. Knowledge Base
  3. Known Compatibility Issues
  4. Why Do Products Not Show In Regular Searches When Prices Premium Is Active?

Why Do Products Not Show In Regular Searches When Prices Premium Is Active?

WooCommerce Wholesale Prices Premium has a feature to restrict products exclusive to wholesale customers. However, due to technical limitations, the regular search of WordPress doesn’t filter these restrictions on the products.

It can be confusing to guests and other users to see products that are restricted to them that’s why we disable showing products on the regular search to prevent confusion.

If we didn’t do this, then your guest customers might see wholesale restricted products in their regular search results. Though, even if they did click on one of these restricted products, they would just be redirected to the shop as they don’t have the authorization to view the product page.

However, if you don’t mind your wholesale products showing up to non-authorized users in search query results pages you can re-add products to the regular listings using this snippet. Note that visibility is ignored, they’ll just see all products regardless of wholesale visibility.

function include_product_search( $query ) 
{
if ( !is_admin() && $query->is_search() && (!isset($_GET['post_type']) || $_GET['post_type'] != 'product') )
{
$post_types = $query->get('post_type'); $post_types []= 'product'; $query->set( 'post_type', $post_types );
}
}
add_action( 'pre_get_posts', 'include_product_search' 

The preferred solution is instead of using the regular search, we recommend using WooCommerce’s Product Search widget which is compatible with the wholesale role restrictions.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support