Files
medicalalert-web-reloaded/wp/wp-content/plugins/facetwp/includes/integrations/woocommerce/woocommerce.js
Tony Volpe 779393381f Merged in feature/plugins-update (pull request #9)
wp plugin updates from pantheon

* wp plugin updates from pantheon
2023-12-15 18:08:21 +00:00

34 lines
1.1 KiB
JavaScript

(function($) {
$().on('facetwp-refresh', function() {
if (! FWP.loaded) {
setup_woocommerce();
}
});
function setup_woocommerce() {
// Intercept WooCommerce pagination
$().on('click', '.woocommerce-pagination a', function(e) {
e.preventDefault();
var matches = $(this).attr('href').match(/\/page\/(\d+)/);
if (null !== matches) {
FWP.paged = parseInt(matches[1]);
FWP.soft_refresh = true;
FWP.refresh();
}
});
// Disable sort handler
$('.woocommerce-ordering').attr('onsubmit', 'event.preventDefault()');
// Intercept WooCommerce sorting
$().on('change', '.woocommerce-ordering .orderby', function(e) {
var qs = new URLSearchParams(window.location.search);
qs.set('orderby', $(this).val());
history.pushState(null, null, window.location.pathname + '?' + qs.toString());
FWP.soft_refresh = true;
FWP.refresh();
});
}
})(fUtil);