Merged in feature/from-pantheon (pull request #16)

code from pantheon

* code from pantheon
This commit is contained in:
Tony Volpe
2024-01-10 17:03:02 +00:00
parent 054b4fffc9
commit 4eb982d7a8
16492 changed files with 3475854 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,84 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// This sample uses the Places Autocomplete widget to:
// 1. Help the user select a place
// 2. Retrieve the address components associated with that place
// 3. Populate the form fields with those address components.
// This sample requires the Places library, Maps JavaScript API.
// Include the libraries=places parameter when you first load the API.
// For example: <script
// src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
let autocomplete;
let address1Field;
let address2Field;
let postalField;
function initAutocomplete() {
address1Field = document.querySelector("#address1_shipping");
address2Field = document.querySelector("#address2");
postalField = document.querySelector("#postcode");
// Create the autocomplete object, restricting the search predictions to
// addresses in the US and Canada.
autocomplete = new google.maps.places.Autocomplete(address1Field, {
componentRestrictions: { country: ["us", "ca"] },
fields: ["address_components", "geometry"],
types: ["address"],
});
address1Field.focus();
// When the user selects an address from the drop-down, populate the
// address fields in the form.
autocomplete.addListener("place_changed", fillInAddress);
}
function fillInAddress() {
// Get the place details from the autocomplete object.
const place = autocomplete.getPlace();
let address1 = "";
let postcode = "";
// Get each component of the address from the place details,
// and then fill-in the corresponding field on the form.
// place.address_components are google.maps.GeocoderAddressComponent objects
// which are documented at http://goo.gle/3l5i5Mr
for (const component of place.address_components) {
// @ts-ignore remove once typings fixed
const componentType = component.types[0];
switch (componentType) {
case "street_number": {
address1 = `${component.long_name} ${address1}`;
break;
}
case "route": {
address1 += component.short_name;
break;
}
case "postal_code": {
postcode = `${component.long_name}${postcode}`;
break;
}
case "locality":
document.querySelector("#locality").value = component.long_name;
break;
case "administrative_area_level_1": {
document.querySelector("#state_shipping").value = component.short_name;
break;
}
}
}
address1Field.value = address1;
postalField.value = postcode;
// After filling the form with address components from the Autocomplete
// prediction, set cursor focus on the second address line to encourage
// entry of subpremise information such as apartment, unit, or floor number.
address2Field.focus();
}
window.initAutocomplete = initAutocomplete;

View File

@@ -0,0 +1,196 @@
/**
* Created by linus on 05/02/16.
*/
window.plan=0;
jQuery(function(){
function setCookieAjax_1(plan, plan_id){
//ajax
var data_plan = {
'action': 'iper_set_cookie_plan',
'plan': plan,
'plan_id': plan_id
};
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
jQuery.post(ajax_object.ajax_url, data_plan, function(response) {});
}
function iperFPSetProductPlanCookie(plan,planID,product,productID, discount_product, promotion_id){
if(!plan || !planID || !product || !productID){ return ; }
var arrPlan=plan.split(',');
if(arrPlan.length<2){ return ; }
var planWPID=arrPlan[0];
var planPrice=arrPlan[1];
var data = {
plan_wp_id: planWPID,
plan_price: planPrice,
plan_id: planID,
product_wp_id: product,
product_id: productID,
discount: discount_product,
promotion_id: promotion_id
};
jQuery.ajax({
type: 'POST',
url: ajax_object.ajax_url,
data: {data: data, action: 'iper_set_cookie_product_plan'},
async:false,
success: function(response) {
response=jQuery.parseJSON(response);
console.log('Added product plan to cart: ', data);
}
});
}
function iperFPSetProductPlanUpsellCookie(upsell, targetURL,link,productID,planID,upsellID,promotion_id){
var arrupsell=upsell.split(',');
if(arrupsell.length<2){ return ; }
var upsellWPID=arrupsell[0];
var upsellPrice=arrupsell[1];
var data = {
upsell: upsellWPID,
upsellPrice: upsellPrice,
upsellID:upsellID,
product: productID,
plan: planID,
promotion_ID: promotion_id
};
jQuery.ajax({
type: 'POST',
url: ajax_object.ajax_url,
data: {data: data, action: 'iper_set_cookie_product_plan_upsell'},
async:false,
success: function(response) {
if(targetURL!=null && targetURL=="" && link!=null) {
window.location=link;
}
console.log('Added upsell to cart: ', data);
}
});
}
jQuery(".btIperSelectPlan").click(function(){
var plan=jQuery(this).attr("data-plan");
var planID=jQuery(this).attr("data-plan-id");
var product=jQuery(this).attr("data-product");
var productID=jQuery(this).attr("data-product-id");
var product_discount=jQuery(this).attr("data-discount");
var promotion_id=jQuery(this).attr("data-promotion-id");
window.plan=parseInt(planID);
iperFPSetProductPlanCookie(plan,planID,product,productID, product_discount, promotion_id);
//setCookieAjax_1(jQuery(this).attr("data-plan"), jQuery(this).attr("data-plan-id"));
});
function setCookieAjax_2(product, product_fk_id, link){
//ajax
var data_product = {
'action': 'iper_set_cookie_product',
'product': product,
'product_fk_id': product_fk_id
};
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
jQuery.post(ajax_object.ajax_url, data_product, function(response) {
if(link!=null){
window.location=link;
}
});
}
/*jQuery(".iperModalProduct").click(function(e){
e.preventDefault();
e.stopPropagation();
setCookieAjax_2(jQuery(this).data("product"), jQuery(this).data("base-product-id"),jQuery(this).attr('href'));
});
jQuery('.product-id').load(function(){
setCookieAjax_2(jQuery('.product-id').data("id"));
});*/
function setCookieAjax_3(upsell, targetURL,link){
//ajax
var data_upsell = {
'action': 'iper_set_cookie_upsell',
'upsell': upsell
};
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
jQuery.post(ajax_object.ajax_url, data_upsell, function(response) {
if(targetURL!=null && targetURL=="" && link!=null){
window.location=link;
}
});
}
/*jQuery(".plan_select_final").click(function(e){
setCookieAjax_3();
});*/
jQuery(".iperModalUpsell").click(function(e){
var targetURL=jQuery(this).attr("data-target");
var link=jQuery(this).attr("href");
if(targetURL==""){
e.preventDefault();
e.stopPropagation();
}
var product=jQuery(this).data("product-id");
var upsellID=jQuery(this).data("upsell-id");
var upsell_data_promotion_id = jQuery(this).data("promotion-id");
if(jQuery(this).attr('data-block')!='block_it'){
iperFPSetProductPlanUpsellCookie(jQuery(this).data("upsell"),targetURL,link,product,window.plan,upsellID, upsell_data_promotion_id);}
jQuery(this).attr('data-block', 'block_it');
//setCookieAjax_3(jQuery(this).data("upsell"),targetURL,link);
});
});
function removeAccessoryFromCart(groupID,accID,product){
var data = {
action: 'iper_remove_accessory_to_cart',
data:{
groupID: groupID,
accID: accID,
product: product
}
};
$.post(ajax_object.ajax_url, data, function(response) {
var res= $.parseJSON(response);
if(res.status==1){
for(var i in res.cart){
var single=res.cart[i];
iperRenderCartJS(single);
}
$("div[data-accGroupID="+groupID+"] div[data-accID="+accID+"]").removeClass('active');
$("div[data-accGroupID="+groupID+"] div[data-accID="+accID+"] a.btn").html("Select");
}
});
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,521 @@
(function($) {
if(window.cart){
renderCart(window.cart);
}
/*********************************************************************************************************/
/* -------------------------------------- Sticky navigation ------------------------------------------ */
/*********************************************************************************************************/
/*$("#preview-order-payment").sticky({
topSpacing: 0,
className: 'sticky',
responsiveWidth: true
});*/
/*********************************************************************************************************/
/* -------------------------------------- FORM PAYMENT ------------------------------------------ */
/*********************************************************************************************************/
//$('#form-payment').validator();
//billing same as shipping
$('#billing_sameas_shipping').on('click', function(){
if ($(this).is(':checked')) {
var first_name = $('#firstName_shipping').val(),
last_name = $('#lastName_shipping').val(),
country = $('#country_shipping').val(),
addr1 = $('#address1_shipping').val(),
addr2 = $('#address2').val(),
city = $('#locality').val(),
state = $('#state_shipping').val(),
zip = $('#postcode').val(),
email = $('#email_shipping').val(),
tel = $('#phone_shipping').val();
$('#firstName_billing').val(first_name);
$('#lastName_billing').val(last_name);
$('#country_billing').val(country);
$('#address1_billing').val(addr1);
$('#address2_billing').val(addr2);
$('#city_billing').val(city);
$('#state_billing').val(state);
$('#zip_billing').val(zip);
$('#email_billing').val(email);
$('#phone_billing').val(tel);
jQuery('#state_billing').html("");
jQuery('#state_shipping option').each(function(){
var opt=jQuery(this).clone();
jQuery('#state_billing').append(opt);
});
jQuery('#country_billing').selectpicker('refresh');
jQuery('#state_billing').selectpicker('refresh');
$('#country_billing').selectpicker('val',country);
$('#state_billing').selectpicker('val',state);
}else{
/*
$('#firstName_billing').val('');
$('#lastName_billing').val('');
$('#country_billing').val('');
$('#address1_billing').val('');
$('#address2_billing').val('');
$('#city_billing').val('');
$('#state_billing').val('');
$('#zip_billing').val('');
$('#email_billing').val('');
$('#phone_billing').val('');
$('.bootstrap-select button[data-id="country_billing"] .filter-option').text('Country*');
$('.bootstrap-select button[data-id="state_billing"] .filter-option').text('State*');*/
}
});
//change price
$('input[name="shippingType"]').on('change', function(){
$('.shipping-tax .shipping .price').text($(this).attr('data-price'));
});
$(document).on('submit','form#form-payment',function(){
if ($("#payment_terms").prop('checked') == false ) {
$("#payment_terms").closest('.form-group').addClass('has-error');
return false;
}
});
function removeClassActive(el){
if($(el).hasClass('active')){
$(el).removeClass('active');
}
}
/*$('.card-container').on('click', function(){
removeClassActive($('.card-container'));
$(this).toggleClass('active');
$price = $('.price', this).html();
$wp_id = $('.post_id' , this).html();
$('.plan_select_final').attr('data-plan', $wp_id+','+$price);
$plan_id = $('.plan_id' , this).html();
$('.plan_select_final').attr('data-plan-id', $plan_id);
$upsell_id = $('.upsell_id' , this).html();
$('.plan_select_final').attr('data-target', '#modalProduct'+$upsell_id);
});
$('.plan_select_final').on('click', function(e){
if(!$(this).attr('data-plan-id')){
e.preventDefault();
$(this).attr('data-target', '');
$('.plan_check_error').html('Select a Rate Plan');
} else {
$('.plan_check_error').html('');
}
});*/
$('.list-product').load(function(){
if($('.card-container').hasClass('active')) {
$id = $('.post_id', this).html();
$('.plan_select_final').attr('data-plan', $id);
}
});
$('.card-select').on('click', function(){
var permanent = $('.list-select').attr('data-permanent');
if(permanent=='0'){//verifico se gli oggetti sono permanenti o meno
if ($(this).hasClass('active')) {
$(this).toggleClass('active').find('.btn').html('Select');
removeToCart(this);
} else {
var parent = $(this).closest("div.row");
var singleSelection = parent.attr('data-singleSelection');
if (singleSelection == 1) {
var elToRemove = $(".card-select.active", parent);
if (elToRemove) {
removeToCart(elToRemove);
}
$(".card-select.active", parent).removeClass('active');
}
$(this).toggleClass('active').find('.btn').html('Selected');
var el = this;
addToCart(el);
}
}
});
function addToCart(el){
showLoader();
var accessories=$(el).data('json');
var product=$(el).data('product');
var accGroup=$(el).data('accgroup');
var data = {
action: 'iper_add_product_plan_accessories_to_cart',
data:{
accessories: accessories,
product: product,
accGroup: accGroup
}
};
$.post(ajax_object.ajax_url, data, function(response) {
var res= $.parseJSON(response);
if(res.status==1){
for(var i in res.cart){
var single=res.cart[i];
iperRenderCartJS(single);
}
}
hideLoader();
});
}
function removeToCart(el){
var accessories=$(el).data('json');
var product=$(el).data('product');
var accGroup=$(el).data('accgroup');
if(!product || product=="null") return ;
var data = {
action: 'iper_remove_product_plan_accessories_to_cart',
data:{
accessories: accessories,
product: product,
accGroup: accGroup
}
};
showLoader();
$.post(ajax_object.ajax_url, data, function(response) {
var res= $.parseJSON(response);
if(res.status==1){
for(var i in res.cart){
var single=res.cart[i];
iperRenderCartJS(single);
}
}
hideLoader();
});
}
function renderCart(cart){
var wrapper=$("#preview-select-payment .order-detail");
//set tax
/*$(".shipping-tax li.tax .order-text-space .price",wrapper).html(cart.tax);*/
//set products
$("ul.productListCart",wrapper).html("");
if(cart.products.length){
for(var i in cart.products){
var product=cart.products[i];
$("ul.productListCart",wrapper).append("<li><strong>"+product.post_title+"</strong><div class='order-text-space'> <span class='price'>Included</span></div><div class='clearfix'></div></li>");
/* $(".total1",wrapper).append("1");*/
}
}
}
/*$( window ).scroll(function() {
if($(window).width()<768) return ;
var btn_order = $( "#place_order" );
var btn_cart_order = $( "#preview-order-payment" );
var footer = $( "#colophon" );
var footer_offset = footer.offset();
var offset = btn_order.offset();
var offset_cart = btn_cart_order.offset();
*//*if(offset_cart.top+btn_cart_order.height() >= offset.top){
$("#preview-order-payment").css("position","absolute");
$("#preview-order-payment").css("top", ""+(offset_cart.top-btn_cart_order.height())+"px");
} else {
$("#preview-order-payment").css("position","fixed").css("top",""+(offset_cart.top)+"px");
}*//*
//controlla con lo scroll del document
var offsetScroll = $(document).scrollTop()+$(window).height();
console.log("scroll "+offsetScroll);
console.log("footer top "+footer_offset.top);
if(offsetScroll >= footer_offset.top){
$("#preview-order-payment").css("position","absolute");
$("#preview-order-payment").css("top", (offset_cart.top)+"px");
}
*//*var bottomOffset=offset.top+btn_order.height();
var bottomOffsetCart=offset_cart.top+btn__cart_order.height()*//*
*//*btn__cart_order.html( "btTop: "+bottomOffset + ", top: " + bottomOffsetCart );*//*
*//*if( bottomOffsetCart >= bottomOffset ){
console.log("HERE");
$("#preview-order-payment").css("position","absolute").css("top",""+(bottomOffset- $("#preview-order-payment").height()-30-293)+"px");
}else{
$("#preview-order-payment").css("position","fixed").css("top","auto")
}*//*
});*/
$('#_a_add_contact').click( function() {
$('.emergency_contact').toggleClass('hide_emergency_contact');
if($('.emergency_contact').hasClass('hide_emergency_contact')){
$('#_a_add_contact').html('+Add Another Emergency Contact');
} else {$('#_a_add_contact').html('+Remove an Emergency Contact');}
});
/*$('#_a_add_contact').click( function() {
$('#_add_contact').append(new_contact);
var u = ' ';
});
var new_contact = [
'<div class="row">',
' <div class="col-xs-12"><label>Secondary Contact</label></div>',
' <div class="col-sm-4">',
' <div class="form-group has-feedback">',
' <div class="form-subtitle2">',
' <input type="text" class="form-control" id="firstName_shipping" placeholder="First Name*" required>',
' <span class="glyphicon form-control-feedback" aria-hidden="true"></span>',
' </div>',
' </div>',
' </div>',
' <div class="col-sm-4">',
' <div class="form-subtitle2">',
' <div class="form-group has-feedback">',
' <input type="text" class="form-control" id="lastName_shipping" placeholder="Last Name*" required>',
' <span class="glyphicon form-control-feedback" aria-hidden="true"></span>',
' </div>',
' </div>',
' </div>',
' <div class="col-sm-4">',
' <div class="form-group">',
' <div class="form-subtitle2">',
' <select id="state_billing_2" class="form-control selectpicker show-tick" data-live-search="true" title="Relationship" required>',
' <option value="">Relationship</option>',
' <option value="Aunt">Aunt</option>',
' <option value="Caretaker">Caretaker</option>',
' <option value="Daughter">Daughter</option>',
' <option value="Doctor">Doctor</option>',
' <option value="Ex-Husband">Ex-Husband</option>',
' <option value="Ex-Wife">Ex-Wife</option>',
' <option value="Father">Father</option>',
' <option value="Friend">Friend</option>',
' <option value="Granddaughter">Granddaughter</option>',
' <option value="Grandfather">Grandfather</option>',
' <option value="Grandmother">Grandmother</option>',
' <option value="Grandparent">Grandparent</option>',
' <option value="Grandson">Grandson</option>',
' <option value="Mother">Mother</option>',
' <option value="Niece">Niece</option>',
' <option value="Neighbor">Neighbor</option>',
' <option value="Nephew">Nephew</option>',
' <option value="Nurse">Nurse</option>',
' <option value="Sibling">Sibling</option>',
' <option value="Son">Son</option>',
' <option value="Uncle">Uncle</option>',
' <option value="Wife">Wife</option>',
' <option value="Other">Other</option>',
' </select>',
' </div>',
' </div>',
' </div>',
' </div>',
' <div class="row">',
' <div class="col-sm-8">',
' <div class="form-group has-feedback">',
' <input type="text" class="form-control" id="firstName_shipping" placeholder="Phone*" required>',
' <span class="glyphicon form-control-feedback" aria-hidden="true"></span>',
' </div>',
' </div>',
' </div>'
].join('');*/
/*var ddl = document.getElementById("cardtype");
if(ddl){
var selectedValue = ddl.options[ddl.selectedIndex].value;
if (selectedValue == "selectcard")
{
alert("Please select a card type");
}
}*/
/*function checkEmail()
{
val = jQuery('#email_shipping').val();
}*/
function validateEmail(email)
{
var re = /\S+@\S+\.\S+/;
return re.test(email);
}
function addLoader() {
$("body").append('<div id="site-loader"><div class="sk-three-bounce"><div class="sk-child sk-bounce1"></div><div class="sk-child sk-bounce2"></div><div class="sk-child sk-bounce3"></div></div></div>');
$("#site-loader").hide();
}
function showLoader(){
$("#site-loader").show();
}
function hideLoader(){
$("#site-loader").hide();
}
addLoader();
/*$('.terms_and_conditions').on('click', function(){
$text = $('#terms_text');
if($text.css('display')=='none'){
$text.css('display','block');} else{
$text.css('display','none');
}
});
$('.close2').on('click', function(){
$('#terms_text').css('display','none');
});*/
function validate_fields(e, id, bool) {
var parent=jQuery(id).closest('.form-group');
var gliphycon=jQuery('.glyphicon', parent);
var errText=jQuery(id).attr("data-error");
gliphycon.removeClass('glyphicon-ok');
if(bool=='false'){
parent.removeClass('has-success');
parent.addClass('has-error');
gliphycon.removeClass('glyphicon-ok');
gliphycon.addClass('glyphicon-remove');
jQuery(".help-block.with-errors",parent).html(errText);
} else if(bool=='true'){
parent.addClass('has-success');
parent.removeClass('has-error');
gliphycon.addClass('glyphicon-ok');
gliphycon.removeClass('glyphicon-remove');
jQuery(".help-block.with-errors",parent).html('');
}
}
/*jQuery('#btncart').onclick(function(){
jQuery('#btncart').attr('href', '');
});*/
/*function check_if_filled(id){
var hidden_input = jQuery(id);
hidden_input.attr('name', Math.floor(Date.now() / 1000));
hidden_input.attr('id', Math.floor(Date.now() / 1000));
return jQuery("#"+hidden_input.attr('id')).val();
}
jQuery('#form-payment').on('submit', function(e){
if(check_if_filled('.you_cant_see_me_input') || check_if_filled('.you_cant_see_me_input')!=''){
jQuery('.spam_blocker').html("<?php $_SESSION['block_active_'] = 'block_active'; echo $_SESSION['block_active_']; ?>");
e.preventDefault();
console.log('block');
} else { jQuery('.spam_blocker').html(""); console.log('block_no');}
});*/
})(jQuery);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
/*! jquery.cookie v1.4.1 | MIT */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});

