Solved

Subscription Contract doesn't give details of all if multiple line items with selling plans

RitikaThakur
Shopify Partner
19 0 6

If customer process the checkout with one of the below case of mixed cart like :- 

1.   If customer add multiple products with different /same selling plan , for example if  Product "Tea Packet"  and "Coffee Packet" both fall under same selling plan group and if customer add both products with same or different selling plan in cart (like "Tea Packet" for every day & "Coffee Packet" for every 2 day OR  "Tea Packet"  & "Coffee Packet" both for every 2 day) and proceed checkout

2.  If customer add different selling plan of same product (Yes I know this will be rare case ) but if in case customer proceed checkout with product "Coffee Packet both for every 2 day and every day as well 

 

Then In both cases , subscription contract webhook only provide details of one product like logically it should create either multiple subscription contracts for each product in checkout or  if single subscription contract is created then it should have details of all subscribed products  in checkout . 

 

Please HELP !!

Accepted Solution (1)
J-ROM
Shopify Staff (Retired)
66 6 8

This is an accepted solution.

Hi RitikaThakur,

Thanks for your patience while I looked into your inquiry.

The "subscription create" webhook returns an "admin_graphql_api_origin_order_id" which you can then use to retrieve the list of line items associated with this order via GraphQL. Each line item includes the contract, product and selling plan details.

query Order($id: ID!) {
  node(id: $id) {
	  ... on Order {
      lineItems(first:10) {
        edges {
          node {
            contract {
              id
            },
            product {
              title
            },
            sellingPlan {
              name
            }
          }
        }
      }
    }
  }
}

 
Hope this helps.

Cheers,
Jerome

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 5 (5)

RitikaThakur
Shopify Partner
19 0 6

Can I get any Update Please

J-ROM
Shopify Staff (Retired)
66 6 8

This is an accepted solution.

Hi RitikaThakur,

Thanks for your patience while I looked into your inquiry.

The "subscription create" webhook returns an "admin_graphql_api_origin_order_id" which you can then use to retrieve the list of line items associated with this order via GraphQL. Each line item includes the contract, product and selling plan details.

query Order($id: ID!) {
  node(id: $id) {
	  ... on Order {
      lineItems(first:10) {
        edges {
          node {
            contract {
              id
            },
            product {
              title
            },
            sellingPlan {
              name
            }
          }
        }
      }
    }
  }
}

 
Hope this helps.

Cheers,
Jerome

To learn more visit the Shopify Help Center or the Community Blog.

RitikaThakur
Shopify Partner
19 0 6

Thank You for your help ..!!

 

RitikaThakur
Shopify Partner
19 0 6

However Can you please explain what exactly the subscription contract id in json of subscription create webhook response ? Like I got the below JSON response  , the very first parameter/key here is "admin_graphql_api_id " and its value shows contract ID which don't match to the individual contract id of both the 2 line items in the order graphQL so need to know what exactly the role & usage of this :-  "admin_graphql_api_id": "gid:\/\/shopify\/SubscriptionContract\/2027946134"  . Also , below JSON response has "billing_policy" & "delivery policy" key value now how can we get to know to which line item these both keys refer to ? its very confusing as this order has 2 line items . I got your point that order api can give me each line item contract data but then what exactly the usage of providing the same or incomplete or inapportaire or confusing data itself in SubscriptionContract JSON :-  

 

{
"admin_graphql_api_id": "gid:\/\/shopify\/SubscriptionContract\/2027946134",
"id": 2027946134,
"billing_policy": {
"interval": "month",
"interval_count": 1,
"min_cycles": null,
"max_cycles": null
},
"currency_code": "USD",
"customer_id": 5805580845206,
"admin_graphql_api_customer_id": "gid:\/\/shopify\/Customer\/5805580845206",
"delivery_policy": {
"interval": "month",
"interval_count": 1
},
"status": "active",
"admin_graphql_api_origin_order_id": "gid:\/\/shopify\/Order\/4264538898582",
"origin_order_id": 4264538898582
}

 

andy_lee
Shopify Partner
1 0 0

Hi @RitikaThakur , this may seems too late for your question but I got the same case and found out whats going on based on your question. 

 

When order has multiple subscription products, actually multiple contracts are being created in shopify back-end. But the shopify `SUBSCRIPTION_CONTRACTS_CREATE` webhook returns with only first contract and its details. 

 

So in this response:

{
"admin_graphql_api_id": "gid:\/\/shopify\/SubscriptionContract\/2027946134",
"id": 2027946134,
"billing_policy": {
"interval": "month",
"interval_count": 1,
"min_cycles": null,
"max_cycles": null
},
"currency_code": "USD",
"customer_id": 5805580845206,
"admin_graphql_api_customer_id": "gid:\/\/shopify\/Customer\/5805580845206",
"delivery_policy": {
"interval": "month",
"interval_count": 1
},
"status": "active",
"admin_graphql_api_origin_order_id": "gid:\/\/shopify\/Order\/4264538898582",
"origin_order_id": 4264538898582
}

 

 

the `delivery_policy` & `billing_policy` & `id` are all related with first line item contract. 

 

And if you call the graphql with `admin_graphql_api_origin_order_id`, it will return all contracts with line items. Then you can see that `id` exists as the first item contract in the response.

 

Then you can use it for doing later actions for contrats.

 

Hope this helpful.