Skip to main content
All CollectionsSubscriptionsSubscription Management
Appstle Subscriptions JavaScript API Documentation
Appstle Subscriptions JavaScript API Documentation
Updated over a week ago

The Appstle Subscriptions JavaScript API documentation explains how to use various JavaScript events and methods in the Appstle Subscriptions app. For example, when your customer selects or removes a subscription plan in your shop, this API allows you to capture these events and take actions accordingly. You can also use this API to customize the customer experience in your shop.

When a Subscription Plan is Selected

When a subscription plan is selected in the subscription widget, a custom JavaScript event called AppstleSubscription:SubscriptionWidget:SellingPlanSelected will be triggered on the document. You can use this event to execute custom JavaScript code when a subscription plan is selected.

Here is how you can configure a listener for this event:

// This event will be fired when a subscription plan is selected

document.addEventListener('AppstleSubscription:SubscriptionWidget:SellingPlanSelected', function() {
console.log('selling plan', jQuery('.appstle_sub_widget input[name=selling_plan]:checked').val());
// Do your custom actions here
});

When a Subscription Plan is Removed

When a subscription plan is removed in the subscription widget, a custom JavaScript event called AppstleSubscription:SubscriptionWidget:SellingPlanRemoved will be triggered on the document. You can use this event to execute custom JavaScript code when a subscription plan is removed.

Here is how you can configure a listener for this event:

// This event will be fired when a subscription plan is removed

document.addEventListener('AppstleSubscription:SubscriptionWidget:SellingPlanRemoved', function() {
console.log('selling plan', jQuery('.appstle_sub_widget input[name=selling_plan]:checked').val());
// Do your custom actions here
});

Example Usage

Subscription Plan Selected Event

When the customer selects a subscription plan, the following code will log the selected selling plan's value to the console and perform any custom actions defined in the function:

document.addEventListener('AppstleSubscription:SubscriptionWidget:SellingPlanSelected', function() {
console.log('selling plan', jQuery('.appstle_sub_widget input[name=selling_plan]:checked').val());
// Do your custom actions here
});

Subscription Plan Removed Event

When the customer removes a subscription plan, the following code will log the current selling plan's value (if any) to the console and perform any custom actions defined in the function:

document.addEventListener('AppstleSubscription:SubscriptionWidget:SellingPlanRemoved', function() {
console.log('selling plan', jQuery('.appstle_sub_widget input[name=selling_plan]:checked').val());
// Do your custom actions here
});

By using these events, you can customize the behavior and appearance of the subscription widget in your shop, providing a more tailored experience for your customers.

Did this answer your question?