yithemes / yith-woocommerce-wishlist

YITH WooCommerce Wishlist gives your users the possibility to create, fill, manage and share their wishlists allowing you to analyze their interests and needs to improve your marketing strategies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REST API Support

prionkor opened this issue · comments

commented

Continue of the discussion from WP Support Forum

I am going to for this project and start the development. If you have any preferred guidelines on how you structure your code let me know. I am using a pattern like this.

Namespace

/yith/wishlist/v1

Proposed Endpoint for (CRUD)

GET {url}/wishlists
Users with credentials will be returned with an array of wishlists object.

POST {url}/wishlists

Add product/s to wishlist endpoint. Users with credentials will be returned with a wishlists object created from the POST data. if no wishlist id was provided a new wishlist is created otherwise the object with the given id returned.

Params:

wishlistId: id of the wishlist
productIds: an array of product ids. for a single product add send one element array.
userId (optional): In the case of client credentials or API key, admin user auth send userId. For a user auth userId isn't required because userId will be gathered from authentication. Defaults to the current user. (needs discussion)

DELETE {url}/wishlists/{id}

Clears the wishlist data.

DELETE {url}/wishlists/{id}/product/{product_id}

Removes the given product id from wishlist id

Hi there

I am going to for this project and start the development. If you have any preferred guidelines on how you structure your code let me know. I am using a pattern like this.

We of course suggest to create a PR to this repo, in order to improve and extend the plugin
Anyway, as I already told you on wp.org, this is an ongoing project and I'll make use of your post to open discussion about this feature, that will be hopefully added within next major release

Talking about standards, we have no specific suggestions regarding plugin scaffolding, but of course we recommend to follow WP's coding standards and best practice in general; we'll hopefully write a contributing guide for this project soon enough

Regarding namespace, I'd follow WC's example, and place the root of API at wp-json/yith/wishlist/v1

The structure of the API, instead, should describe the two main entities of the project: wishlist and wishlist_item (you can find reference of these objects in dedicated classes, YITH_WooCommerce_Wishlist and YITH_WooCommerce_Wishlist_Item respectively)

I'll spend some time drafting a possible API structure, to share here for anyone who may want to contribute, or even to get feedback before proceeding with development

commented

Tasks

  • Get list of wishlist
  • Get single wishlist
  • Create Wishlist
  • Update Wishlist
  • Add product to wishlist
  • Remove product from wishlist
  • Delete wishlist
  • Clean wishlist (delete all products form wishlists
commented

As the deadline of one of my client projects approaches. I have created a separate plugin with the work and can be found here https://github.com/prionkor/yith-woocommerce-wishlist-rest-api The checklist above is a list of things that were done.

The plugin needs pull request #11 to be merged to work properly.

As the deadline of one of my client projects approaches. I have created a separate plugin with the work and can be found here https://github.com/prionkor/yith-woocommerce-wishlist-rest-api The checklist above is a list of things that were done.

The plugin needs pull request #11 to be merged to work properly.

Great work @prionkor have you accomplished the "Create Wishlist" task yet?? I'm developing some custom endpoints for a project and I'm kinda stuck in there. Somehow I can create a "wishlist object" but the "->save()" wont work even though it returns an id.

I'm attaching photos of the endpoint, what I get as a response from my endpoint and what I see on the wishlists list. I don't seem to find the one that got created.

Captura de Pantalla 2021-08-24 a la(s) 18 44 09

Captura de Pantalla 2021-08-24 a la(s) 18 41 32

Captura de Pantalla 2021-08-24 a la(s) 18 41 58

commented

Sorry, for the delay. I think I did, I will check this in the weekend and get back to you.

Would really appreciate it. Thank you :D

commented

@melomontoya Could you move over to https://github.com/prionkor/yith-woocommerce-wishlist-rest-api and create a ticket there?

BTW, There is always a default wishlist created for a user. Unless you need multiple wishlist you do not need a create wishlist endpoint. You can just add to the wishlist and it should stick.

So why would "YITH_WCWL_Wishlist_Factory::get_default_wishlist( $user_id );" return false?
And why I'm not able to see the new wishlists on the backend?
Thanks for your answer :D

Was this ever added somehow into the plugin?

How does still have no updates? can someone provide reference here?