Closed patrickposner closed 2 years ago
@gilbitron Could you check the feature branch here: https://github.com/Make-Lemonade/lemonsqueezy-wp/tree/select-store
I integrated the select option for stores and modified the endpoints so that the products are getting updated as soon as you select a store.
One problem I faced yesterday (maybe I was simply too tired..):
If I make a request to: https://api.lemonsqueezy.com/v1/products?store_id=123 I get all products from that store.
If I do the same with: https://api.lemonsqueezy.me/v1/products?store_id=123
I get all products from all stores.
@patrickposner The JSON:API format for filters is filter[store_id]=
. So the URL would need to be:
https://api.lemonsqueezy.com/v1/products?filter[store_id]=123
The other (cleaner) way to do it is:
@patrickposner I've commited some changes to the select-store
branch which fixes the API request and adds some better state handling. I'll let you clean it up a bit.
I noticed that changing the product in the block settings in the sidebar doesn't change the product in the dropdown in the block editor itself, and vice versa.
@gilbitron mentioned this important point:
One other thing I've just realised, the products dropdown in the block is loading all products across all of the Lemon Squeezy stores that belong to the user. I think we should add a second "stores" dropdown above the products dropdown if the API key has access to multiple stores. That way products can be filtered by store.
Originally posted by @gilbitron in https://github.com/Make-Lemonade/lemonsqueezy-wp/issues/3#issuecomment-957320826