Created
September 21, 2019 03:02
-
-
Save denlunev/7fac1374430295742f4665df5e5634b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src='https://widgets.depositfix.com/v1/app.min.js'></script> | |
<script type='text/javascript' id='df-script'> | |
DepositFixForm.init({ | |
formId: 'dff4ae4e-d43b-43f4-9e13-46641f090872', | |
portalId: '1705488', | |
settings: { | |
multipleContacts: { | |
fields: ['email', 'firstname', 'lastname', 'mobilephone', 'jobtitle'] | |
} | |
}, | |
forms: { | |
stripe: { | |
stripeKey: 'pk_live_i9HGhshYxqNzJbd3O9MhBLvB00d7kDaini', | |
mode: 'live', | |
accountId: '470006' | |
} | |
}, | |
products: [{ | |
id: "plan_FqF7ZtF0eIgg9Y", | |
type: "subscription", | |
name: "PABCA Annual Membership (Single)", | |
amount: 40, | |
showQuantity: true, | |
addon: false | |
}, | |
{ | |
id: "plan_FqF8XqEvzzIFDR", | |
type: "subscription", | |
name: "ArBCA Annual Membership (Staff)", | |
amount: 160, | |
showQuantity: true, | |
addon: false | |
}], | |
callbacks: { | |
onFormReady: function(){ | |
var maxCoaches = 10; | |
var isStaticPrice = false; | |
DepositFixForm.widget.view.getHSFrame().getElementById("df-subscription").innerText = ''; | |
DepositFixForm.widget.view.getHSFrame().getElementById("df_subscriptions").addEventListener('change', function(){ | |
var value = this.options[this.selectedIndex].value; | |
if('plan_FqF8XqEvzzIFDR' == value){ | |
checkQuantityMax(); | |
setQuantityListener(); | |
DepositFixForm.widget.view.getHSFrame().getElementById("df-subscription").innerText = 'Up to ' + maxCoaches + ' seats'; | |
isStaticPrice = true; | |
}else{ | |
isStaticPrice = false; | |
setNormalQuantity(); | |
DepositFixForm.widget.view.getHSFrame().getElementById("df-subscription").innerText = ''; | |
} | |
}); | |
DepositFixForm.widget.view.getHSFrame().getElementById("df_subscription_quantity").addEventListener('change', function(){ | |
if(isStaticPrice){ | |
checkQuantityMax(); | |
setQuantityListener(); | |
}else{ | |
setNormalQuantity(); | |
} | |
}); | |
setNormalQuantity = function(){ | |
DepositFixForm.widget.getSubscriptionForm().quantityForm.quantity = DepositFixForm.widget.view.getHSFrame().getElementById("df_subscription_quantity").value; | |
DepositFixForm.widget.getSubscriptionForm().setQuantity(); | |
} | |
checkQuantityMax = function(){ | |
var quantityElement = DepositFixForm.widget.view.getHSFrame().getElementById("df_subscription_quantity"); | |
if(quantityElement.value > maxCoaches){ | |
quantityElement.value = maxCoaches; | |
quantityElement.dispatchEvent(new Event('input')); | |
} | |
} | |
setQuantityListener = function(){ | |
DepositFixForm.widget.getSubscriptionForm().quantityForm.quantity = 1; | |
DepositFixForm.widget.getSubscriptionForm().setQuantity(); | |
} | |
} | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment