Hello Developer, Is there any way to get all subscription plan belongs to a client from shopify by clientID ?
Hi Masumluf,
You can list all the subscription contracts from a customer ID by going through the Customer object and leveraging its subscriptionContracts connection:
query {
customer(id: "gid://shopify/Customer/CUSTOMER_ID") {
subscriptionContracts (first: N, after: END_CURSOR) {
nodes {
id
status
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
where:
- CUSTOMER_ID is your customer ID
- N is the number of contracts you want to fetch with each query (e.g. 10 at a time)
- END_CURSOR is null for the first query, and is the value of endCursor for the following queries until hasNextPage is false
This will return the first N contract IDs and their status. With the page info, you can retrieve the following N results, until there is no more to fetch.
Hope this helps!
J-ROM