Plugin Directory

Changeset 2897079


Ignore:
Timestamp:
04/11/2023 10:00:53 AM (3 years ago)
Author:
ajithkumarvm
Message:

jquery injected if not found.

Location:
flowhippo-abandoned-cart-recovery/tags
Files:
9 added
1 edited

Legend:

Unmodified
Added
Removed
  • flowhippo-abandoned-cart-recovery/tags/1.1.0/facr_script.js

    r2897049 r2897079  
    22    var $ = $ || window.jQuery;
    33    var facr_data = window.facr_data;
    4     if (!facr_data){
     4    if (!facr_data) {
    55        return;
    66    }
    7     $(document).on('change', 'input#billing_phone,input#billing_email,input#shipping_phone,input#shipping_email', function() {
     7    $(document).on('change', 'input#billing_phone,input#billing_email,input#shipping_phone,input#shipping_email', function () {
    88        sendData('checkout-updated', $(this));
    99    });
     
    1111        sendData('checkout-page-loaded');
    1212    } else {
    13         $(document).ready(function() {
     13        $(document).ready(function () {
    1414            sendData('checkout-page-loaded');
    1515        });
    1616    }
    17     function sendData (event, thisObj) {
     17    function sendData(event, thisObj) {
    1818        var billingFields = {}
    1919        var shippingFields = {}
     
    2121        $('form input').each(function (e) {
    2222            var id = $(this).attr('id');
    23             if (id && id.indexOf('billing_') !== -1){
     23            if (id && id.indexOf('billing_') !== -1) {
    2424                id = id.replace('billing_', '');
    2525                billingFields[id] = $(this).val();
    26             } else if(id && id.includes('shipping')) {
     26            } else if (id && id.includes('shipping')) {
    2727                id = id.replace('shipping_', '');
    2828                shippingFields[id] = $(this).val();
     
    3838                id: $(thisObj).attr('id'),
    3939                name: $(thisObj).attr('name'),
    40                 label: $('[for='+ $(thisObj).attr('id')+']').text(),
     40                label: $('[for=' + $(thisObj).attr('id') + ']').text(),
    4141            }
    4242        }
     
    9696        });
    9797    }
    98     function mapCartData (_cartData) {
     98    function mapCartData(_cartData) {
    9999        var cartData = [];
    100100        Object.keys(_cartData).map(function (key, index) {
     
    113113        })
    114114        return cartData;
    115     } 
     115    }
    116116}
    117 facr_initialize(true);
     117if (!$ && !window.jQuery) {
     118    var script = document.createElement('script');
     119    script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js';
     120    script.type = 'text/javascript';
     121    script.onload = function () {
     122        var $ = window.jQuery;
     123        facr_initialize(false);
     124    };
     125    document.getElementsByTagName('head')[0].appendChild(script);
     126} else {
     127    facr_initialize(true);
     128}
Note: See TracChangeset for help on using the changeset viewer.