perfect-woocommerce-brands icon indicating copy to clipboard operation
perfect-woocommerce-brands copied to clipboard

Align rest api to WC standard functionality

Open msp1974 opened this issue 3 years ago • 4 comments

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:

  1. Endpoint to return single brand -- /brands/[id]
  2. Ability to search based on returned fields brands -- /brands?slug=xxx etc
  3. Return only certain fields -- /brands?_fields=term_id, name
  4. 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

msp1974 avatar Sep 07 '20 19:09 msp1974

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

msp1974 avatar Sep 07 '20 22:09 msp1974

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.

msp1974 avatar Sep 10 '20 20:09 msp1974

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!

kristina-joachim avatar Feb 22 '21 02:02 kristina-joachim

I really need the update option to become available.

Anyone can help ?

Peeripapo avatar Aug 26 '21 15:08 Peeripapo