Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {% if context == "checkout" %}
- <script>
- $(document).on("keyup", ".fc-modal [name='price']", updateOutcome);
- $(document).ready(updateOutcome);
- function updateOutcome() {
- var priceper = 10;
- var peopleper = 4;
- var quantity = Math.floor(parseInt(this.value)/priceper) * peopleper;
- var amount = (!isNaN(parseFloat(this.value)) && isFinite(this.value)) ? "$" + this.value : "";
- var people = (quantity > 0) ? quantity : "";
- $(".dynamic-outcome .price").html(amount);
- $(".dynamic-outcome .quantity").html(people);
- }
- </script>
- {% endif %}
- {% if context == "checkout" %}
- <script>
- var upsell_cookie_name = "fc_completed_upsell",
- cookie_expires_in = 30; // default, in days
- $(function() {
- var has_upsell_cookie = document.cookie.split(';').filter(function(item) {
- return item.indexOf(upsell_cookie_name + '=') >= 0
- }).length;
- if (has_upsell_cookie) {
- $('[data-fc-id="block-upsell-modal"]').html("");
- if (FC.checkout.upsell_modal) {
- FC.checkout.upsell_modal.close();
- }
- }
- // On closing the modal
- $('body').on("mousedown", '[data-fc-id="block-upsell-modal"] [data-remodal-action="cancel"]', function() { addUpsellCookie(); });
- // On submitting a form in the modal
- $('body').on("submit", '[data-fc-id="block-upsell-modal"] form', function() { addUpsellCookie(); });
- });
- function addUpsellCookie(days) {
- var expires = "",
- date = new Date(),
- days = parseInt(days);
- if (typeof days !== "number" || !isFinite(days) || Math.floor(days) !== days) {
- days = cookie_expires_in;
- }
- date.setTime(date.getTime() + (days*24*60*60*1000));
- expires = "; expires=" + date.toUTCString();
- document.cookie = upsell_cookie_name + "=true" + expires + "; path=/";
- }
- </script>
- {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement