perfect-woocommerce-brands
perfect-woocommerce-brands copied to clipboard
Align rest api to WC standard functionality
Hi,
I have been using this plugin to develop a new ecommerce website and really love it. However, I have an integration (custom built) between the website and an epos system to manage products and orders etc.
As part of that integration, I needed to be able to have more functionality in the rest api to create/update/delete and search for brands by id (from the product detail) and by slug (used as key field to align epos and website).
This pull request updates the rest api functionality to align with standard WC api functionality in the following way:
- Endpoint to return single brand -- /brands/[id]
- Ability to search based on returned fields brands -- /brands?slug=xxx etc
- Return only certain fields -- /brands?_fields=term_id, name
- Support the api schema data -- /v3
It does, however, have a breaking change in that it now paginates (default 10 items, max 100) as is standard in wp, otherwise everyting is additional functionality and does not change existing.
Rather than have a custom version of this plugin, I thought it better to maybe include in the base repo and share with others.
Let me know if you're happy to merge or you would like any amends making.
Thanks Mark
Sorry there is a flaw in this and needs some rework. Will close for now and resubmit when i have done that, but if you could let me know that you are interested in merging when done. Thx
This was using WC_Rest_Terms_Controller which could cause an issue depending on load order of plugins. Changed it to use WP_Rest_Terms_Controller. Tested and working fine.
Also, doing this was able to remove the breaking change and have default page returning 1000 items instead of 10. Maybe need to decide best approach to this before implementing.
Hello, I was wondering if it was possible to also incorporate the following:
- Update existing brand information with PUT requests.
- Adding more information when creating a new brand via POST:
- set Parent Brand by ID
- set Brand Image by Image ID, filename, or URL
Thanks!
I really need the update option to become available.
Anyone can help ?