Instantly share code, notes, and snippets.

Embed
What would you like to do?
Freemius Buy Button Code for a Multi-Plans Table
<script src="https://checkout.freemius.com/checkout.min.js"></script>
<select id="starter-licenses">
<option value="1" selected="selected">Single Site License</option>
<option value="5">5-Site License</option>
<option value="25">25-Site License</option>
<option value="unlimited">Unlimited Sites License</option>
</select>
<button id="starter-purchase">Buy Starter</button>
<select id="pro-licenses">
<option value="1" selected="selected">Single Site License</option>
<option value="5">5-Site License</option>
<option value="25">25-Site License</option>
<option value="unlimited">Unlimited Sites License</option>
</select>
<button id="pro-purchase">Buy Professional</button>
<select id="bus-licenses">
<option value="1" selected="selected">Single Site License</option>
<option value="5">5-Site License</option>
<option value="25">25-Site License</option>
<option value="unlimited">Unlimited Sites License</option>
</select>
<button id="bus-purchase">Buy Professional</button>
<script type="text/javascript">
(function(){
var freemiusHandler = FS.Checkout.configure({
name : '<pluginTitle>',
plugin_id: '<pluginID>',
public_key: '<publicKey>'
});
var plans = {
starter: '<starterPlanID>',
pro: '<proPlanID>',
bus: '<busPlanID>'
};
var addBuyHandler = function (plan, planID){
$('#' + plan + '-purchase').on('click', function (e) {
freemiusHandler.open({
plan_id : planID,
licenses: $('#' + plan + '-licenses').val(),
// You can consume the response for after purchase logic.
success : function (response) {
// alert(response.user.email);
}
});
e.preventDefault();
});
};
for (var plan in plans) {
if (!plans.hasOwnProperty(plan))
continue;
addBuyHandler(plan, plans[plan]);
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment