PageSourceSearch

https://www.kidsincrisis.org/wp-content/plugins/obituary-assistant…flower-delivery-public.js?ver=250904-155437

js kidsincrisis.org collected 2026-10-01 14:42:30 UTC 56,464 bytes, 1,596 lines download raw bytes

1(function($) {
2  'use strict';
3
4  var ajaxurl = oaInfo.ajax_url;
5  var historyBool = false;
6  //window.localStorage.clear();
7
8
9  $(window).ready(function() {
10
11    if ($('#client_type').val() == 5 || $("#client_type").val() == 7) {
12
13      $('#florist-one-flower-delivery-menu-nav').remove();
14      $('.florist-one-flower-delivery-menu').html('<li style="display:none" class="nav-item m-1 border"><a href="#" id="florist-one-flower-delivery-menu-link-0" class="nav-link florist-one-flower-delivery-menu-plant-a-tree-link" data-category="pt" data-bs-toggle="collapse" data-bs-target=".navbar-collapse.show" >Plant Trees</a></li>');
15
16
17    } else {
18
19      $('#florist-one-flower-delivery-menu-nav').removeClass('d-none');
20
21    }
22
23    // set session variables for prepopulations
24    var dataStored = {
25      'action': 'setFlowerSessionData',
26      'name': $("#florist-one-flower-delivery-recipient-name").val(),
27      'tree-name-of-loved-one': $("#florist-one-flower-delivery-tree-certificate-name-of-loved-one").val(),
28      'institution': $("#florist-one-flower-delivery-recipient-institution").val(),
29      'address1': $("#florist-one-flower-delivery-recipient-address-1").val(),
30      'address2': $("#florist-one-flower-delivery-recipient-address-2").val(),
31      'city': $("#florist-one-flower-delivery-recipient-city").val(),
32      'state': $("#florist-one-flower-delivery-recipient-state").val(),
33      'zip': $("#florist-one-flower-delivery-recipient-postal-code").val(),
34      'country': $("#florist-one-flower-delivery-recipient-country").val(),
35      'phone': $("#florist-one-flower-delivery-recipient-phone").val(),
36      'facility_id': $("#florist-one-flower-delivery-facility-id").val(),
37      'obit_id': $("#obit_id").val(),
38      'random': Math.random()
39    };
40
41    var localStorageData = JSON.parse(window.localStorage.getItem('chekoutInfo'));
42    if (localStorageData != null) {
43
44      jQuery.each(localStorageData, function(key, value) {
45
46        dataStored[key] = value;
47
48      });
49
50    }
51
52    //display checkout stored values
53    jQuery.post(ajaxurl + "?_r=" + Math.random(), dataStored);
54
55    //get cart count and display
56    jQuery.post(ajaxurl + "?_r=" + Math.random(), {
57      'action': 'getCartCount',
58      'random': Math.random()
59    }, function(response, status) {
60      jQuery('#florist-one-cart-count').html(response);
61    }, "html");
62
63    //modal
64
65    $('#florist-one-flower-delivery-view-modal').on('shown.bs.modal', function(event) {
66      var $modal = $('#florist-one-flower-delivery-view-modal');
67
68      $modal.find('.modal-header-text').html('').text(event.relatedTarget.text);
69
70      if ($(event.relatedTarget).hasClass('florist-one-flower-delivery-menu-cart-button') || $(event.relatedTarget).hasClass('florist-one-flower-delivery-add-to-cart')) {
71        $('.modal-header-text').html(jQuery('.florist-one-flower-delivery-menu-cart-button p').text());
72      }
73
74      if (event.relatedTarget.id == "florist-one-flower-delivery-menu-link-99") {
75        $('#florist-one-flower-delivery-view-modal').find('.modal-footer').hide();
76      } else {
77        $('#florist-one-flower-delivery-view-modal').find('.modal-footer').show();
78      }
79      if ($('.checkout-form').is(':visible')) {
80        $('#florist-one-flower-delivery-view-modal-close').hide();
81      } else {
82        $('#florist-one-flower-delivery-view-modal-close').show();
83      }
84    });
85
86    $('#florist-one-flower-delivery-view-modal').on('hide.bs.modal', function(event) {
87
88      if ($('.checkout-form').is(':visible')) {
89        getCheckout();
90      }
91      jQuery.post(ajaxurl + "?_r=" + Math.random(), {
92        'action': 'getCartCount',
93        'random': Math.random()
94      }, function(response, status) {
95        jQuery('#florist-one-cart-count').html(response);
96      }, "html");
97      var $modal = $('#florist-one-flower-delivery-view-modal');
98      $modal.find('.modal-body').html("");
99    });
100
101
102    if ($(".florist-one-flower-delivery-menu").get(0)) {
103
104      if ($('#client_type').val() != 5) {
105        $('.florist-one-flower-delivery-ssl-warning').css('display', 'block');
106      }
107
108      var pagetitle = $(document).find("title").text();
109      if (getUrlParameter('viewitem')) {
110        var data = {
111          'action': 'getProduct',
112          'code': getUrlParameter('viewitem'),
113          'random': Math.random()
114        };
115      } else if (getUrlParameter('buyitem')) {
116        var data = {
117          'action': 'addToCart',
118          'code': getUrlParameter('buyitem'),
119          'random': Math.random()
120        };
121      } else if ($(".florist-one-flower-delivery-container").attr("data-def_cat")) {
122        if ($(".florist-one-flower-delivery-container").attr("data-def_cat") != 'cart') {
123          var data = {
124            'action': 'getProducts',
125            'category': $(".florist-one-flower-delivery-container").attr("data-def_cat"),
126            'page': 1,
127            'random': Math.random()
128          };
129        } else {
130          var data = {
131            'action': 'getCart',
132            'random': Math.random()
133          };
134        }
135      } else if (getUrlParameter('revieworder')) {
136
137        historyBool = true;
138        var data = {
139          'action': 'checkout',
140          'page': 4,
141          'formdata': dataStored,
142          'obituary': ($('#fhws-main-obit').is(':visible')) ? 1 : 0,
143          'validated': null,
144          'random': Math.random()
145        };
146      } else if (getUrlParameter('orderno')) {
147
148        var purchaseData = {
149          "order_id": getUrlParameter('orderno'),
150        }
151
152        checkout(5, purchaseData);
153
154      } else if (getUrlParameter('show_trees') == 1 || $('#client_type').val() == 5 || $("#client_type").val() == 7) {
155        var data = {
156          'action': 'getTree',
157          'code': 'TREES',
158          'random': Math.random()
159        };
160      } else {
161        var data = {
162          'action': 'getProducts',
163          'category': (($(".florist-one-flower-delivery-container").attr("data-def_cat")) ? $(".florist-one-flower-delivery-container").attr("data-def_cat") : 'default'),
164          'page': 1,
165          'random': Math.random()
166        };
167      }
168      History.pushState(data, pagetitle, "");
169    }
170
171  });
172
173  $(document).on("click", "a.florist-one-flower-delivery-menu-link", function(e) {
174
175    e.preventDefault();
176    var data = {
177      'action': 'getProducts',
178      'category': $(this).attr("data-category"),
179      'page': $(this).attr("data-page")
180    };
181    History.pushState(data, "", "");
182  });
183
184  // trees
185  function selectYourOwnTreeCalc(amount, number, calc, minTrees) {
186
187    var totalPrice = (amount != null) ? (Math.round(amount * 100) / 100).toFixed(2) : '';
188    var getPrice = $('.florist-one-flower-delivery-plant-a-tree-select-your-own-price').text();
189    var pricePresent = isNaN(getPrice);
190    var $container = $('#fws-trees-calculate-msg');
191    var $addToCart = '<svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" stroke-width="2" fill="currentColor" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><circle cx="9" cy="21" r="1"></circle><circle cx="20" cy="21" r="1"></circle><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path></svg>';
192    var min = '<div class="alert alert-danger lh-base" role="alert">We’re sorry but the minimum number of trees that can be planted is ' + minTrees + '</div>';
193    var useModal = ($('#florist-one-flower-delivery-view-modal').hasClass('show')) ? "" : 'data-bs-toggle="modal"';
194    var price = ' <p class="fs-5 florist-one-flower-delivery-plant-a-tree-select-your-own-price">$' + totalPrice + '</p>' +
195      '<button type="button" data-checkout="show" href="#" class="f1fd_primary florist-one-flower-delivery-add-to-cart btn mt-3" ' + useModal + ' data-bs-target="#florist-one-flower-delivery-view-modal" id="plant-a-tree-add-to-cart2">Add To Cart ' + $addToCart + '</button>'
196    var msg = (number < parseInt(minTrees)) ? min : (calc) ? price : (pricePresent) ? getPrice : '';
197    $container.html(msg);
198
199    if (calc) {
200
201      $('#plant-a-tree-add-to-cart2').attr('data-number', number)
202        .attr('data-price', amount)
203        .attr('data-name', 'Plant ' + number + " Trees")
204        .attr('data-code', 'Plant ' + number + " Trees");
205
206    }
207
208  }
209
210  function calculateTreePrice(minTrees, trees, element, radio) {
211
212    var each = 0;
213    if (trees > 4 && trees < 12) {
214      each = 10;
215    } else if (trees > 11 && trees < 30) {
216      each = 8.33;
217    } else if (trees > 29) {
218      each = 8;
219    }
220
221    if (isNaN(trees) || trees < minTrees) {
222      element.focus();
223    } else {
224      var data = {
225        'action': 'getTreesTotal',
226        'code': "TREES",
227        'number': trees,
228        'price': (trees * each).toFixed(2),
229        'client_id': $("#client_id").val(),
230      };
231
232      if (!radio) {
233        jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
234          selectYourOwnTreeCalc(response, trees, true, minTrees);
235        }, "html");
236      } else {
237        jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
238          element.attr("data-price", response);
239          element.attr("data-number", trees);
240          element.attr("data-code", "Plant-" + trees + '-Trees');
241          element.attr("data-name", "Plant " + trees + ' Trees');
242        });
243      }
244
245    }
246
247  }
248
249  $(document).on("input", "#florist-one-flower-delivery-plant-a-tree-select-your-own", function(e) {
250
251    selectYourOwnTreeCalc(null, this.value, false, $(this).attr('min'));
252
253  });
254
255
256  $(document).on("change", "#florist-one-flower-delivery-recipient-country", function(e) {
257
258    var d = '#florist-one-flower-delivery-recipient-state';
259    var pc = '#florist-one-flower-delivery-recipient-postal-code';
260
261    function _rx(e, s, d) {
262      var c = 'fhws-hide-state';
263      var t = $("." + e);
264      t.removeClass(c);
265      if (s == "hide") {
266        t.addClass(c)
267      }
268      $(d).val('');
269      $(pc).val('');
270    }
271    switch (this.value) {
272      case "CA":
273        _rx("fhws-country-rec-ca", "show", d);
274        _rx("fhws-country-rec-us", "hide", d);
275        $(d).prop("disabled", false);
276        $(pc).prop("disabled", false);
277        $(d).prev().text('Province*')
278        $(pc).attr("placeholder", "Postal Code*").prev().text('Postal Code*');
279
280        break;
281      case "US":
282        _rx("fhws-country-rec-ca", "hide", d);
283        _rx("fhws-country-rec-us", "show", d);
284        $(d).prop("disabled", false);
285        $(pc).prop("disabled", false);
286        $(d).prev().text('State*')
287        $(pc).attr("placeholder", "Zip Code*").prev().text('Zip Code*');
288        break;
289      default:
290
291    }
292
293
294  });
295
296  $(document).on("change", "#florist-one-flower-delivery-customer-country", function(e) {
297
298    var d = '#florist-one-flower-delivery-customer-state';
299    var pc = '#florist-one-flower-delivery-customer-postal-code';
300
301    function _x(e, s, d) {
302      var c = 'fhws-hide-state';
303      var t = $("." + e);
304      t.removeClass(c);
305      if (s == "hide") {
306        t.addClass(c)
307      }
308      $(d).val('');
309      $(pc).val('');
310    }
311    switch (this.value) {
312      case "CA":
313        _x("fhws-country-ca", "show", d);
314        _x("fhws-country-us", "hide", d);
315        $(d).prop("disabled", false);
316        $(pc).prop("disabled", false);
317        $(d).prev().text('Province*')
318        $(pc).attr("placeholder", "Postal Code*").prev().text('Postal Code*');
319        $(d + ' option:first').html('&#8212; Select &#8212;');
320
321        break;
322      case "US":
323        _x("fhws-country-ca", "hide", d);
324        _x("fhws-country-us", "show", d);
325        $(d).prop("disabled", false);
326        $(pc).prop("disabled", false);
327        $(d).prev().text('State*')
328        $(pc).attr("placeholder", "Zip Code*").prev().text('Zip Code*');
329        $(d + ' option:first').html('&#8212; Select &#8212;');
330        break;
331      default:
332        _x("fhws-country-ca", "hide");
333        _x("fhws-country-us", "hide");
334        $(d).prop("disabled", true);
335        $(d).val('');
336        if ($(d).next().hasClass('alert-danger')) {
337          $(d).next().remove();
338        }
339        if ($(pc).next().hasClass('alert-danger')) {
340          $(pc).next().remove();
341        }
342        $(pc).prop("disabled", false);
343        $(d).prev().text('State');
344        $(pc).attr("placeholder", "Postal Code").prev().text('Postal Code');
345        $(d + ' option:first').html('&#8212; Not Required &#8212;');
346    }
347
348  });
349
350  $(document).on("click", ".country-trigger", function(e) {
351
352
353    if ($('#' + $(this).children(":first").next().attr('id')).is(':disabled')) {
354      $("#florist-one-flower-delivery-customer-country").focus();
355    }
356
357  });
358
359  $(document).on("keydown", "#florist-one-flower-delivery-tree-certificate-sender-display-name, #florist-one-flower-delivery-tree-certificate-name-of-loved-one", function(e) {
360
361    if ($(this).length < 59) {
362      $(this).val($(this).val().substring(0, 59));
363    }
364
365  });
366
367
368  $(document).on("click", ".florist-one-flower-delivery-plant-a-tree-select-your-own-calculate", function(e) {
369
370    e.preventDefault();
371
372    calculateTreePrice(
373      $('#florist-one-flower-delivery-plant-a-tree-select-your-own').attr('min'),
374      parseInt($('#florist-one-flower-delivery-plant-a-tree-select-your-own').val().trim()),
375      $('#florist-one-flower-delivery-plant-a-tree-select-your-own')
376    );
377
378  });
379
380  $(document).on("click", "#florist-one-flower-delivery-tree-certificate-wrapper .trees-checkout", function(e) {
381
382    // switch radio button on input
383    if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") {
384
385      jQuery("input:radio").eq($(".trees-checkout").index(this)).attr("checked", true).trigger("click");
386
387    }
388
389  });
390
391  // end trees
392
393  $(document).on("click", "a.florist-one-flower-delivery-menu-plant-a-tree-link", function(e) {
394
395    if ($(this).attr("href") == '#') {
396      e.preventDefault();
397      $('#checkout-tree-button').remove(); // used if account type is 5 or 7 trees only
398      var data = {
399        'action': 'getTree',
400        'code': "TREES"
401      };
402      History.pushState(data, "", "");
403    }
404  });
405
406  $(document).on("click", ".florist-one-flower-delivery-menu-link-more", function(e) {
407
408    e.preventDefault();
409
410    var data = {
411      'action': 'getProductsMore',
412      'category': $(this).attr("data-category"),
413      'page': $(this).attr("data-current-page"),
414      'random': Math.random()
415    };
416
417
418    if (parseInt($(this).attr("data-current-page")) == parseInt($(this).attr("data-pages"))) {
419
420      $(this).remove();
421    }
422    $(this).attr("data-current-page", parseInt($(this).attr("data-current-page")) + 1);
423    History.pushState(data, "", "");
424
425  });
426
427
428  $(document).on("click", ".florist-one-flower-delivery-many-products-single-product", function(e) {
429
430    if ($(this).attr("href") == '#' && $(this).attr("data-code") != 'TREES') {
431
432      var thisCode = $(this).attr("data-code");
433      $("#checkout-tree-button").remove();
434
435      e.preventDefault();
436      var data = {
437        'action': (thisCode == "TREES") ? 'getTree' : 'getProduct',
438        'code': thisCode,
439        'random': Math.random()
440      };
441      History.pushState(data, "", "");
442    } else if ($(this).attr("data-code") == 'TREES') {
443
444      $("a[data-category=pt]").trigger("click");
445
446    }
447
448  });
449
450  $(document).on("change", "input[type=radio][name=number_of_trees]", function(e) {
451
452    e.preventDefault();
453
454    var trees = $("input[type=radio][name=number_of_trees]:checked").val();
455
456    calculateTreePrice(
457      0,
458      trees,
459      $("#plant-a-tree-add-to-cart1"),
460      true
461    );
462
463    $("#fws-trees-calculate-msg-choose-number").html('');
464
465  });
466
467  $(document).on("click", ".florist-one-flower-delivery-add-to-cart", function(e) {
468
469    // if tree added and no radio option selected
470    if ($(this).attr("id") == "plant-a-tree-add-to-cart1" && (!($("input[type=radio][name=number_of_trees]").length && $("input[type=radio][name=number_of_trees]:checked").val()))) {
471      e.preventDefault();
472      $("input[type=radio][name=number_of_trees]").focus();
473      $('#florist-one-flower-delivery-view-modal').hide()
474      $("#fws-trees-calculate-msg-choose-number").html('<div class="alert alert-danger">Please choose an option above.</div>');
475      return;
476    }
477
478    if ($(this).attr("href") == '#') {
479      historyBool = true;
480      e.preventDefault();
481      var data = {
482        'action': 'addToCart',
483        'code': $(this).attr("data-code"),
484        'num': ($('#fws-add-to-cart-amount').is(":visible")) ? $('#fws-add-to-cart-amount').val() : 1,
485        'random': Math.random()
486
487      };
488
489      History.pushState(data, "", "");
490    }
491    jQuery.post(ajaxurl + "?_r=" + Math.random(), {
492      'action': 'getCartCount',
493      'random': Math.random()
494    }, function(response, status) {
495      jQuery('#florist-one-cart-count').html(response);
496    }, "html");
497
498  });
499
500  $(document).on("click", ".florist-one-flower-delivery-menu-cart-button", function(e) {
501    e.preventDefault();
502    //checkout
503    var data = {
504      'action': 'getCart',
505      'code': null,
506      'random': Math.random()
507    };
508    History.pushState(data, "", "");
509    //get cart count and display
510    jQuery.post(ajaxurl + "?_r=" + Math.random(), {
511      'action': 'getCartCount',
512      'random': Math.random()
513    }, function(response, status) {
514      jQuery('#florist-one-cart-count').html(response);
515    }, "html");
516
517  });
518
519  $(document).on("click", "a.florist-one-flower-delivery-cart-remove-item", function(e) {
520    e.preventDefault();
521    removeFromCart($(this).attr("data-code"));
522    jQuery.post(ajaxurl + "?_r=" + Math.random(), {
523      'action': 'getCartCount',
524      'random': Math.random()
525    }, function(response, status) {
526      jQuery('#florist-one-cart-count').html(response);
527    }, "html");
528
529  });
530
531  $(document).on("click", "a.florist-one-flower-delivery-menu-customer-service-link", function(e) {
532    e.preventDefault();
533    var data = {
534      'action': 'getCustomerService'
535    };
536    History.pushState(data, "", "");
537  });
538
539  $(document).on("focusout", ".checkout-form", function(e) {
540
541    var key = e.target.name;
542    var value = e.target.value;
543
544    if (e.target.name == "florist-one-flower-delivery-tree-certificate") {
545
546      //store checkout in local storage
547      var checkoutInput = (JSON.parse(window.localStorage.getItem('chekoutInfo')) == null) ? {} : JSON.parse(window.localStorage.getItem('chekoutInfo'));
548      checkoutInput[key] = value;
549      window.localStorage.setItem('chekoutInfo', JSON.stringify(checkoutInput));
550
551    } else if (e.target.name != "florist-one-flower-delivery-purchase-recognition-check") {
552      // validate and store value in local storage
553      var validator = $(".checkout-form").validate();
554      validator.element("#" + key);
555
556      var validator = $(".checkout-form").data('validator');
557      if (validator.check("#" + key)) {
558
559        //store checkout in local storage
560        var checkoutInput = (JSON.parse(window.localStorage.getItem('chekoutInfo')) == null) ? {} : JSON.parse(window.localStorage.getItem('chekoutInfo'));
561        checkoutInput[key] = value;
562        window.localStorage.setItem('chekoutInfo', JSON.stringify(checkoutInput));
563
564      }
565    }
566
567  });
568
569  $(document).on('change', 'input[Id="florist-one-flower-delivery-purchase-recognition-check"]', function(e) {
570
571    //store checkout in local storage
572    var checkoutInput = (JSON.parse(window.localStorage.getItem('chekoutInfo')) == null) ? {} : JSON.parse(window.localStorage.getItem('chekoutInfo'));
573    checkoutInput["florist-one-flower-delivery-purchase-recognition-check"] = ($(this).prop('checked')) ? "on" : "";
574    window.localStorage.setItem('chekoutInfo', JSON.str
574ingify(checkoutInput));
575
576  });
577
578  $(document).on('change', 'input[Id="florist-one-flower-delivery-allow-substitutions-check"]', function(e) {
579
580    //store checkout in local storage
581    var checkoutInput = (JSON.parse(window.localStorage.getItem('chekoutInfo')) == null) ? {} : JSON.parse(window.localStorage.getItem('chekoutInfo'));
582    checkoutInput["florist-one-flower-delivery-allow-substitutions-check"] = ($(this).prop('checked')) ? "on" : "";
583    window.localStorage.setItem('chekoutInfo', JSON.stringify(checkoutInput));
584
585  });
586
587  $(document).on("click", ".checkout-form-continue-next-step", function(e) {
588    e.preventDefault();
589    $(".checkout-form").submit();
590
591  })
592
593
594  $(document).on("click", ".florist-one-flower-delivery-checkout", function(e) {
595    historyBool = true;
596    e.preventDefault();
597    document.querySelector(".florist-one-flower-delivery-menu").scrollIntoView(true);
598
599    var dataCheckout = {
600      'action': 'setFlowerSessionData',
601      'name': $("#florist-one-flower-delivery-recipient-name").val(),
602      'tree-name-of-loved-one': $("#florist-one-flower-delivery-tree-certificate-name-of-loved-one").val(),
603      'institution': $("#florist-one-flower-delivery-recipient-institution").val(),
604      'address1': $("#florist-one-flower-delivery-recipient-address-1").val(),
605      'address2': $("#florist-one-flower-delivery-recipient-address-2").val(),
606      'city': $("#florist-one-flower-delivery-recipient-city").val(),
607      'state': $("#florist-one-flower-delivery-recipient-state").val(),
608      'zip': $("#florist-one-flower-delivery-recipient-postal-code").val(),
609      'country': $("#florist-one-flower-delivery-recipient-country").val(),
610      'phone': $("#florist-one-flower-delivery-recipient-phone").val(),
611      'facility_id': $("#florist-one-flower-delivery-facility-id").val(),
612      'obit_id': $("#obit_id").val(),
613      'random': Math.random()
614    };
615
616    var localStorageData = JSON.parse(window.localStorage.getItem('chekoutInfo'));
617    if (localStorageData != null) {
618
619      jQuery.each(localStorageData, function(key, value) {
620        dataCheckout[key] = value;
621
622      });
623
624    }
625
626    var data = {
627      'action': 'checkout',
628      'page': 4,
629      'formdata': jQuery.post(ajaxurl + "?_r=" + Math.random(), dataCheckout),
630      'obituary': ($('#fhws-main-obit').is(':visible')) ? 1 : 0,
631      'validated': null,
632      'random': Math.random()
633    };
634    History.pushState(data, "", "");
635  });
636
637
638  History.Adapter.bind(window, "statechange", function() {
639
640    var state = History.getState();
641
642    if (state.data.action == 'getProducts') {
643      $("#florist-one-flower-delivery-menu-nav").find('a').removeClass("active");
644      if (state.data.category != "default") {
645        $("a.florist-one-flower-delivery-menu-link[data-category='" + state.data.category + "']").addClass("active");
646      } else {
647        $("#florist-one-flower-delivery-menu-link-1").addClass("active");
648      }
649      getProducts(state.data.category, state.data.page);
650    } else if (state.data.action == 'getProductsMore') {
651      getProductsMore(state.data.category, state.data.page);
652    } else if (state.data.action == 'getProduct') {
653      getProduct(state.data.code);
654
655    } else if (state.data.action == 'getTree') {
656      $("#florist-one-flower-delivery-menu-nav").find('a').removeClass("active");
657      $("a.florist-one-flower-delivery-menu-plant-a-tree-link").addClass("active");
658      getTree(state.data.code);
659    } else if (state.data.action == 'addToCart') {
660      //$("#florist-one-flower-delivery-menu-nav").find('a').removeClass("active");
661      if (historyBool) {
662        addToCart(state.data.code, state.data.num);
663      } else {
664        getCart(state.data.code);
665      }
666      historyBool = false;
667    } else if (state.data.action == 'getCart') {
668      //$("#florist-one-flower-delivery-menu-nav").find('a').removeClass("active");
669      getCart(state.data.code);
670    } else if (state.data.action == 'getCustomerService') {
671      $("#florist-one-flower-delivery-menu-nav").find('a').removeClass("active");
672      $("a.florist-one-flower-delivery-menu-customer-service-link").addClass("active");
673      showCustomerService();
674    } else if (state.data.action == 'checkout') {
675      $("a.florist-one-flower-delivery-menu-link").removeClass("active");
676      checkout(state.data.page, state.data.formdata, state.data.obituary, state.data.validated);
677    }
678
679  });
680
681  var getProducts = function(category, page) {
682
683    var data = {
684      'action': 'getProducts',
685      'category': category,
686      'page': page,
687      'facility_id': $('#facility_id').val()
688    };
689
690    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
691      make_page(response, status);
692    }, "html");
693
694  }
695
696  var getProductsMore = function(category, page) {
697
698    var data = {
699      'action': 'getProductsMore',
700      'category': category,
701      'page': page,
702      'facility_id': $('#facility_id').val()
703    };
704
705    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
706
707      jQuery('#florist-one-flower-delivery-many-products-display').append(response);
708      var itemsPage = (page == $('.florist-one-flower-delivery-menu-link-more').attr('data-pages')) ? $('.florist-one-flower-delivery-menu-link-more').attr('data-items-count') : $('.florist-one-flower-delivery-menu-link-more').attr('data-count') * page;
709      jQuery('#florist-one-pagnation').text(itemsPage);
710
711    }, "html");
712
713  }
714
715
716  var getProduct = function(code) {
717
718    var data = {
719      'action': 'getProduct',
720      'code': code,
721      'facility_id': $('#facility_id').val()
722    };
723
724    //jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status){ make_page(response, status); }, "html");
725
726
727    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
728      jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response);
729    }, "html");
730    jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html("");
731
732
733  }
734
735  var getTree = function(code) {
736
737    var data = {
738      'action': 'getTree',
739      'code': code,
740      'facility_id': $('#facility_id').val(),
741      'name': $("#obit_full_name").val()
742    };
743
744    if (jQuery('#florist-one-flower-delivery-view-modal').hasClass('show') && !jQuery('#fws-trees-container').is(':visible')) {
745      jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
746        jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response);
747        jQuery('#florist-one-flower-delivery-view-modal').find('#plant-a-tree-add-to-cart1').removeAttr('data-bs-toggle');
748      }, "html");
749
750    } else {
751
752
753      if (jQuery('#florist-one-flower-delivery-view-modal').hasClass('show')) {
754        $('#florist-one-flower-delivery-view-modal').modal('hide');
755      }
756
757      jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
758        make_page(response, status);
759      }, "html");
760    }
761
762    //jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status){ jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response); }, "html");
763    //jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html("");
764
765  }
766
767  var addToCart = function(code, num) {
768
769    var data = {
770      'action': 'addToCart',
771      'code': code,
772      'num': num
773    };
774
775    //jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status){ make_page(response, status); }, "html");
776
777    if (jQuery('#florist-one-flower-delivery-view-modal').hasClass('show')) {
778      jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
779        jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response);
780      }, "html");
781    } else {
782      jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
783        jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response);
784      }, "html");
785    }
786
787
788
789  }
790
791  var removeFromCart = function(code) {
792
793    var data = {
794      'action': 'removeFromCart',
795      'code': code
796    };
797
798    //jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status){ make_page(response, status); }, "html");
799    if (jQuery('#florist-one-flower-delivery-view-modal').hasClass('show')) {
800      jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
801        jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response);
802      }, "html");
803    } else {
804      //jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status){ make_page(response, status); }, "html");
805    }
806
807  }
808
809  var getCart = function(code) {
810
811    var data = {
812      'action': 'getCart',
813      'code': code
814    };
815
816    //jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status){ make_page(response, status); }, "html");
817    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
818      jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html(response);
819    }, "html");
820    jQuery('#florist-one-flower-delivery-view-modal').find('.modal-body').html("");
821
822  }
823
824  var showCustomerService = function(code) {
825
826    var data = {
827      'action': 'getCustomerService'
828    };
829
830    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
831      make_page(response, status);
832    }, "html");
833
834  }
835
836  var placeOrder = function(formdata, flowers, total, token) {
837
838    var data = {
839      'action': 'placeOrder',
840      'formdata': formdata,
841      'flowers': flowers,
842      'ordertotal': total,
843      'token': token
844    };
845
846    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
847
848      // if return is json there are validation errors
849      if (isJSON(response)) {
850        var errorList = JSON.parse(response);
851        $(".floristone-checkout-errors").remove();
852        var summary = "<p>There are some issues with your order:</p>";
853        summary += "<ul>";
854        $.each(errorList, function() {
855          summary += "<li>" + this + "</li>";
856        });
857        summary += "</ul>";
858        $(".checkout-form-continue-next-step").before('<div class="my-2 alert alert-danger floristone-checkout-errors">' + summary + '</div>');
859      }
860
861      // if return is html, it is the thank you page, just display it
862      else {
863        make_page(response, status);
864      }
865
866    });
867
868  };
869
870  var isJSON = function(something) {
871    if (typeof something != 'string')
872      something = JSON.stringify(something);
873
874    try {
875      JSON.parse(something);
876      return true;
877    } catch (e) {
878      return false;
879    }
880  }
881
882  var createPaymentLink = function() {
883
884    var data = {
885      'action': 'createPaymentLink'
886    };
887
888    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
889      console.log(response);
890      if (typeof response["PAYMENT_LINK"] !== "undefined") {
891        window.location.href = response["PAYMENT_LINK"];
892      }
893    }, "json");
894
895  };
896
897  var checkout = function(page, formdata, obituary, validated) {
898
899    var data = {
900      'action': 'checkout',
901      'page': page,
902      'formdata': formdata,
903      'obituary': ($('#fhws-main-obit').is(':visible')) ? 1 : 0,
904      'validated': validated
905    };
906
907
908    jQuery.post(ajaxurl + "?_r=" + Math.random(), data, function(response, status) {
909
910
911      $('#florist-one-flower-delivery-view-modal').modal('hide');
912      make_page(response, status, page);
913      jQuery('#florist-one-flower-delivery-purchase-recognition-label').text(jQuery("#f1_purchase_recognition").val());
914    }, "html");
915
916    if (jQuery('#client_type').val() == 5 || $("#client_type").val() == 7) {
917
918      jQuery("#checkout-tree-button").remove();
919      jQuery('.florist-one-flower-delivery').before('<a href="#" id="checkout-tree-button" class="btn-fws mb-3 btn-dark florist-one-flower-delivery-menu-plant-a-tree-link active" data-category="pt" data-bs-toggle="collapse" data-bs-target=".navbar-collapse.show" >Back to Plant Trees</a>');
920
921    }
922  }
923
924  var getCheckout = function() {
925
926    var dataCheckout = {
927      'action': 'setFlowerSessionData',
928      'name': $("#florist-one-flower-delivery-recipient-name").val(),
929      'tree-name-of-loved-one': $("#florist-one-flower-delivery-tree-certificate-name-of-loved-one").val(),
930      'institution': $("#florist-one-flower-delivery-recipient-institution").val(),
931      'address1': $("#florist-one-flower-delivery-recipient-address-1").val(),
932      'address2': $("#florist-one-flower-delivery-recipient-address-2").val(),
933      'city': $("#florist-one-flower-delivery-recipient-city").val(),
934      'state': $("#florist-one-flower-delivery-recipient-state").val(),
935      'zip': $("#florist-one-flower-delivery-recipient-postal-code").val(),
936      'country': $("#florist-one-flower-delivery-recipient-country").val(),
937      'phone': $("#florist-one-flower-delivery-recipient-phone").val(),
938      'facility_id': $("#florist-one-flower-delivery-facility-id").val(),
939      'obit_id': $("#obit_id").val(),
940      'random': Math.random()
941    };
942
943    var localStorageData = JSON.parse(window.localStorage.getItem('chekoutInfo'));
944    if (localStorageData != null) {
945
946      jQuery.each(localStorageData, function(key, value) {
947
948        dataCheckout[key] = value;
949
950      });
951
952    }
953
954    var data = {
955      'action': 'checkout',
956      'page': 4,
957      'formdata': jQuery.post(ajaxurl + "?_r=" + Math.random(), dataCheckout),
958      'obituary': ($('#fhws-main-obit').is(':visible')) ? 1 : 0,
959      'validated': null,
960      'random': Math.random()
961    };
962    History.pushState(data, "", "");
963
964  }
965
966  var make_page = function(response, status, page) {
967
968    $(".florist-one-flower-delivery").html(response);
969
970    if (page !== undefined) {
971      initCheckoutFormValidation();
972      showTreeFields();
973    }
974
975  }
976
977  var scroll_to_top = function() {
978
979    window.scrollTo(0, $('.florist-one-flower-delivery-menu').offset().top - 60);
980
981  }
982
983  var initCheckoutFormValidation = function() {
984
985    var submitted;
986    $(document).ready(function() {
987      var $form = $(".checkout-form");
988      $form.validate({
989        rules: {
990          "florist-one-flower-delivery-delivery-date": {
991            required: true
992          },
993          "florist-one-flower-delivery-tree-certificate": {
994            required: true
995          },
996          "florist-one-flower-delivery-tree-certificate-email-behalf-recipient-name": {
997            required: {
998              depends: function() {
999                $(this).val($(this).val().trim());
1000                if ($("#florist-one-flower-delivery-tree-certificate-email-behalf").is(":checked")) {
1001                  return true;
1002                } else {
1003                  return false;
1004                }
1005              }
1006            },
1007            maxlength: 100
1008          },
1009          "florist-one-flower-delivery-tree-certificate-email-behalf-recipient-email": {
1010            required: {
1011              depends: function() {
1012                $(this).val($(this).val().trim());
1013                if ($("#florist-one-flower-delivery-tree-certificate-email-behalf").is(":checked")) {
1014                  return true;
1015                } else {
1016                  return false;
1017                }
1018              }
1019            },
1020            emailVer: true,
1021            maxlength: 100
1022          },
1023          "florist-one-flower-delivery-tree-certificate-email-behalf-message-to-recipient": {
1024            required: {
1025              depends: function() {
1026                $(this).val($(this).val().trim());
1027                return false;
1028              }
1029            },
1030            maxlength: 500
1031          },
1032          "florist-one-flower-delivery-tree-certificate-email-behalf": {
1033            required: {
1034              depends: function() {
1035                $(this).val($(this).val().trim());
1036                if ($("#florist-one-flower-delivery-tree-certificate-email-behalf").is(":checked")) {
1037                  return true;
1038                } else {
1039                  return false;
1040                }
1041              }
1042            }
1043          },
1044          "florist-one-flower-delivery-tree-certificate-name-of-loved-one": {
1045            required: {
1046              depends: function() {
1047                $(this).val($(this).val().trim());
1048                if ($(this).length < 59) {
1049                  $(this).val($(this).val().substring(0, 59));
1050                }
1051                return true;
1052              }
1053            },
1054          },
1055          "florist-one-flower-delivery-tree-certificate-sender-display-name": {
1056            required: {
1057              depends: function() {
1058                $(this).val($(this).val().trim());
1059                if ($(this).length < 59) {
1060                  $(this).val($(this).val().substring(0, 59));
1061                }
1062                return true;
1063              }
1064            },
1065          },
1066          "florist-one-flower-delivery-special-card-message": {
1067            required: {
1068              depends: function() {
1069                $(this).val($(this).val().trim());
1070                return true;
1071              }
1072            },
1073            maxlength: 200
1074          },
1075          "florist-one-flower-delivery-special-special-instructions": {
1076            required: {
1077              depends: function() {
1078                $(this).val($(this).val().trim());
1079                return false;
1080              }
1081            },
1082            maxlength: 100
1083          },
1084          "florist-one-flower-delivery-recipient-name": {
1085            required: {
1086              depends: function() {
1087                $(this).val($(this).val().trim());
1088                return true;
1089              }
1090            },
1091            maxlength: 100
1092          },
1093          "florist-one-flower-delivery-recipient-institution": {
1094            required: {
1095              depends: function() {
1096                $(this).val($(this).val().trim());
1097                return false;
1098              }
1099            },
1100            maxlength: 100
1101          },
1102          "florist-one-flower-delivery-recipient-address-1": {
1103            required: {
1104              depends: function() {
1105                $(this).val($(this).val().trim());
1106                return true;
1107              }
1108            },
1109            maxlength: 100
1110          },
1111          "florist-one-flower-delivery-recipient-address-2": {
1112            required: {
1113              depends: function() {
1114                $(this).val($(this).val().trim());
1115                return false;
1116              }
1117            },
1118            maxlength: 100
1119          },
1120          "florist-one-flower-delivery-recipient-city": {
1121            required: {
1122              depends: function() {
1123                $(this).val($(this).val().trim());
1124                return true;
1125              }
1126            },
1127            maxlength: 100
1128          },
1129          "florist-one-flower-delivery-recipient-state": {
1130            required: true,
1131            maxlength: 2
1132          },
1133          "florist-one-flower-delivery-recipient-country": {
1134            required: true,
1135            maxlength: 2
1136          },
1137          "florist-one-flower-delivery-recipient-postal-code": {
1138            required: {
1139              depends: function() {
1140                $(this).val($(this).val().trim().toUpperCase());
1141                return true;
1142              }
1143            },
1144            maxlength: 7,
1145            recipientZip: true
1146          },
1147          "florist-one-flower-delivery-recipient-phone": {
1148            required: {
1149              depends: function() {
1150                $(this).val($(this).val().trim());
1151                return true;
1152              }
1153            },
1154            maxlength: 20,
1155            phoneNumber: true
1156          },
1157          "florist-one-flower-delivery-customer-name": {
1158            required: {
1159              depends: function() {
1160                $(this).val($(this).val().trim());
1161                return true;
1162              }
1163            },
1164            maxlength: 100
1165          },
1166          "florist-one-flower-delivery-customer-address-1": {
1167            required: {
1168              depends: function() {
1169                $(this).val($(this).val().trim());
1170                return true;
1171              }
1172            },
1173            maxlength: 100
1174          },
1175          "florist-one-flower-delivery-customer-address-2": {
1176            rrequired: {
1177              depends: function() {
1178                $(this).val($(this).val().trim());
1179                return false;
1180              }
1181            },
1182            maxlength: 100
1183          },
1184          "florist-one-flower-delivery-customer-city": {
1185            required: {
1186              depends: function() {
1187                $(this).val($(this).val().trim());
1188                return true;
1189              }
1190            },
1191            maxlength: 100
1192          },
1193          "florist-one-flower-delivery-customer-state": {
1194            required: true,
1195            maxlength: 2
1196          },
1197          "florist-one-flower-delivery-customer-country": {
1198            required: true,
1199            maxlength: 2
1200          },
1201          "florist-one-flower-delivery-customer-phone": {
1202            required: {
1203              depends: function() {
1204                $(this).val($(this).val().trim());
1205                return true;
1206              }
1207            },
1208            maxlength: 20,
1209            phoneNumber: true
1210          },
1211          "florist-one-flower-delivery-customer-email": {
1212            required: {
1213              depends: function() {
1214                $(this).val($(this).val().trim());
1215                return true;
1216              }
1217            },
1218            maxlength: 100,
1219            emailVer: true
1220          },
1221          "florist-one-flower-delivery-customer-postal-code": {
1222            required: {
1223              depends: function() {
1224
1225                var $cVal = $("#florist-one-flower-delivery-customer-country").val();
1226
1227                if ($cVal == "CA" || $cVal == "US") {
1228                  $(this).val($(this).val().trim().toUpperCase());
1229                  return true;
1230                } else {
1231                  $(this).val($(this).val().trim());
1232                  return false;
1233                }
1234
1235              }
1236            },
1237            maxlength: 15,
1238            customerZip: true
1239          },
1240          "florist-one-flower-delivery-payment-credit-card-number": {
1241            required: true,
1242            maxlength: 16,
1243            creditCardNumber: true
1244          },
1245          "florist-one-flower-delivery-payment-expiration-month": {
1246            required: true,
1247            maxlength: 2,
1248            CCExp: {
1249              month: '#florist-one-flower-delivery-payment-expiration-month',
1250              year: '#florist-one-flower-delivery-payment-expiration-year'
1251            }
1252          },
1253          "florist-one-flower-delivery-payment-security-code": {
1254            required: true,
1255            maxlength: 4
1256          },
1257          "": {
1258
1259          }
1260        },
1261        onkeyup: false,
1262        onfocusout: function(element) {
1263          if ($(element).hasClass('ofo')) {
1264            this.element(element);
1265          }
1266        },
1267        onchange: false,
1268        focusInvalid: false,
1269        errorClass: "alert alert-danger w-100",
1270        invalidHandler: function(event, validator) {
1271          submitted = true;
1272        },
1273        showErrors: function(errorMap, errorList) {
1274
1275          if (submitted) {
1276            $(".floristone-checkout-errors").remove();
1277            var summary = "Please ensure you have entered the following: <br/><br/>";
1278            $.each(errorList, function() {
1279
1280              var inputName = $("label[for='" + this.element.id + "']").text();
1281              var inputName = inputName.split('*');
1282              var sectionLabel = "";
1283
1284              var section = this.element.id.split("-")
1285              if (section.indexOf("customer") !== -1) {
1286
1287                sectionLabel = "Bill To ";
1288
1289              }
1290              if (section.indexOf("recipient") !== -1) {
1291
1292                sectionLabel = "Deliver To ";
1293
1294              }
1295
1296              summary += sectionLabel + inputName[0] + "<br/>";
1297
1298            });
1299            $(".checkout-form-continue-next-step").before('<div class="my-2 alert alert-danger floristone-checkout-errors">' + summary + '</div>');
1300            submitted = false;
1301          }
1302
1303
1304          this.defaultShowErrors();
1305        },
1306        submitHandler: function() {
1307
1308          // tokenized payment
1309          if ($("#florist-one-flower-delivery-payment-credit-card-number").length) {
1310            var data = $form.serializeArray();
1311            sendPaymentDataToAnet(data);
1312          }
1313
1314          // hosted forms (authnet or stripe)
1315          else {
1316            var checkValue = (jQuery("#florist-one-flower-delivery-purchase-recognition-check").prop('checked')) ? "on" : "";
1317            var data = $form.serializeArray().concat({
1318              name: "florist-one-flower-delivery-purchase-recognition-check",
1319              value: checkValue
1320            });
1321
1322            var checkValue2 = (jQuery("#florist-one-flower-delivery-allow-substitutions-check").prop('checked')) ? "on" : "";
1323            data = $form.serializeArray().concat({
1324              name: "florist-one-flower-delivery-allow-substitutions-check",
1325              value: checkValue2
1326            });
1327
1328            checkout(4, data, ($('#fhws-main-obit').is(':visible')) ? 1 : 0, true);
1329
1330            // switch payment module based on client country
1331            if ($("#international_tree").length) {
1332              // international tree
1333              createPaymentLink();
1334            } else {
1335              // us or ca client country
1336              $(document).ajaxStop(function() {
1337                $('#fws-checkout-form-payment').trigger("click");
1338              });
1339            }
1340          }
1341
1342        },
1343        errorPlacement: function(error, element) {
1344          if (element.is(":radio")) {
1345            if (element.name == 'florist-one-flower-delivery-tree-certificate') {
1346              error.insertBefore(element.parents('#florist-one-flower-delivery-tree-certificate-info'));
1347            } else {
1348              error.insertBefore(".email_yes_no_error");
1349            }
1350          } else { // This is the default behavior
1351            error.insertAfter(element);
1352          }
1353        },
1354        messages: {
1355          "florist-one-flower-delivery-tree-certificate": {
1356            required: "Please select a delivery method."
1357          },
1358          "florist-one-flower-delivery-tree-certificate-email-behalf": {
1359            required: "Please select if you have the recipient's email address or not."
1360          }
1361        },
1362      });
1363    });
1364  }
1365
1366  var getUrlParameter = function getUrlParameter(sParam) {
1367    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
1368      sURLVariables = sPageURL.split('&'),
1369      sParameterName,
1370      i;
1371
1372    for (i = 0; i < sURLVariables.length; i++) {
1373      sParameterName = sURLVariables[i].split('=');
1374
1375      if (sParameterName[0] === sParam) {
1376        return sParameterName[1] === undefined ? true : sParameterName[1];
1377      }
1378    }
1379  };
1380
1381  $(document).on("change", "[name=florist-one-flower-delivery-tree-certificate]", function() {
1382    showTreeFields();
1383  });
1384
1385  $(document).on("change", "[name=florist-one-flower-delivery-tree-certificate-email-behalf]", function() {
1386    showTreeFields();
1387  });
1388
1389  var showTreeFields = function() {
1390
1391    var allow_trees_to_funeral_home = $("[name=florist-one-flower-delivery-tree-certificate-email-behalf-allow-trees-to-funeral-home]").val();
1392
1393    $("span.obit_full_name").text($("input#obit_full_name").val());
1394
1395    if (allow_trees_to_funeral_home == 1) {
1396
1397      if ($("[name=florist-one-flower-delivery-tree-certificate]:checked").val() == 'Cert-email-behalf'){
1398        $(".email-certificate-fields").show();
1399        // new functionality and new radio boxes
1400        $(".tree-recipient-has-email").show();
1401        if ($("[name=florist-one-flower-delivery-tree-certificate-email-behalf]:checked").val() == '0') {
1402          $(".tree-recipient-name").show();
1403          $(".tree-recipient-email").show();
1404          $(".tree-recipient-message").show();
1405          $(".tree-recipient-fh-message").hide();
1406        }
1407        else if ($("[name=florist-one-flower-delivery-tree-certificate-email-behalf]:checked").val() == '1') {
1408          $(".tree-recipient-name").show();
1409          $(".tree-recipient-email").hide();
1410          $(".tree-recipient-message").show();
1411          $(".tree-recipient-fh-message").show();
1412        }
1413        else {
1414          $(".tree-recipient-name").hide();
1415          $(".tree-recipient-email").hide();
1416          $(".tree-recipient-message").hide();
1417          $(".tree-recipient-fh-message").hide();
1418        }
1419      }
1420      else {
1421        $(".tree-recipient-has-email").hide();
1422        $(".tree-recipient-name").hide();
1423        $(".tree-recipient-email").hide();
1424        $(".tree-recipient-message").hide();
1425        $(".tree-recipient-fh-message").hide();
1426      }
1427    }
1428    else {
1429      // legacy functionality
1430      // allow_trees_to_funeral_home = 0
1431      if ($("[name=florist-one-flower-delivery-tree-certificate]:checked").val() == 'Cert-email-behalf') {
1432        $(".email-certificate-fields").show();
1433      }
1434      else{
1435        $(".email-certificate-fields").hide();
1436      }
1437    }
1438
1439  }
1440
1441  function sendPaymentDataToAnet(data) {
1442
1443    console.log(data);
1444
1445    var authData = {
1446      // plug in dynamic authorizenet credentials from getauthorizenetkey
1447      clientKey: $("#florist-one-flower-delivery-payment-client-key").val(),
1448      apiLoginID: $("#florist-one-flower-delivery-payment-username").val()
1449    };
1450
1451    var cardData = {};
1452    cardData.cardNumber = $("#florist-one-flower-delivery-payment-credit-card-number").val();
1453    cardData.month = $("#florist-one-flower-delivery-payment-expiration-month").val();
1454    cardData.year = $("#florist-one-flower-delivery-payment-expiration-year").val();
1455    cardData.cardCode = $("#florist-one-flower-delivery-payment-security-code").val();
1456
1457    // remove card info from form scope so not stored in browser
1458    data = $.grep(data, function(value) {
1459      return value.name != "florist-one-flower-delivery-payment-credit-card-number" &&
1460        value.name != "florist-one-flower-delivery-payment-expiration-month" &&
1461        value.name != "florist-one-flower-delivery-payment-expiration-year" &&
1462        value.name != "florist-one-flower-delivery-payment-security-code" &&
1463        value.name != "florist-one-flower-delivery-payment-username" &&
1464        value.name != "florist-one-flower-delivery-payment-client-key";
1465    });
1466    console.log(data);
1467
1468    var secureData = {};
1469    secureData.authData = authData;
1470    secureData.cardData = cardData;
1471
1472    Accept.dispatchData(secureData, function(response) {
1473
1474      if (response.messages.resultCode == 'Ok') {
1475        $("#florist-one-flower-delivery-payment-token").val(response.opaqueData.dataValue);
1476        var flowers = $("#florist-one-flower-delivery-product-product-type").val() != 'TREES';
1477        placeOrder(data, flowers, $("#florist-one-flower-delivery-payment-order-total").val(), $("#florist-one-flower-delivery-payment-token").val());
1478      } else {
1479        var errorList = response.messages.message;
1480        $(".floristone-checkout-errors").remove();
1481        var summary = "<p>Please check your credit card information</p>";
1482        summary += "<ul>";
1483        $.each(errorList, function() {
1484          summary += "<li>" + this.text + "</li>";
1485        });
1486        summary += "</ul>";
1487        $(".checkout-form-continue-next-step").before('<div class="my-2 alert alert-danger floristone-checkout-errors">' + summary + '</div>');
1488      }
1489
1490    });
1491
1492  }
1493
1494
1495  $(document)
1496    .ready(function() {
1497
1498      jQuery.validator.addMethod("phoneNumber", function(phone_number, element) {
1499        phone_number = phone_number.replace(/\s+/g, "");
1500        return this.optional(element) ||
1501          phone_number.match(/(.*?\d){10}/gm);
1502      }, "Please specify a valid phone number");
1503
1504
1505      jQuery.validator.addMethod("customerZip", function(value, element) {
1506
1507        var $cVal = jQuery('#florist-one-flower-delivery-customer-country').val();
1508        if ($cVal == "CA") {
1509          return this.optional(element) || /(^[A-Za-z]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}\d{1}$)/.test(value);
1510        }
1511        if ($cVal == "US") {
1512          return this.optional(element) || /(^\d{5}$)/.test(value);
1513        }
1514
1515        if ($cVal != "US" && $cVal != "CA") {
1516          return this.optional(element) || /(.*?)/.test(value);
1517        }
1518
1519      }, function() {
1520
1521        var $cVal = jQuery('#florist-one-flower-delivery-customer-country').val();
1522
1523        var msg;
1524        if ($cVal == "CA") {
1525          msg = "Please enter a valid Canadian postal code.";
1526          return msg;
1527        }
1528
1529        if ($cVal == "US") {
1530          msg = "Please enter a valid 5 digit zip code.";
1531          return msg;
1532        }
1533      });
1534
1535      jQuery.validator.addMethod("recipientZip", function(value, element) {
1536        var $cVal = jQuery('#florist-one-flower-delivery-recipient-country').val();
1537        if ($cVal == "CA") {
1538          return this.optional(element) || /(^[A-Za-z]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}\d{1}$)/.test(value);
1539        }
1540        if ($cVal == "US") {
1541          return this.optional(element) || /(^\d{5}$)/.test(value);
1542        }
1543      }, function() {
1544
1545        var $cVal = jQuery('#florist-one-flower-delivery-recipient-country').val();
1546        var msg;
1547        if ($cVal == "CA") {
1548          msg = "Please enter a valid Canadian postal code.";
1549        }
1550        if ($cVal == "US") {
1551          msg = "Please enter a valid 5 digit zip code.";
1552        }
1553
1554        return msg;
1555
1556      });
1557
1558      jQuery.validator.addMethod("emailVer", function(value, element) {
1559        return this.optional(element) || /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(value)
1560      }, "Please enter a valid email address");
1561
1562      jQuery.validator.addMethod("CCExp", function(value, element, params) {
1563        var minMonth = new Date().getMonth() + 1;
1564        var minYear = new Date().getFullYear();
1565        minYear = (minYear + '').substring(2, 4);
1566        var month = parseInt($(params.month).val(), 10);
1567        var year = parseInt($(params.year).val(), 10);
1568        return this.optional(element) || (year > minYear || (year == minYear && month >= minMonth));
1569      }, "Your Credit Card Expiration date is invalid.");
1570
1571      jQuery.validator.addMethod("CCCVV2", function(value, element, params) {
1572        var cc_type = $(params.cc_type).val();
1573        var cc_cvv2 = $(params.cc_cvv2).val();
1574        return this.optional(element) || ((cc_type == 'AX' && cc_cvv2.length == 4) || (cc_type != 'AX' && cc_cvv2.length == 3));
1575      }, "Your CVV2 is invalid.");
1576
1577      jQuery.validator.addMethod("creditCardNumber", function(value, element) {
1578        var strippedValue = value.replace(/[^0-9]+/g, '');
1579        return this.optional(element) || /^.{15,16}$/.test(strippedValue)
1580      }, "Please enter a valid credit card number.");
1581
1582    })
1583    .ajaxStart(function() {
1584
1585      jQuery('#florist-one-flower-delivery-loader').removeClass("d-none");
1586
1587    })
1588
1589    .ajaxStop(function() {
1590
1591      jQuery('#florist-one-flower-delivery-loader').addClass("d-none");
1592
1593
1594    });
1595
1596})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.