Create filter on collection page using Ajax

Cornetto
New Member
2 0 0

So far everything is going well with the development of my first store on Shopify. Except I can't manage to create a filter that works with Ajax.

For the products I have entered a number of metafields that I want to filter on.

What I would like is that I can call a template with Ajax that then get the request (something like request.body) and that I can filter through the products with Liquid.

What I have already seen is that you can create alternative templates. Here I give a {% layout none%} and an include to a snippet.

Only when I make a request to that template (product.filter.liquid) i get an 404 error back.

This is the code for posting, I'm using axios for this:

 

axios({
	type: 'post',
	url: '/product?view=filter'
})
.then(function (response) {
	console.log('Response ', response);
})
.catch(function (error) {
	console.log('Error ', error);
});

 

Does anyone know how to fix this. Or maybe there is a completely different solution for this?

I know there are apps. But i just want to fix this without an app.

Thank you very much for thinking along!

Greetings,

Cornetto

0 Likes