SHARE
TWEET

Untitled

PalmeseJohn Oct 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--// 2step-Checkout Page Code //-->
  2. <!--/////////////// CF Funnel Total Tracker ///////////////-->
  3. <script>
  4. $(function () {
  5.   window.cfptCurrency = 'USD'; //set to whatever currency you process in
  6.   // set total on button click for OTO pages
  7.   $('[data-title*="cf-oto-cents-"]').on('click', function () {
  8.     var titleParts = $(this).attr('data-title').split(' ');
  9.     var total = null;
  10.     $.each(titleParts, function (index, value) {
  11.       if (value.indexOf('cf-oto-cents-') > -1) {
  12.         total = value.split('-').pop();
  13.         total = parseInt(total) / 100;
  14.         return false; //break out of the loop
  15.       }
  16.     });
  17.     if (!isNaN(total)) {
  18.       window.cfptOrderTotal = total;
  19.       setLastTransLocalStorage();
  20.     }
  21.   });
  22.   function setLastTransLocalStorage() {
  23.     localStorage.setItem('cfptLastTransAmt', window.cfptOrderTotal);
  24.     localStorage.setItem('cfptLastTransPath', document.location.pathname);
  25.   }
  26.   // set localStorage vals on cfAR form submit
  27.   $('[href="#submit-form"], [href="#submit-form-2step-order"], [href*="#yes-link"]').on('click', function () {
  28.     if (window.cfptOrderTotal) {
  29.       setLastTransLocalStorage();
  30.     }
  31.   });
  32.   $('#cfAR').on('submit', function () {
  33.       if (window.cfptOrderTotal) {
  34.         setLastTransLocalStorage();
  35.       }
  36.   });
  37.   // handle grabbing totals from last trans and fire events
  38.   var cfptLastTransAmt = localStorage.getItem('cfptLastTransAmt');
  39.   var cfptLastTransPath = localStorage.getItem('cfptLastTransPath');
  40.   var cfptCurrPagePath = document.location.pathname;
  41.   // if the last path and the current path match
  42.   // this is a page reload, which would be a failure
  43.   // so remove the items to start fresh
  44.   if (cfptLastTransPath && cfptLastTransPath == cfptCurrPagePath) {
  45.     cfptLastTransAmt = null;
  46.     cfptLastTransPath = null;
  47.     clearLastTransLocalStorage();
  48.   }
  49.   // if we have an amount and we can convert that amount to a float
  50.   // store that float into the last transAmt var
  51.   if (cfptLastTransAmt) {
  52.     cfptLastTransAmt = parseFloat(cfptLastTransAmt);
  53.     if (!isNaN(cfptLastTransAmt)) {
  54.       firePurchaseEvents(cfptLastTransAmt);
  55.     }
  56.   }
  57.   function firePurchaseEvents(amt) {
  58.     if (typeof fbq != 'undefined') {
  59.       fireFBPurchaseEvent(amt);
  60.     }
  61.     clearLastTransLocalStorage();
  62.   }
  63.   function fireFBPurchaseEvent(amt) {
  64.     fbq('track', 'Purchase', {value: amt, currency: window.cfptCurrency});
  65.   }
  66.   function clearLastTransLocalStorage() {
  67.     localStorage.removeItem('cfptLastTransAmt');
  68.     localStorage.removeItem('cfptLastTransPath');
  69.   }
  70. });
  71. </script>
  72.  
  73. <!--/////////////// CF 2 Step Track Lead (AddToCart) ///////////////-->
  74. <script>
  75. $(function () {
  76.     $('[href="#submit-form-2step"]').on("click", function () {
  77.         fbq('track','AddToCart');
  78.     });
  79. });
  80. </script>
  81.  
  82. <!--/////////////// CF Order Summary ///////////////-->
  83. <script>
  84. CFPT = {};
  85. CFPT.prodPrices = { //modify with your product IDs and prices
  86.     '1234567': 0, // key = product_id; value = true product price float
  87.     '7654321': 7.95
  88. };
  89. CFPT.freePriceDisplay = 'FREE'; //what to say for subtotal when price is $0.00
  90. CFPT.orderTotalLabel = 'Order Total:'; //what to say for Order Total at the bottom
  91. // END OPTIONAL CONFIGURATION //
  92. </script>
  93. <script>
  94. $(function () {
  95.     //set default value to kill bug in L&E JS
  96.     window.cfpe = window.cfpe || {};
  97.     window.cfpe.orderTotal = window.cfpe.orderTotal || 0;
  98.     window.cfptOrderTotal = null;
  99.     $('[data-de-type="ors"], .elOrderProductOptions:not(:has(input,select))').first().attr('data-title','cf-order-summary');
  100.     $('#bump-offer').off();
  101.     rebuildOrderSummary();
  102.     $(document).on("change", '.qty_select, .o2step_step2 [name="purchase[product_id]"], [data-de-type="orpo"] [name="purchase[product_id]"], #bump-offer', function (ev) {
  103.         $('#bump-offer, [id*="bump_offer_"]').each(function () {
  104.             var bumpId = $(this).val();
  105.             if ($(this).is(':checked')) {
  106.                 $('#cfAR [name="purchase[product_ids][]"][value="'+bumpId+'"]').attr('checked', true);
  107.             } else {
  108.                 $('#cfAR [name="purchase[product_ids][]"][value="'+bumpId+'"]').attr('checked', false);
  109.             }
  110.         });
  111.         rebuildOrderSummary();
  112.     });
  113.     $(document).on('cfpt:cart-updated', function () {
  114.         rebuildOrderSummary();
  115.     });
  116. });
  117. function rebuildOrderSummary() {
  118.     var cfpt = window.CFPT || {};
  119.     var prodPrices = cfpt.prodPrices || {};
  120.     var freePriceDisplay = cfpt.freePriceDisplay || null;
  121.     var orderTotalLabel = cfpt.orderTotalLabel || null;
  122.     var prodSelParent = '[data-de-type="orpo"]';
  123.     var appendTo = '[data-title="cf-order-summary"] .elOrderProductOptions';
  124.     var cartMode = ($('.qty_select').length) ? true : false;
  125.     if ($('.o2step_wrapper').length > 0) {
  126.         prodSelParent = '.o2step_step2';
  127.         appendTo = '[data-title="cf-order-summary"]';
  128.     }
  129.     $('[data-title="cf-order-summary"]').hide();
  130.     if ($('[data-title="cf-order-summary"] .qty-head').length == 0 && $('.qty_select').length > 0) {
  131.         $('[data-title="cf-order-summary"] .elOrderProductOptinLabel .elOrderProductOptinItem').before('<div class="pull-left qty-head">Qty</div>');
  132.     }
  133.     var $summTemplate = $("<div/>").addClass("clearfix elOrderProductOptinProducts");
  134.     $summTemplate.append($("<div/>").addClass("pull-left elOrderProductOptinProductName product-name").css("width","inherit"));
  135.     $summTemplate.append($("<div/>").addClass("pull-right elOrderProductOptinPrice product-price"));
  136.     var orderTotal = 0.00;
  137.     var orderCurrency = "USD"; //default
  138.     $('[data-title="cf-order-summary"] .elOrderProductOptinProducts').remove();
  139.     window.cfptCartProds = {};
  140.     $('#cfAR [name="purchase[product_ids][]"]:checked').each(function () {
  141.         var prodId = $(this).val();
  142.         if (window.cfptCartProds.hasOwnProperty(prodId)) {
  143.             window.cfptCartProds[prodId].qty++;
  144.         } else {
  145.             window.cfptCartProds[prodId] = {qty: 1};
  146.         }
  147.     });
  148.     //$('#cfAR [name="purchase[product_ids][]"]:checked').each(function () {
  149.     $.each(window.cfptCartProds, function (index, value) {
  150.         var qty = value.qty;
  151.         var prodId = index;
  152.         var $prodItem = $(prodSelParent+' [name="'+prodId+'_qty"]');
  153.         if (!$prodItem.length) {
  154.             $prodItem = $(prodSelParent+' [name="purchase[product_id]"][value="'+prodId+'"]');
  155.         }
  156.         var prodDesc = $prodItem.nextAll('label').html();
  157.         var prodPriceStr = $prodItem.nextAll('.elOrderProductOptinPrice').html();
  158.         if (prodPrices.hasOwnProperty(prodId)) {
  159.             var prodPriceNum = prodPrices[prodId].toFixed(2);
  160.         } else {
  161.             var prodPriceNum = parseFloat(prodPriceStr.replace(/[^0-9\.]+/g, "")).toFixed(2);
  162.         }
  163.         var subTotal = qty * prodPriceNum;
  164.         var currency = $prodItem.nextAll('.elOrderProductOptinPrice').attr("taxamo-currency");
  165.         orderCurrency = currency;
  166.         $currTemplate = $summTemplate.clone();
  167.         $currTemplate.attr('data-product_id', prodId);
  168.         $currTemplate.attr('data-quantity', qty);
  169.         var prodName = prodDesc;
  170.         if ($('.qty_select').length > 0) {
  171.             prodName = '<span class="prodQty">'+qty+'</span>'+prodDesc;
  172.         }
  173.         $currTemplate.find('.product-name').html(prodName);
  174.         if (freePriceDisplay && subTotal == 0) {
  175.             $currTemplate.find('.product-price').attr("taxamo-currency",currency).html(freePriceDisplay);
  176.             $currTemplate.attr('data-subtotal', freePriceDisplay);
  177.         } else {
  178.             var priceDisplay = subTotal.toLocaleString(undefined, {style: 'currency', currency: currency});
  179.             $currTemplate.find('.product-price').attr("taxamo-currency",currency).html(priceDisplay);
  180.             $currTemplate.attr('data-subtotal', priceDisplay);
  181.         }
  182.         $currTemplate.appendTo($(appendTo));
  183.         orderTotal += subTotal;
  184.     });
  185.     if (orderTotal) {
  186.         $ttlTemplate = $summTemplate.clone();
  187.         $ttlTemplate.addClass('cf-order-total-row').css({'border-top': '1px solid #DDD', 'margin-top': '.5em'});
  188.         $ttlTemplate.find('.product-name').html(orderTotalLabel);
  189.         $ttlTemplate.find('.product-price').attr("taxamo-currency",orderCurrency).html(orderTotal.toLocaleString(undefined, {style: 'currency', currency: orderCurrency}));
  190.         $ttlTemplate.appendTo($(appendTo));
  191.         $('[data-title="cf-order-summary"]').show();
  192.         window.cfptOrderTotal = orderTotal;
  193.     } else {
  194.         $('[data-title="cf-order-summary"]').hide();
  195.         window.cfptOrderTotal = null;
  196.     }
  197. }
  198. </script>
  199. <style>
  200. .cf-order-total-row {
  201.     border-top: 1px solid #DDD;
  202.     margin-top: .5em
  203. }
  204. .cf-order-total-row .product-name {
  205.     font-weight: bold;
  206. }
  207. .cf-order-total-row .product-price {
  208.     font-weight: bold;
  209. }
  210. [data-de-type='ors'] .elOrderProductOptinLabel .elOrderProductOptinItem {
  211.     /* margin-left: 2em; */
  212. }
  213. [data-de-type='ors'] .qty-head {
  214.     width: 3em;
  215. }
  216. .prodQty {
  217.     display: inline-block;
  218.     width: 3em;
  219. }
  220. </style>
  221.  
  222. <!--/////////////// CF Best Seller Highlight ///////////////-->
  223. <style>
  224. span.best-seller-head {
  225.   font-weight: bold;
  226.   color: red;
  227.   text-transform: uppercase;
  228. }
  229. input[type='radio'] {
  230.   vertical-align: top;
  231. }
  232. .elOrderProductOptinProductName label {
  233.   display: inline-block;
  234.   max-width: 65%;
  235. }
  236. div.best-seller {
  237.   font-weight: bold;
  238.   /*background-color: #FDF107;*/
  239.   background-image: linear-gradient(to bottom right, #ffeb00, #FDF107);
  240.   border: 1px solid #000000;
  241.   border-radius: 5px;
  242.   margin: 0 -10px .5em;
  243.   padding: 10px 10px;
  244.   font-size: 1.1em;
  245.   -webkit-box-shadow: 0px 10px 5px -5px rgba(0,0,0,0.5);
  246.   -moz-box-shadow: 0px 10px 5px -5px rgba(0,0,0,0.5);
  247.   box-shadow: 0px 10px 5px -5px rgba(0,0,0,0.5);
  248. }
  249. div.best-seller:hover {
  250.     background-image: linear-gradient(to bottom right, #fff258, #fff52e);
  251.     box-shadow: 0px 10px 5px -5px rgba(0, 0, 0, 0.4);
  252.     border: 1px solid #060606;
  253. }
  254. .activeRadioProduct {
  255.     background: inherit !important;
  256. }
  257. </style>
  258. <script> //STRIPE-CC PRODUCT ID HERE!
  259. $(function() {
  260.     var productId = "2317180"; //TODO: your product ID goes here
  261.     var head = "Most Popular!"; //TODO: change this text to whatever you like
  262.     $('.elOrderProductOptinProductName input[value="'+productId+'"]').siblings('label').html('<span class="best-seller-head">'+head+'</span><br />'+$('.elOrderProductOptinProductName input[value="'+productId+'"]').siblings('label').html());
  263.     $('.elOrderProductOptinProductName input[value="'+productId+'"]').closest('.elOrderProductOptinProducts').addClass('best-seller');
  264. });
  265. </script>
  266.  
  267. <!--/////////////// CF Select Default ///////////////-->
  268. <script>
  269. $(function () {
  270.     $('#cfAR input[name="purchase[product_id]"]').remove();
  271.     var selectedProduct = '2317180'; //TODO: enter the product ID you want to be selected by default
  272.     $('#pid-'+selectedProduct+':not(#cfAR input)').click();
  273. });
  274. </script>
  275.  
  276. <!--// DISCLAMER: //
  277. * Copyright 2018 CF Pro Tools, All Rights Reserved
  278. * Do not share, or distribute this code without author's consent.
  279. * This copyright notice must remain in place whenever using
  280. * this code - DO NOT REMOVE
  281. * Author: Jaime Smith
  282. * Website: https://cfprotools.com
  283. -->
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