Last active
January 16, 2024 06:42
-
-
Save PluginRepublicSupport/512f1b4865650b3e8959682768f25999 to your computer and use it in GitHub Desktop.
Compatibility between WooCommerce Members Only and FiboSearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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