Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce API v3 custom endpoint

I would like to make a custom endpoint in WooCoommerce API v3 in order to fetch some customers from eshop. I know that there is an endpoint available in API v3 but it does not fill the project's specifications.

I've checked this: https://docs.woothemes.com/document/hooks/ but no luck. When I use this action, the response format is in HTML and in JSON.

Can anyone help me with this?

like image 652
Nikolas Theologos Avatar asked Dec 05 '22 19:12

Nikolas Theologos


1 Answers

To create custom endpoint like wc-api/v3/custom you can look at my endpoint tutorial.

The main step here is to create a custom class and return that to woocommerce_api_classes filter like so:

add_filter( 'woocommerce_api_classes', function( $classes ){
        $classes[] = 'WC_API_Custom';
        return $classes;
    }
);

After that you can use WC_API_Custom to return custom content.

like image 195
Karthik Avatar answered Dec 09 '22 14:12

Karthik