Objective
Allow users to subscribe to a digital product (recurring) by default while purchasing a physical product (one-time) within a single cart experience.
Step-by-Step Integration
Enable Recurpay Subscription Widget
Go to the theme customization section.
βActivate the Recurpay widget on product pages where you want to offer subscription plans
β
Note: Only in case you want to show subscription options on the digital product page as well.
Fetch the Selling Plan ID of digital product
Call Recurpay selling plan API to fetch the selling plan associated with the digital product.
Override Default "Add to Cart" Behavior via JavaScript
You will need to use custom JS logic to bundle both products:
letformData= {
'items': [
{
'id': '<digital_product_variant_id>',
'quantity': '<quantity>',
'selling_plan': '<selling_plan_id>'
},
{
'id': '<subscription_variant_id>',
'quantity': '<quantity>',
},
]
};
fetch(window.Shopify.routes.root + 'cart/add.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
})
.then(response => {
return response.json();
})
.catch((error) => {
console.error('Error:', error);
});
Use Case Example
When the customer adds Product A, the script simultaneously adds digital Product B, enhancing value while maintaining a smooth UX.