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

Solved
RitikaThakur
Tourist
15 0 2

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)

Accepted Solutions
J-ROM
Shopify Staff
7 2 3

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

View solution in original post

Replies 4 (4)
J-ROM
Shopify Staff
7 2 3

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

View solution in original post

RitikaThakur
Tourist
15 0 2

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
}