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?

Answer

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.

Leave a Reply

Your email address will not be published. Required fields are marked *