Created
September 20, 2019 22:57
-
-
Save denlunev/db30e767bf229cefdc165ee79c30f069 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_I7TPzodT3rJDrgev8JNV5ANu00PGV95PlY', | |
mode: 'live', | |
accountId: '470002' | |
} | |
}, | |
products: [{ | |
id: "plan_FqF2HTWCenyNFd", | |
type: "subscription", | |
name: "ArBCA Annual Membership (Single)", | |
amount: 25, | |
showQuantity: true, | |
addon: false | |
},{ | |
id: "plan_FqF4A3jQ0jv0Ks", | |
type: "subscription", | |
name: "ArBCA Annual Membership (Staff)", | |
amount: 80, | |
showQuantity: true, | |
addon: false | |
}], | |
callbacks: { | |
onFormReady: function(){ | |
var maxCoaches = 15; | |
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_FqF4A3jQ0jv0Ks' == 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