9 months ago
<?php
/** reloads bricks accordian after facet reloads **/
add_action( 'wp_footer', function() {
?>
<script>
document.addEventListener('facetwp-loaded', function() {
bricksAccordion();
});
</script>
<?php
}, 100 );
1 year ago
<?php
add_action( 'wp_footer', function() {
?>
<script>
document.addEventListener('facetwp-loaded', function() {
EleCustomSkinItemLink();
});
</script>
<?php
}, 100 );
3 months ago
<?php
/** close flyout on facetwp-loaded so that the user doesn't need to close after facet refreshes **/
add_action( 'facetwp_scripts', function() { ?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
if (FWP.loaded && $('.facetwp-flyout').hasClass('active') ) {
FWP.flyout.close();
}
});
})(fUtil);
</script>
<?php } );
5 days ago
<?php
// Changes 'mi' to 'miles' in a Proximity facet's radius dropdown
add_action('facetwp_scripts', function () {
?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
let radiusdropdown = document.querySelector('.facetwp-radius-dropdown');
radiusdropdown.querySelectorAll('option').forEach(option => {
if (option.textContent.trim().endsWith('mi')) {
const newOptionText = option.textContent.replace(/mi\b/g, 'miles'); // Replace 'mi' with 'miles' if it is at the end of the option string
option.textContent = newOptionText;
}
});
});
})(fUtil);
</script>
<?php
}, 100);
4 weeks ago
<?php
// Hides a facet if there is only one option left
// Replace 'my_facet_name' with the name of your facet (4x)
add_action( 'facetwp_scripts', function() { ?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
if ( FWP.settings.num_choices.my_facet_name !== 'undefined' && FWP.settings.num_choices.my_facet_name < 2 ) {
$('.facetwp-facet-my_facet_name').addClass( 'facetwp-hidden' );
} else {
$('.facetwp-facet-my_facet_name').removeClass( 'facetwp-hidden' );
}
});
})(fUtil);
</script>
<?php } );
2 months ago
<?php
/**
** change facet1 to the name of your first facet (the facet to check selection)
** facet2 to the name of your second facet (to be disabled)
**/
add_action( 'facetwp_scripts', function() {
?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
if ( 'undefined' !== typeof FWP.facets['facet1'] && FWP.facets['facet1'].length > 0 ) {
$( '.facetwp-facet-facet2 select' ).attr('disabled', 'disabled');
}
});
})(fUtil);
</script>
<?php
}, 100 );
2 months ago
<?php
/**
* Product quantity <input> fields for add to cart forms,
* generated with the woocommerce_quantity_input() function,
* need re-initializing their minimum value (set in the 'min' attribute) after a FacetWP refresh:
**/
add_action( 'facetwp_scripts', function() {
?>
<script>
document.addEventListener('facetwp-loaded', function() {
jQuery(function($) {
$('input.qty').each(function() {
var min = parseFloat($(this).attr('min'));
if (min >= 0 && parseFloat($(this).val()) < min) {
$(this).val(min);
}
});
});
});
</script>
<?php
}, 100 );
3 months ago
<?php
// This sets the class "checked", which makes the parent choice look selected, with a checked checkbox icon.
// If you just want to make the parent choice bold for example, use a custom class, e.g. 'selected', and add CSS to make it bold:
// .facetwp-checkbox.selected { font-weight: bold; }
add_action( 'facetwp_scripts', function() {
?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
$('.facetwp-depth.visible').prev('.facetwp-checkbox').toggleClass('checked');
});
})(jQuery);
</script>
<?php
}, 100 );
5 months ago
<?php
add_action( 'facetwp_scripts', function() {
?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
$('.facetwp-facet').each(function() {
var facet = $(this);
var facet_name = facet.attr('data-name');
var facet_type = facet.attr('data-type');
var facet_label = FWP.settings.labels[facet_name];
if (facet_type !== 'pager' && facet_type !== 'sort' && facet_type !== 'reset') {
if (facet.closest('.facet-wrap').len() < 1 && facet.closest('.facetwp-flyout').len() < 1) {
facet.prepend('<h3 class="facet-label">' + facet_label + '</h3>');
}
}
});
});
})(fUtil);
</script>
<?php
}, 100 );
5 months ago
<?php
add_action( 'facetwp_scripts', function() {
?>
<script>
document.addEventListener('facetwp-loaded', function() {
if ( FWP.loaded ) {
jQuery(".facetwp-template").fitVids();
}
});
</script>
<?php
}, 100 );