Last active
February 14, 2018 08:04
-
-
Save rayrutjes/82c392fa206a6f9f3f47aa2fd424fea1 to your computer and use it in GitHub Desktop.
Filter displayed facets in Algolia plugin for WooCommerce
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 | |
add_filter( 'algolia_wc_attributes_for_faceting', function( $attributes ) { | |
$only_ids = array( | |
15, // Main Style | |
13, // Main Color | |
49, // Sizes | |
23, // Brand | |
4, // Collection | |
22, // Material | |
17, // Construction | |
); | |
foreach ( $attributes as &$attribute ) { | |
if ( ! in_array( $attribute['attribute_id'], $only_ids, true ) ) { | |
$attribute['is_enabled'] = false; | |
} else { | |
$attribute['is_enabled'] = true; | |
$attribute['weight'] = array_search( $attribute['attribute_id'], $only_ids, true ); | |
$attribute['sort_by'] = array( 'isRefined:desc', 'name:asc' ); | |
} | |
} | |
return $attributes; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment