Skip to content

Instantly share code, notes, and snippets.

@PluginRepublicSupport
Last active January 16, 2024 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PluginRepublicSupport/512f1b4865650b3e8959682768f25999 to your computer and use it in GitHub Desktop.
Save PluginRepublicSupport/512f1b4865650b3e8959682768f25999 to your computer and use it in GitHub Desktop.
Compatibility between WooCommerce Members Only and FiboSearch
<?php
/**
* Hide products restricted by WooCommerce Members Only from FiboSearch results
*/
function wcmo_fibosearch_remove_restricted_products( $products ) {
if ( ! empty( $products ) ) {
$tmp = array();
foreach ( $products as $product ) {
if ( ! wcmo_is_product_restricted( $product->ID ) ) {
$tmp[] = $product;
}
}
$products = $tmp;
}
return $products;
}
add_filter( 'dgwt/wcas/search_results/products_raw', 'wcmo_fibosearch_remove_restricted_products', 10, 1 );
/**
* Hide categories restricted by WooCommerce Members Only from FiboSearch
*/
add_filter( 'wcmo_force_hide_restricted_categories', '__return_true' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment