SHARE
TWEET

UpsellModal footer code

mobas77 Nov 15th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {% if context == "checkout" %}
  2. <script>
  3. $(document).on("keyup", ".fc-modal [name='price']", updateOutcome);
  4. $(document).ready(updateOutcome);
  5.  
  6. function updateOutcome() {
  7.     var priceper = 10;
  8.     var peopleper = 4;
  9.     var quantity = Math.floor(parseInt(this.value)/priceper) * peopleper;
  10.     var amount = (!isNaN(parseFloat(this.value)) && isFinite(this.value)) ? "$" + this.value : "";
  11.     var people = (quantity > 0) ? quantity : "";
  12.     $(".dynamic-outcome .price").html(amount);
  13.     $(".dynamic-outcome .quantity").html(people);
  14. }
  15. </script>
  16. {% endif %}
  17.  
  18.  
  19.  
  20. {% if context == "checkout" %}
  21. <script>
  22.     var upsell_cookie_name = "fc_completed_upsell",
  23.         cookie_expires_in = 30; // default, in days
  24.  
  25.     $(function() {
  26.         var has_upsell_cookie = document.cookie.split(';').filter(function(item) {
  27.                 return item.indexOf(upsell_cookie_name + '=') >= 0
  28.             }).length;
  29.         if (has_upsell_cookie) {
  30.             $('[data-fc-id="block-upsell-modal"]').html("");
  31.             if (FC.checkout.upsell_modal) {
  32.                 FC.checkout.upsell_modal.close();
  33.             }
  34.         }
  35.  
  36.         // On closing the modal
  37.         $('body').on("mousedown", '[data-fc-id="block-upsell-modal"] [data-remodal-action="cancel"]', function() { addUpsellCookie(); });
  38.         // On submitting a form in the modal
  39.         $('body').on("submit", '[data-fc-id="block-upsell-modal"] form', function() { addUpsellCookie(); });
  40.     });
  41.  
  42.     function addUpsellCookie(days) {
  43.         var expires = "",
  44.             date = new Date(),
  45.             days = parseInt(days);
  46.  
  47.         if (typeof days !== "number" || !isFinite(days) || Math.floor(days) !== days) {
  48.             days = cookie_expires_in;
  49.         }
  50.  
  51.         date.setTime(date.getTime() + (days*24*60*60*1000));
  52.         expires = "; expires=" + date.toUTCString();
  53.         document.cookie = upsell_cookie_name + "=true" + expires + "; path=/";
  54.     }
  55. </script>
  56. {% endif %}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top