Tagged: ajax, jQuery, links, pagination
Hey there
thought i would open a new thread. my problem is related to the first fix here
My problem url is here (hosted on WPengine)
You will see i’m echoing the Add to cart url above the button. If you then scroll down to the bottom and click on page 5 you will those URL’s change from
/products/?fwp_paged=4&add-to-cart=5948
to
/wp-admin/admin-ajax.php?add-to-cart=5941
Something is not being applied to the buttons but not sure what. If you add a product to cart on page 4 it works perfect but clicking add to cart on page 5 or any other page returns a 0 on a white page.
Can you help out here ?
Hey interfacemedia,
when I click on page 5, I get redirected to this page:
/products/?fwp_paged=5
So it seems that you could fix it, right?
Best regards,
Andy
Once again the FacetWP developers have come through with this solution
Add the below to the theme function file
<?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;
});
Hi,
glad you could find a solution. Let us know in a new ticket if you have some more questions related to the theme. We are happy to assist you.
Best regards,
Andy