Skip to main content

Theme Engine

The theme engine is slightly different since now the customer is a subscriber and lives in the recharge realm.

First, to know the bundle selections for a subscription you can use the following schema in the request object:

{ "subscription": { "id": "265907516", "bundle_selections": {} } }

The subscription object will include a property called bundle_selections with the following payload. If this value is null, it means the customer doesn't have a selection.

{
"external_variant_id": 41291293425861,
"selections": [
{
"collection_id": 288157827269,
"external_product_id": 7200061391045,
"external_variant_id": 41510929465541,
"quantity": 2
},
{
"collection_id": 285790863557,
"external_product_id": 7200062308549,
"external_variant_id": 41504991412421,
"quantity": 2
}
]
}

Example request (it won't work because the token is not valid)

fetch(
`https://currantapp.myshopify.com/tools/recurring/portal/53cf286a3ff18d0bea10b28f4eebe9/request_objects?token=XXXX&schema={"subscription":{"id":"265907516","bundle_selections":{}}}`
);

To update the contents using the theme engine you need to make a POST request to /tools/recurring/portal/CUSTOMER-HASH/subscriptions/ID/bundles?token=XXX, for example:

const newSelection = {
bundle_purchase_item: {
external_variant_id: 41291293425861,
external_product_id: 7134322196677,
selections: [
{
collection_id: 285790863557,
external_product_id: 7200063029445,
external_variant_id: 41504993575109,
quantity: 1,
},
{
collection_id: 285790863557,
external_product_id: 7200062308549,
external_variant_id: 41504991412421,
quantity: 1,
},
{
collection_id: 288157827269,
external_product_id: 7200064241861,
external_variant_id: 41510933299397,
quantity: 2,
},
],
},
};

fetch(
'https://currantapp.myshopify.com/tools/recurring/portal/53cf286a3ff18d0bea10b28f4eebe9/subscriptions/265907516/bundles?token=XXX',
{
headers: {
'content-type': 'application/json',
},
body: JSON.stringify(newSelection),
method: 'POST',
}
);