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

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?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;
});

{{/gist}}