FacetWP – support non-ajax “Add to cart” links

<?php

// Add to functions.php
function fwp_cart_link() {
?>
<script>
(function($) {
    $(document).on('facetwp-loaded', function() {
        FWP_HTTP.current_url = window.location.href;
    });
})(jQuery);
</script>
<?php
}
add_action( 'wp_head', 'fwp_cart_link', 100 );
add_filter( 'woocommerce_product_add_to_cart_url', function( $url ) {
    if ( function_exists( 'FWP' ) && isset( FWP()->facet->http_params['current_url'] ) ) {
        $url = FWP()->facet->http_params['current_url'];
    }
    return $url;
});