Not sure if combining the handler with postTypes will work. I think the best option is to choose between:
Using a custom endpoint and use a handler to point to that data.
Using the CPT product and add more info (if necessary) from your WordPress.
Just to clarify it a bit more we have two cases:
If you use the CPT you defined
With that settings, you are telling Frontity to fetch that CPT. As you have defined it:
If you access to https://mysite.com/product/first-product (from Frontity) youâll be getting the info from the endpoint https://wp.mysite.com/wp-json/wp/v2/product?slug=first-product (from your WP).
If you access to https://mysite.com/product youâll be getting a list of all your products, fetched from https://wp.mysite.com/wp-json/wp/v2/product?slug=first-product.
You could add more info to that endpoint from your WP.
If you use your own handler
We usually use handlers to fetch data from a custom endpoint, or to change the way we populate the state.
With the handler you are telling Frontity: if we access the url https://mysite.com/products/slug you are going to run the function defined inside it. Inside this function, we usually fetch data from a new endpoint, and how we populate the frontity.state in order to consume that info later.
If you want to show a lists of your products when you access https://mysite.com/products, youâd need to create a new handler to match that pattern, and fetch all the products from your endpoint.
Youâd need a new handler for example if you want to point to woocommerce API instead of wp-json/wp/v2.
In this case, if youâre fetching the data from a CPT, I guess the best option would be to use the CPT without a handler. And if you want to fetch the data from a different endpoint you may want to use a handler.
@luisherranz describes a handler to load a product, which is not necessary now, since I handle products like Custom Post Types.
Now I need to load the products from the shopping cart (which I charge from localStorage) at the start of the app, I have the product id(s) from the localStorage
Hey @vscopise! This method is awesome. I only just got around to trying it out. Did you ever get around to figuring out the payment handling and sending the order back to wordpress for processing? Working on it now, just curious if you already found a decent method.