WooCommerce API v3 自定义端点 [英] WooCommerce API v3 custom endpoint
问题描述
我想在 WooCoomerce API v3 中创建一个自定义端点,以便从 eshop 获取一些客户.我知道 API v3 中有一个端点可用,但它不符合项目的规范.
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.
我已经检查过:https://docs.woothemes.com/document/hooks/ 但没有运气.当我使用此操作时,响应格式为 HTML 和 JSON.
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?
推荐答案
要创建像 wc-api/v3/custom
这样的自定义端点,您可以查看我的 端点教程.
To create custom endpoint like wc-api/v3/custom
you can look at my endpoint tutorial.
这里的主要步骤是创建一个自定义类并将其返回到 woocommerce_api_classes
过滤器,如下所示:
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;
}
);
之后您可以使用 WC_API_Custom
返回自定义内容.
After that you can use WC_API_Custom
to return custom content.
这篇关于WooCommerce API v3 自定义端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!