gpt4 book ai didi

php - WooCommerce API v3 自定义端点

转载 作者:可可西里 更新时间:2023-11-01 00:30:28 25 4
gpt4 key购买 nike

我想在 WooCoommerce API v3 中创建一个自定义端点,以便从 eshop 获取一些客户。我知道 API v3 中有一个端点可用,但它不符合项目规范。

我检查过这个:https://docs.woothemes.com/document/hooks/但没有运气。当我使用此操作时,响应格式为 HTML 和 JSON。

谁能帮我解决这个问题?

最佳答案

要创建像 wc-api/v3/custom 这样的自定义端点,您可以查看我的 endpoint tutorial .

这里的主要步骤是创建一个自定义类并将其返回给 woocommerce_api_classes 过滤器,如下所示:

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

之后,您可以使用 WC_API_Custom 返回自定义内容。

关于php - WooCommerce API v3 自定义端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34963720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com