1. Casa
  2. Knowledge Base
  3. WooCommerce Prezzi all'ingrosso Premium
  4. Visibilità del prodotto
  5. Perché i prodotti non vengono visualizzati nelle ricerche normali quando Prices Premium è attivo?
  1. Casa
  2. Knowledge Base
  3. Problemi di compatibilità noti
  4. Perché i prodotti non vengono visualizzati nelle ricerche normali quando Prices Premium è attivo?

Perché i prodotti non vengono visualizzati nelle ricerche normali quando Prices Premium è attivo?

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.

Questo articolo è stato utile?

Articoli Correlati

Serve Supporto?

Non trovi la risposta che cerchi?
Contatta il Supporto
Completa il tuo acquisto