View File

@@ -0,0 +1,226 @@
// Sticky Plugin v1.0.3 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 02/14/2011
// Date: 07/20/2015
// Website: http://stickyjs.com/
// Description: Makes an element on the page stick on the screen as you scroll
// It will only set the 'top' and 'position' of your element, you
// might need to adjust the width in some cases.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var slice = Array.prototype.slice; // save ref to original slice()
var splice = Array.prototype.splice; // save ref to original slice()
var defaults = {
topSpacing: 0,
bottomSpacing: 0,
className: 'is-sticky',
wrapperClassName: 'sticky-wrapper',
center: false,
getWidthFrom: '',
widthFromWrapper: true, // works only when .getWidthFrom is empty
responsiveWidth: false
},
$window = $(window),
$document = $(document),
sticked = [],
windowHeight = $window.height(),
scroller = function() {
var scrollTop = $window.scrollTop(),
documentHeight = $document.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
for (var i = 0, l = sticked.length; i < l; i++) {
var s = sticked[i],
elementTop = s.stickyWrapper.offset().top,
etse = elementTop - s.topSpacing - extra;
//update height in case of dynamic content
s.stickyWrapper.css('height', s.stickyElement.outerHeight());
if (scrollTop <= etse) {
if (s.currentTop !== null) {
s.stickyElement
.css({
'width': '',
'position': '',
'top': ''
});
s.stickyElement.parent().removeClass(s.className);
s.stickyElement.trigger('sticky-end', [s]);
s.currentTop = null;
}
}
else {
var newTop = documentHeight - s.stickyElement.outerHeight()
- s.topSpacing - s.bottomSpacing - scrollTop - extra;
if (newTop < 0) {
newTop = newTop + s.topSpacing;
} else {
newTop = s.topSpacing;
}
if (s.currentTop !== newTop) {
var newWidth;
if (s.getWidthFrom) {
newWidth = $(s.getWidthFrom).width() || null;
} else if (s.widthFromWrapper) {
newWidth = s.stickyWrapper.width();
}
if (newWidth == null) {
newWidth = s.stickyElement.width();
}
s.stickyElement
.css('width', newWidth)
.css('position', 'fixed')
.css('top', newTop);
s.stickyElement.parent().addClass(s.className);
if (s.currentTop === null) {
s.stickyElement.trigger('sticky-start', [s]);
} else {
// sticky is started but it have to be repositioned
s.stickyElement.trigger('sticky-update', [s]);
}
if (s.currentTop === s.topSpacing && s.currentTop > newTop || s.currentTop === null && newTop < s.topSpacing) {
// just reached bottom || just started to stick but bottom is already reached
s.stickyElement.trigger('sticky-bottom-reached', [s]);
} else if(s.currentTop !== null && newTop === s.topSpacing && s.currentTop < newTop) {
// sticky is started && sticked at topSpacing && overflowing from top just finished
s.stickyElement.trigger('sticky-bottom-unreached', [s]);
}
s.currentTop = newTop;
}
}
}
},
resizer = function() {
windowHeight = $window.height();
for (var i = 0, l = sticked.length; i < l; i++) {
var s = sticked[i];
var newWidth = null;
if (s.getWidthFrom) {
if (s.responsiveWidth) {
newWidth = $(s.getWidthFrom).width();
}
} else if(s.widthFromWrapper) {
newWidth = s.stickyWrapper.width();
}
if (newWidth != null) {
s.stickyElement.css('width', newWidth);
}
}
},
methods = {
init: function(options) {
var o = $.extend({}, defaults, options);
return this.each(function() {
var stickyElement = $(this);
var stickyId = stickyElement.attr('id');
var stickyHeight = stickyElement.outerHeight();
var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName;
var wrapper = $('<div></div>')
.attr('id', wrapperId)
.addClass(o.wrapperClassName);
stickyElement.wrapAll(wrapper);
var stickyWrapper = stickyElement.parent();
if (o.center) {
stickyWrapper.css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
}
if (stickyElement.css("float") === "right") {
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
}
stickyWrapper.css('height', stickyHeight);
o.stickyElement = stickyElement;
o.stickyWrapper = stickyWrapper;
o.currentTop = null;
sticked.push(o);
});
},
update: scroller,
unstick: function(options) {
return this.each(function() {
var that = this;
var unstickyElement = $(that);
var removeIdx = -1;
var i = sticked.length;
while (i-- > 0) {
if (sticked[i].stickyElement.get(0) === that) {
splice.call(sticked,i,1);
removeIdx = i;
}
}
if(removeIdx !== -1) {
unstickyElement.unwrap();
unstickyElement
.css({
'width': '',
'position': '',
'top': '',
'float': ''
})
;
}
});
}
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if (window.addEventListener) {
window.addEventListener('scroll', scroller, false);
window.addEventListener('resize', resizer, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', scroller);
window.attachEvent('onresize', resizer);
}
$.fn.sticky = function(method) {
if (methods[method]) {
return methods[method].apply(this, slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$.fn.unstick = function(method) {
if (methods[method]) {
return methods[method].apply(this, slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.unstick.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$(function() {
setTimeout(scroller, 0);
});
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
(function($) {
// we create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;
// and then we overwrite the function with our own code
inlineEditPost.edit = function( id ) {
// "call" the original WP edit function
// we don't want to leave WordPress hanging
$wp_inline_edit.apply( this, arguments );
// now we take care of our business
// get the post ID
var $post_id = 0;
if ( typeof( id ) == 'object' )
$post_id = parseInt( this.getId( id ) );
if ( $post_id > 0 ) {
// define the edit row
var $edit_row = $( '#edit-' + $post_id );
// get the release date
var $release_date = $( $post_id ).text();
// populate the release date
/* $("#order_priority_value option:selected").prop("selected",false);
$("#order_priority_value option[value=" + $release_date + "]").prop("selected",true);*/
/* $("#order_priority_value > select > option[value=" + value + "]").prop("selected",true);*/
}
};
})(jQuery);

View File

@@ -0,0 +1,665 @@
var woo = {};
(function($) {
//Keys required for accessing the woocommerce api calls (Referenced in woo.getRatePlan, woo.getCoreProduct, and woo.displayProtectionPlan)
var consumer_key = "ck_63c6c0c6c1a22a78c0cbfdc9f344f74ba6c42f3b";
var consumer_secret = "cs_71499bc1c4a6429ff1c6aca680a97b0cc74b2d95";
var _self = this;
_self.productInfo = undefined; //Stores product information retrieved from API call
_self.productVariations = undefined;//Stores product variation information from API call in woo.getRatePlan
_self.cart = undefined; //Stores the cart object created in woo.displayFallDetection
_self.productName = undefined; //Stores that name of the product given in woo.getRatePlan
//Function to parse together the html for the product cards based on the product JSON object sent
woo.createRateButtons = function(product) {
//regularPrice = parseFloat(product.regular_price).toFixed(2);
var card = '';
var ratePromotions = '';
var displayPrice;
salePrice = parseFloat(product.sale_price).toFixed(2);
ratePromotions = product.attributes[6].option.split(",");
specialOffer = product.attributes[7].option.split(",");
dPrice = parseFloat(product.price).toFixed(2);
ratePlan = product.attributes[1].option;
product_id = product.id;
noidea = product.attributes[1].option;
card +=
'<a class="et_pb_button et_pb_button_0 mobblk et_pb_bg_layout_dark" data-toggle="modal" title=' + product.attributes[1].option +'" data-product="' + product.id + '" onclick="woo.displayFallDetection(' + "'" + product.id+ "','" + product.price + "','" + product.attributes[1].option + "','" + product.attributes[3].option + "','" + product.sku + "','" + product.attributes[2].option + "','" + product.attributes[5].option + "'" + ')"> Order Now </a>';
//"<a onclick=" + "woo.displayFallDetection(" + "'" + product.id + "','" + product.price + "','" + product.attributes[1].option + "','" + product.attributes[3].option + "','" + product.sku + "','" + product.attributes[2].option + "','" + product.attributes[5].option + "'" + ') "data-toggle="modal" title="' + product.attributes[1].option +'" class="btn btn-orange btn-block iperModalProduct" data-product="' + product.id + '">Select</a>';
return card;
};
//Function to parse together the html for the rate plan cards based on the product JSON object sent
woo.createRateCard = function(product) {
//regularPrice = parseFloat(product.regular_price).toFixed(2);
var card = '';
var ratePromotions = '';
var displayPrice;
salePrice = parseFloat(product.sale_price).toFixed(2);
ratePromotions = product.attributes[6].option.split(",");
specialOffer = product.attributes[7].option.split(",");
dPrice = parseFloat(product.price).toFixed(2);
ratePlan = product.attributes[1].option;
card +=
'<div class="prtrow">' +
'<div class="prtcolumn30"><label for="'+ratePlan+'" class="radiolbl">'+ratePlan+'</label></div>' +
'<div class="prtcolumn30 prtcolumn65mob paddtop0smob">' +
'<p class="prodcost">$'+dPrice+'/mo. <span class="small-red-txt">'+specialOffer+' </span></p>' +
'<p class="showmob prodoffer2"><strong>'+ratePromotions+'</p>' +
'</div>' +
'<div class="nsmob prtcolumn35">' +
'<p class="prodoffer2"><strong>'+ratePromotions+'</p>' +
'</div>' +
'<div class="prtcolumn25 paddtop12">' +
'<a class="btn btn-red-learnmore qr-buy-btn red-btn et_pb_bg_layout_light" onmouseover="" style="cursor: pointer;" data-toggle="modal" title=' + ratePlan +'" data-product="' + product.id + '" onclick="woo.displayFallDetection(' + "'" + product.id+ "','" + product.price + "','" + ratePlan + "','" + product.attributes[3].option + "','" + product.sku + "','" + product.attributes[2].option + "','" + product.attributes[5].option + "'" + ' ) "> Select </a>'+
'</div>' +
'</div>';
return card;
};
//Function that does an ajax call returning on all the variations for a specific product.
woo.getRatePlan = function(callback, productId, productName) {
_self.productName = productName;
$.ajax({
async: false,
method: "GET",
url:
"/wp-json/wc/v3/products/" +
productId +
"/variations?per_page=100&order=asc&consumer_key=" +
consumer_key +
"&consumer_secret=" +
consumer_secret,
success: function(data) {
_self.productVariations = data;
callback(data);
}
});
};
//Function that initiates the display and creation of the modal for the upsell fall detection pendents, also creates and does initial insert into cart object.
woo.displayFallDetection = function(id, price, rate_plan, rateplan_sfid, product_sfid, price_mulitplier, promotion) {
//Initial add to cart
_self.cart = new woo.cartPackage();
_self.cart.product_sid = product_sfid;
_self.cart.rateplan_sid = rateplan_sfid;
_self.cart.rateplan_multiplier = price_mulitplier;
_self.cart.product_price = price;
_self.cart.product_rate_price = (parseFloat(price)*parseFloat(price_mulitplier)).toFixed(2);
_self.cart.ratePlan = rate_plan;
if(promotion !== "none"){
_self.cart.promotionId = promotion;
}else{
_self.cart.promotionId = undefined;
}
_self.cart.productName = _self.productName;
//Modal creation
var modal = document.getElementById("modalProduct");
var modalContent = woo.createFallDetectionCard(rate_plan);
$("#modalProduct").html(modalContent);
$("body").append('<div id="modalBackDrop" class="modal-backdrop fade in"></div>');
modal.classList.add("in");
modal.style.display = "block";
};
//Function that generates the html for the Modal Fall Detection Buttons
woo.createFallDetectionCard = function(rate_plan) {
var product = _self.productVariations;
var fd_info;
for (var i = 0; i < product.length; i++) {
if (
product[i].attributes[0].option === "fall" &&
product[i].attributes[1].option === rate_plan
) {
fd_info = product[i];
break;
}
}
fdPrice = parseFloat(fd_info.attributes[4].option).toFixed(2);
var modalContent =
'<div class="modal-dialog modal-lg" role="document">' +
'<div class="modal-content">' +
'<div class="modal-body">' +
'<button class="close" data-dismiss="modal" aria-label="Close" onclick="woo.closeModal()"><span aria-hidden="true">×</span></button>' +
'<div class="row">' +
'<div class="col-md-6 mod-text text-left">' +
'<div class="detail-plan">' +
'<div class="text-plan">' +
"<h2>Add Fall Detection</h2>" +
"<p>With this popular feature your Medical Alert pendant senses a fall and contacts an operator immediately—even if you cant press your button.*</p>" +
"</div>" +
// "<h1>Fall Detection </h1>" +
'<span class="upsell_price">$' +
fdPrice +
"/mo.</span>" +
'<div id="modal-btns" class="modal-btns">' +
'<a onclick="woo.displayProtectionPlan(' +"'" +1 + "','" + rate_plan + "','" + fd_info.attributes[3].option + "','" + fd_info.attributes[4].option + "','" + fd_info.attributes[6].option +
"'" +
')" class="btn et_pb_button et_pb_button_1 btn-red-learnmore et_pb_bg_layout_light modbtn-add iperModalUpsell" id="modalupsell" data-toggle="modal" data-target="#modalProduct69" data-promotion-id="" data-block="" data-upsell="2175,10" data-product-id="10" data-upsell-id="68" data-dismiss="modal">Add to Cart</a>' +
'<a onclick="woo.displayProtectionPlan(' +
"'" +
0 +
"','" +
rate_plan +
"'" +
')" class="blue-btn et_pb_button et_pb_button_1 btn-blue-learnmore et_pb_bg_layout_light modbtn-thanks" id="modalupsell" data-toggle="modal" data-target="#modalProduct69" data-upsell-id="68" data-dismiss="modal">No Thanks</a> ' +
"</div>" +
"</div>" +
"</div>" +
'<div class="col-md-6 upsell_img fd-upsell"></div>' +
"</div>" +
"</div>" +
"</div>" +
"</div>";
return modalContent;
};
//Function that initiates the display and creation of the modal for the upsell protection plan, also adds fall detection data to cart if add to cart is selected.
//Also performs that AJAX call to get the shipping information(Might be better placed somewhere else in the flow but is here for now)
woo.displayProtectionPlan = function(choice, rate_plan, sfID, price, promoID) {
//If Add to Cart is selected on fall detection pendent modal add FDP info to cart
if (choice == 1){
_self.cart.upsells.push([
sfID,
price,
"Fall Detection Button",
parseFloat(_self.cart.rateplan_multiplier) * parseFloat(price),
promoID
]);
}
//AJAX call to get the shipping variations from woocommerce then parse them into the cart object(Maybe better served at different location)
$.ajax({
async: false,
method: "GET",
url:
"/wp-json/wc/v3/products/" +
localStorage.getItem('ShippingInfo') +
"/variations?consumer_key=" +
consumer_key +
"&consumer_secret=" +
consumer_secret,
success: function(data) {
woo.parseShipping(data);
}
});
//creates and displays modal for the Protection Plan
var modal = document.getElementById("modalProduct");
var modalContent = woo.createProtectionPlanCard(rate_plan);
$("#modalProduct").html(modalContent);
modal.classList.add("in");
modal.style.display = "block";
};
//Function that generate the html for the Modal Protection Plan
woo.createProtectionPlanCard = function(rate_plan) {
var product = _self.productVariations;
var pp_info;
for (var i = 0; i < product.length; i++) {
if (
product[i].attributes[0].option === "protection" &&
product[i].attributes[1].option === rate_plan
) {
pp_info = product[i];
break;
}
}
var modalContent =
'<div class="modal-dialog modal-lg" role="document">' +
'<div class="modal-content">' +
'<div class="modal-body">' +
'<button class="close" data-dismiss="modal" aria-label="Close" onclick="woo.closeModal()"><span aria-hidden="true">×</span></button>' +
'<div class="row">' +
'<div class="col-md-6 mod-text protection-text-plan text-left">' +
'<div class="detail-plan">' +
'<div class="text-plan">' +
"<h2>Add a Protection Plan</h2>" +
"<p>Prevent out of pocket expenses up to $350 in case your system is lost, stolen, or damaged with a Protection Plan.</p>" +
"</div>" +
// "<h1>Protection Plan </h1>" +
'<span class="upsell_price">$' +
pp_info.attributes[4].option +
"/mo.</span>" +
'<div id="modal-btns" class="modal-btns">' +
'<a onclick="woo.navShipping(' +
"'1" +
"','" +
pp_info.attributes[3].option +
"','" +
pp_info.attributes[4].option +
"','" +
pp_info.attributes[6].option +
"'" +
')" class="btn et_pb_button et_pb_button_1 btn-red-learnmore et_pb_bg_layout_light modbtn-add iperModalUpsell" id="modalupsell" data-toggle="modal" data-target="#modalProduct69" data-promotion-id="" data-block="" data-upsell="2175,10" data-product-id="10" data-upsell-id="68" data-dismiss="modal">Add to Cart</a>' +
'<a onclick="woo.navShipping(' +
"'0'" +
')" class="blue-btn et_pb_button et_pb_button_1 btn-blue-learnmore et_pb_bg_layout_light modbtn-thanks" id="modalupsell" data-toggle="modal" data-target="#modalProduct69" data-upsell-id="68" data-dismiss="modal">No Thanks</a> ' +
"</div>" +
"</div>" +
"</div>" +
'<div class="col-md-6 upsell_img protection-upsell"></div>' +
"</div>" +
"</div>" +
"</div>" +
"</div>";
return modalContent;
};
//Function that initiates the display and creation of the modal for the upsell protection plan, also adds fall detection data to cart if add to cart is selected.
//Also performs that AJAX call to get the shipping information(Might be better placed somewhere else in the flow but is here for now)
woo.displayProtectionPlanSale = function(choice, rate_plan, sfID, price, promoID) {
//If Add to Cart is selected on fall detection pendent modal add FDP info to cart
if (choice == 1){
_self.cart.upsells.push([
sfID,
price,
"Fall Detection Sale Button",
parseFloat(_self.cart.rateplan_multiplier) * parseFloat(price),
promoID
]);
}
//AJAX call to get the shipping variations from woocommerce then parse them into the cart object(Maybe better served at different location)
$.ajax({
async: false,
method: "GET",
url:
"/wp-json/wc/v3/products/" +
localStorage.getItem('ShippingInfo') +
"/variations?consumer_key=" +
consumer_key +
"&consumer_secret=" +
consumer_secret,
success: function(data) {
woo.parseShipping(data);
}
});
//creates and displays modal for the Protection Plan
var modal = document.getElementById("modalProduct");
var modalContent = woo.createProtectionPlanSaleCard(rate_plan);
$("#modalProduct").html(modalContent);
modal.classList.add("in");
modal.style.display = "block";
};
//Function that generate the html for the Modal Protection Plan
woo.createProtectionPlanSaleCard = function(rate_plan) {
var product = _self.productVariations;
var ppsale_info;
for (var i = 0; i < product.length; i++) {
if (
product[i].attributes[0].option === "protection_sale" &&
product[i].attributes[1].option === rate_plan
) {
ppsale_info = product[i];
break;
}
}
var modalContent =
'<div class="modal-dialog modal-lg" role="document">' +
'<div class="modal-content">' +
'<div class="modal-body">' +
'<button class="close" data-dismiss="modal" aria-label="Close" onclick="woo.closeModal()"><span aria-hidden="true">×</span></button>' +
'<div class="row">' +
'<div class="col-md-6 mod-text protection-text-plan text-left">' +
'<div class="detail-plan">' +
'<div class="text-plan">' +
"<h2>Free Protection Plan</h2>" +
"<p>Prevent out of pocket expenses up to $350 in case your system is lost, stolen, or damaged with a Protection Plan.</p>" +
"</div>" +
"<h1>Protection Plan </h1>" +
'<span class="upsell_price">$' +
ppsale_info.attributes[4].option +
"/mo.</span>" +
'<div id="modal-btns" class="modal-btns">' +
'<a onclick="woo.navShipping(' +
"'1" +
"','" +
ppsale_info.attributes[3].option +
"','" +
ppsale_info.attributes[4].option +
"','" +
ppsale_info.attributes[6].option +
"'" +
')" class="btn et_pb_button et_pb_button_1 btn-red-learnmore et_pb_bg_layout_light modbtn-add iperModalUpsell" id="modalupsell" data-toggle="modal" data-target="#modalProduct69" data-promotion-id="" data-block="" data-upsell="2175,10" data-product-id="10" data-upsell-id="68" data-dismiss="modal">Continue</a>' +
"</div>" +
"</div>" +
"</div>" +
'<div class="col-md-6 upsell_img" style="background: url(/wp-content/uploads/2020/11/Protection-Plan.jpg) no-repeat center / cover; height: 600px; position:absolute; right:0;"></div>' +
"</div>" +
"</div>" +
"</div>" +
"</div>";
return modalContent;
};
//Shows cart when Product is added
woo.getCart = function(){
cartCard = woo.createCart();
$('#preview-order-payment').html(cartCard);
}
woo.getCartItemCount = function(){
var cart = JSON.parse(sessionStorage.getItem('cart'));
return cart.upsells.length + cart.accessories.length + ((cart.product_sid != undefined && cart.product_sid !== '') ? 1 : 0);
}
function resize(){
var cartCheck = sessionStorage.getItem('cart');
var width = jQuery(window).width();
if (cartCheck) {
if (width >= 768) {
jQuery('#carticon').css('display', 'inline');
jQuery('.mobcart').css('display', 'none');
} else {
jQuery('.mobcart').css('display', 'inline-block');
}
}else {
jQuery('.menu-item-29619').css('display','none');
jQuery('.mobcart').css('display','none');
}
}
$(document).ready(function(){
resize();
$(window).resize(resize);
});
//Function that generates the html for the cart to be viewed in the Order Summary Column on the Shipping Page
woo.createCart = function() {
var cartInfo = JSON.parse(sessionStorage.getItem('cart'));
//console.log(cartInfo.ratePlan);
if (cartInfo.ratePlan == "Annually") {
cartInfo.rateplan_multiplier = "12";
//console.log(cartInfo.rateplan_multiplier);
}
var cart =
//console.log(cartInfo.accessories);
'<div class="title">Order Summary</div>' +
'<div id="iperCartDetail" class="order-detail">' +
'<div data-product="12" class="containerIperProduct">' +
'<img src="' + cartInfo.accessories[0][3]+ '" style="float: right;" width="30%">' +
"<!-- PRODOTTO -->" +
'<div class="product">' +
'<span class="name"><strong>'+cartInfo.productName+'</strong></span>' +
"</div>" +
'<div class="clearfix"></div>';
//Builds the rateplan portion of cart
cart+=
"<!-- RATEPLAN -->" +
'<div class="row payment-type">' +
'<div class="col-6 col-md-6">' + cartInfo.ratePlan + "</div>" +
'<div class="col-6 col-md-6 priceff"> <span> $'+cartInfo.product_rate_price+'<strong>/'+cartInfo.rateplan_multiplier+' mo</strong></span></div>' +
"</div>";
//Builds the Upsells portion of cart
if (isNaN(cartInfo.upsells)) {
cart+="<!-- UPSELLS -->" +
'<div class="row upsells">';
for(var i = 0; i<cartInfo.upsells.length; i++){
cart +=
'<div class="col-6 col-md-6">' +
cartInfo.upsells[i][2] +
"</div>" +
'<div class="col-6 col-md-6 price_up"><span class="priceff">$' +
cartInfo.upsells[i][3] +
"<strong>/" +
cartInfo.rateplan_multiplier +
" mo</strong></span></div>";
}
}
cart+="</div>" +
'<div class="clearfix"></div>';
//Builds Accessories portion of cart
cart+="<!-- ACCESSORIES -->" +
'<div class="row">';
for(var i = 0; i<cartInfo.accessories.length; i++){
cart +=
'<div class="col-6 col-md-6">' +
cartInfo.accessories[i][1] +
"</div>" +
'<div class="col-6 col-md-6 price_up"><span class="priceff">$' +
cartInfo.accessories[i][2] +
"</span></div>";
}
cart+=
'<div class="col-12 col-md-12 shipping-label"></div>' +
'<div class="col-6 col-md-6 shipping-type-label"></div>' +
'<div class="col-6 col-md-6 shipping-price"></div>' +
'</div>' +
"<hr>";
//Builds the Total portion of cart
cart+="<!-- TOTAL -->" +
'<div class="row total">' +
'<div class="col-6 col-md-6 total">' +
'<div class="total1"><strong>Total</strong>' +
"</div>" +
"</div>" +
'<div class="col-6 col-md-6 price_up"><span class="price">$'+cartInfo.totalPrice+'</span></div>' +
'<div class="clearfix"></div>' +
"</div>" +
"<!--Session variable to display text on cart page -->" +
'<span id="taxdisclaimer" style="display:none">Plus applicable tax</span>';
var cookies = document.cookie;
var arrayCookies = cookies.split(';');
var sessPromo = '';
var promoLabel = '';
//console.log(cookies);
//console.log(arrayCookies);
for(k in arrayCookies){
//console.log(arrayCookies[k]);
if(arrayCookies[k].includes("SESSpromotion")){
//console.log("Promo found");
var arraySessPromo = arrayCookies[k].split('=');
sessPromo = arraySessPromo[1];
//str.replace(/%20/g, " ");
sessPromo = sessPromo.replace(/%20/g, " ");;
sessPromo = sessPromo.replace(/%24/g, "$");;
promoLabel = "Promotion";
break;
}
}
cart+=
"<!-- PROMOTION -->" +
'<hr>' +
'<div class="row total">' +
'<div class="col-12 col-md-12 total">' +
'<div class="total1"><strong>'+promoLabel+'</strong>' +
"</div>" +
"</div>" +
"</div>" +
'<div class="row total">' +
'<div class="col-12 col-md-12">'+sessPromo+'</div>' +
'<div class="clearfix"></div>' +
"</div>" +
"</div>";
return cart;
};
//Function that gets the object cart out of session storage
woo.packageObject = function() {
var payLoad = sessionStorage.getItem('cart');
return payLoad;
};
//Function that sends the all the information in cart to the dataPassing.php file to be parsed and pushed into Session variables in the server.
woo.postProductInformation = function() {
// $.ajax({
// data: "Package=" + woo.packageObject(),
// //url: "/wp-content/plugins/iper-medical/templates/dataPassing.php",
// url: "/wp-content/plugins/iper-medical/templates/template-product.php",
// async: false,
// method: "POST", // or GET
// success: function() {
// console.log("This was sent with a 200 code");
// alert('success');
// },
// error: function(x, msg, ex) {
// alert('fail');
// console.log(msg);
// }
// });
$('[name="Package"]').val(woo.packageObject);
$('#dataPassing').submit();
};
//Function that performs the AJAX GET call to the woocommerce API for all products
woo.getCoreProducts = function(callback, $) {
$.ajax({
async: false,
method: "GET",
url:
"/wp-json/wc/v3/products?order=asc&consumer_key=" +
consumer_key +
"&consumer_secret=" +
consumer_secret,
success: function(data) {
_self.productInfo = data;
callback(data);
}
});
};
//Function that does the final add to cart for Accessories and Protection Plan choice before sending information over to Server, then navigating page to the
// shipping page.
woo.navShipping = function(choice, sfid, price,promoID, displayFeatimage) {
//If add to cart was chosen for protection plan push information into cart
var product = _self.productVariations;
var ratePlan = _self.cart.ratePlan;
var accessories = _self.cart.accessories;
for(var i = 0; i<product.length; i++){
console.log(product[i].image.src);
let displayFeatimage = product[i].image.src;
};
//Add all Accessories related to product into the cart
for(var i = 0; i<product.length; i++){
if (product[i].attributes[0].option === "accessory") {
if (product[i].attributes[1].option === "all") {
accessories.push([
product[i].attributes[2].option, //Salesforce ID
product[i].attributes[3].option, //Acessory Name
product[i].attributes[4].option, //Programming Fee
product[i].image.src
]);
//alert(product[i].attributes[4].option);
} else if ( product[i].attributes[1].option === ratePlan)
{
accessories.push([
product[i].attributes[2].option, //Salesforce ID
product[i].attributes[3].option, //Acessory Name
product[i].attributes[4].option //Programming Fee
]);
}
}
}
if (ratePlan === 'Annually'){
var pp_total = parseFloat(12) * parseFloat(price);
console.log(ratePlan);
} else {
var pp_total = parseFloat(_self.cart.rateplan_multiplier) * parseFloat(price);
console.log(ratePlan);
}
if(choice == 1){
_self.cart.upsells.push([
sfid,
price,
"Protection Plan",
pp_total,
promoID
]);
}
//Add the total price of order (Upsells + Core) to cart
console.log(productName);
_self.cart.totalPrice = parseFloat(_self.cart.product_price) * parseFloat(_self.cart.rateplan_multiplier) + 79.00;
for(var i = 0; i<_self.cart.upsells.length; i++){
//Takes the initial value for total price and adds to it the unrounded price from the upsell
_self.cart.totalPrice += _self.cart.upsells[i][3];
//Rounds the price for the upsell to 2 decimal places for display purposes
_self.cart.upsells[i][3] = (_self.cart.upsells[i][3]).toFixed(2);
}
//Rounds the final total price to 2 decimal places.
_self.cart.totalPrice = (_self.cart.totalPrice).toFixed(2);
//Sends the cart object to the sessionStorage object to be referenced on shipping page.
sessionStorage.setItem('cart', JSON.stringify(_self.cart));
//Sends the cart object to the Server
woo.postProductInformation();
//Navigates user to next page
//window.location.href = "/medical-shipping.html";
};
//Cart object used to pass information to the Server
woo.cartPackage = function() {
this.images;
this.productName;
this.product_sid;
this.product_price;
this.product_rate_price;
this.ratePlan;
this.rateplan_sid;
this.rateplan_multiplier;
this.upsells = [];
this.accessories = [];
this.totalPrice;
this.promotionId;
this.shippingMethods = [];
};
//Parses the response from the AJAX call to get all shipping prices, pushing into the cart
woo.parseShipping = function(data) {
for(var i = 0; i<data.length; i++){
_self.cart.shippingMethods.push([data[i].attributes[0].option, data[i].attributes[1].option, data[i].attributes[2].option]);
}
};
//Function used to remove the html/css rules that show the modal.
woo.closeModal=function(){
$("#modalProduct").html('');
$("#modalProduct").removeClass('in');
$("#modalProduct").removeAttr("style");
$("#modalBackDrop").remove();
}
})(jQuery);

View File

@@ -0,0 +1,3 @@
jQuery(".s-button").on("click", function() {
jQuery(".s-button-wrapper").toggleClass("expanded");
});

File diff suppressed because one or more lines are too long