亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

WooCommerce Rest API 端點,用于獲取與特定客戶相關的所有訂閱

WooCommerce Rest API 端點,用于獲取與特定客戶相關的所有訂閱

PHP
qq_笑_17 2022-12-23 16:14:23
我不知道如何使用 Woocommerce API 獲得特定客戶的活躍訂閱。我有一個連接到中間層的移動應用程序,這個中間層需要提供用戶激活的訂閱列表。我需要知道我可以調用哪些 Woocommerce API 端點或端點組合來獲取用戶的活動訂閱。幾天來一直在努力解決這個問題。請幫忙例如,使用 WooCommerce API v1 應該返回活動訂閱: https://....com/wp-json/wc/v1/subscriptions?customer=1&status=active 但事實并非如此,很多用戶都缺少活動訂閱.我也試過: 1. https://….com/wp-json/wc/v3/memberships/members 雖然這確實會返回會員資格,但它不提供產品 ID 等,其中許多產品 ID 為空會員資格“id”: 355,“customer_id”: 1,“plan_id”: 430,“status”: “active”,“order_id”: null,“product_id”: null,“subscription_id”: null,2. https://….com/wp-json/wc/v3/orders?customer=1 這也缺少訂閱和其他購買
查看完整描述

3 回答

?
MMMHUHU

TA貢獻1834條經驗 獲得超8個贊

/**

 * Register the routes for this class

 *

 * GET /customers/<id>/subscriptions

 *

 * @since 2.0

 * @param array $routes

 * @return array

 */

public function register_routes( $routes ) {

    # GET /customers/<id>/subscriptions

    $routes[ $this->base . '/(?P<id>\d+)/subscriptions' ] = array(

        array( array( $this, 'get_customer_subscriptions' ), WC_API_SERVER::READABLE ),

    );


    return $routes;

}

你的端點應該是 /customers/<id>/subscriptions- 這里<id>是customer_id


WCS API 函數獲取與特定客戶相關聯的所有訂閱。


查看完整回答
反對 回復 2022-12-23
?
不負相思意

TA貢獻1777條經驗 獲得超10個贊

您可能不再尋找這個,但我想我會澄清答案,因為 @mujuonly 不方便地遺漏了它僅適用于Legacy WooCommerce API. 無論如何,它已被棄用。但它現在有效。

  1. 在 WooCommerce -> 設置 -> 高級 -> 舊版 API 中啟用舊版 API

  2. 獲取您的訪問令牌

  3. 訪問https://___.com/wc-api/v3/customers/<customer_id>/subscriptions/

截至目前,我沒有看到本機 API 支持類似此端點的任何內容。希望它會在不久的將來被添加。


查看完整回答
反對 回復 2022-12-23
?
互換的青春

TA貢獻1797條經驗 獲得超6個贊

您可以使用以下方式獲得有效訂閱:

/wp-json/wc/v1/subscriptions/<id> //To get particular subscription
/wp-json/wc/v1/subscriptions //To get all subscriptions

您可以在此處獲取更多信息: https ://prospress.github.io/subscriptions-rest-api-docs/?php#list-all-subscriptions

如果您覺得有幫助,請告訴我。


查看完整回答
反對 回復 2022-12-23
  • 3 回答
  • 0 關注
  • 156 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號