I started playing with subscription related apis provided by Shopify and i see critical bad design. SellingPlanGroup schema is unclear and badly documented that ends up with situation where different apps are store data in inconsistent way.
Assume you are building the app that takes product, reads all connected sellingPlans and popups this product with list of all available subscriptions. Of course you want to have mechanism that is conssitent with all apps, so if app renders ‘Subscribe and save’ as a title, and ‘Delivery every’ as frequency selector, your popup should you the same. Where to look for those labels? Well who knows… api is designed that way it is not documented and forced, so different apps uses different way.
Example :
a) data of sellingPlanGroup created by recharge
"node": { "appId": null, "name": "Ananas", "options": [ "15 Day(s),30 Day(s)" ], "sellingPlans": { "edges": [ { "node": { "name": "Delivery every 15 Days", "options": [ "15 Day(s)" ] } }, { "node": { "name": "Delivery every 30 Days", "options": [ "30 Day(s)" ] } } ] }
name is inherited from product, options is an array that contains one ! comma separated string. Title rendered by app (“Subscribe and save”) is not stored udner sellingPlanGroup document, probably comes from app itself. Hard to say.
b) created by Ongoing Subscription app
`{
“node”: {
“appId”: “repeat-kit-app-extension”,
“name”: “Ongoing subscription name”,
“options”: [
“Delivery every…”
],
“sellingPlans”: {
“edges”: [
{
“node”: {
“name”: “Ongoing subscription name”,
“options”: [
“Option 1: Delivery Every 1 Month(s) - Paid Every 1 Month(s)"”
]
}
}
]
}
}
}
`
Most common way, used by 90% of apps I tested option contains only one element ( why it is an array) that is frequency selector label. Name is the selling plan name that is then displayed on store front. I know it is up to app to render widget on store front but cmon , provide some unification and standards.
Anyways i thought it is not end of the world, i thought I could write parser and parse data comming from different apps and make sure i have data formatted properly. I was sure that appId is really id. But it is not! It is not required, it is up to the api client to set the appId so there is no way to know who is the creator of sellingPlanGroup, many apps left it even blank. Look above appId in case of recharge is null.