WooCommerce API v3 custom endpoint

2019-05-11 00:45发布

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?

1条回答
姐就是有狂的资本
2楼-- · 2019-05-11 01:33

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.

查看更多
登录 后发表回答