Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce REST API - Add custom routes

I have a Woocommerce shop and I'm using the Woocommerce REST API to list products etc. on another site and it works fine. There are some functionality that I'm missing though, and I'm wondering if it is possible to extend the API with custom calls?

like image 322
Nocklas Avatar asked Jan 19 '15 13:01

Nocklas


1 Answers

I was able to figure out how to this by reading the source code for Woocommerce.

First I had to create a class that extends WC_API_Resource and add my routes in the register_routes method of this class. Then I had to make sure that Woocommerce adds this class to the API by adding the class to the class-array in the woocommerce_api_classes filter.

like image 177
Nocklas Avatar answered Sep 22 '22 23:09

Nocklas