console.info("--- STORE -----------------------------------------------");
console.info($ == undefined);
console.info($);
store = {
debug: (window.location.origin == "http://bs" || window.location.origin == "https://staging.scan2scan.com" || window.location.origin == "https://staging.bridescan.com"),
debugEventKey: (window.location.origin == "http://bs"),
ok: function () {
this._conf._eventKey = this.debugEventKey ? "development" : this._conf._eventKey;
var _ok = $("#store-" + this._conf._eventKey).length !== 0;
console.warn("##########################################################################################################");
console.warn("### EMBED STORE #store-" + this._conf._eventKey + " :: INIT-OK :: " + (_ok ? "OK" : "NOT OK "));
console.warn("##########################################################################################################");
return _ok;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
init: function () {
console.warn("##########################################################################################################");
console.warn("### EMBED STORE :: INIT :: IN ############################################################################");
console.info("#store-" + this._conf._eventKey + " :: " + $("#store-" + this._conf._eventKey).length);
console.info(this._conf);
console.info(this._eventInfo);
this.initialize();
console.warn("### EMBED STORE :: INIT :: OUT ###########################################################################");
console.warn("##########################################################################################################");
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
initialize: function () {
console.info("--- initialize :: -------------------------------------------------------");
$.each(this, function (k, v) {
if (k.indexOf("_") == 0) {
v["_root"] = "$store";
v["_eventKey"] = $store._conf._eventKey;
}
});
this._form._css_prefix_ = "str-";
this.css();
this._store.init(this._eventInfo);
this._comm._initialize();
this.renderStore();
this.next(true);
//------------------------------------------------------------
//--- DEBUG
//------------------------------------------------------------
if (this.debug) {
//this.renderCode();
var div = "
";
var html = "";
html += JSON.stringify(this._eventInfo, null, 2);
$("#atbta-debug-atbta").html(html);
//$store.next();
}
//------------------------------------------------------------
//--- DEBUG
//------------------------------------------------------------
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
canNext: function (visible) {
switch (visible) {
case "tickets":
$store._store.update();
var ret = $store._store.hasQuantity();
if (!ret) {
this.renderError("Choose a quantity to purchase");
}
return ret;
case "info":
$store._store.update();
}
return true;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
next: function (initial) {
//console.clear();
console.warn("---------------------------------------------------------------------------------------------");
console.warn("---------------------------------------------------------------------------------------------");
console.info("--- next" + (initial ? " :: " + initial : ""));
this.renderError();
var visible = $(".str-section:visible");
if (this.canNext(visible.data("store-section"))) {
var show = null;
var title = "";
console.info("--- next :: -" + visible.data("store-section") + "- :: " + (visible.data("store-section") == "completed"));
if ((visible.data("store-section") + "") == "completed" && initial != true) {
return;
}
switch (visible.data("store-section")) {
//----------------------------------------------------------------------------
case "tickets":
if ($store._store.infos() == null) {
show = "cart";
title = "Checkout";
this.renderCart();
}
else {
show = "info";
title = "Provide Needed Info(s)";
this.renderInfo();
}
break;
//----------------------------------------------------------------------------
case "info":
console.info("infos");
let _valid = this._form.validateUnique();
console.info(_valid);
if (_valid != "uniqueCheck") {
if (_valid == 1) {
show = "cart";
title = "Checkout";
this.renderCart();
}
else {
show = "info";
title = "Provide Needed Info(s)";
console.info(typeof _valid);
this.renderError(typeof _valid == "string" ? _valid : "Provide all required information before continuing.");
}
}
else {
return;
}
break;
//----------------------------------------------------------------------------
case "cart":
title = "Thank You";
show = "completed";
this.renderCompleted();
break;
//----------------------------------------------------------------------------
default:
show = "tickets";
title = $store._eventInfo.eventStoreButton;
break;
//----------------------------------------------------------------------------
}
$("#str-navigation-title").html(title);
if ($(".str-section:visible").data("storeSection") != show) {
$(".str-section:visible").hide();
$("[data-store-section='" + show + "']").show();
if (initial !== true) {
this.scrollUp();
}
}
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
nextTo: function (show, title) {
$("#str-navigation-title").html(title);
if ($(".str-section:visible").data("storeSection") != show) {
$(".str-section:visible").hide();
$("[data-store-section='" + show + "']").show();
this.scrollUp();
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
back: function (from) {
console.info("back" + (from ? " :: " + from : ""));
this.renderError();
var visible = $(".str-section:visible");
var show = null;
var back = false;
var title = "";
var current = visible.data("store-section");
switch (from ? from : current) {
case "info":
case "code":
$store._store.update();
title = $store._eventInfo.eventStoreButton;
show = "tickets";
break;
case "codeCheckout":
$store._store.update();
if ($store._store.infos() == null) {
show = "cart";
title = "Checkout";
this.renderCart();
}
else {
show = "info";
title = "Provide Needed Info(s)";
this.renderInfo();
}
break;
case "cart":
if ($store._store.infos() == null) {
title = $store._eventInfo.eventStoreButton;
show = "tickets";
}
else {
show = "info";
title = "Provide Needed Info(s)";
back = true;
}
break;
case "payment":
show = "cart";
title = "Cart";
back = true;
break;
case "completed":
show = "payment";
title = "Payment";
back = true;
break;
default:
break;
}
if (show == "tickets") {
$store.renderTickets();
}
$("#str-navigation-title").html(title);
console.info(current + " :: " + show);
$(".str-section:visible").hide();
$("[data-store-section='" + show + "']").show();
this.scrollUp();
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderStore: function () {
console.info("--- renderStore -------------------------------------------------------");
var html = "";
html += this.renderEvent();
html += this.renderNav();
html += this.renderTickets();
html += this.renderCode();
html += this.renderInfo();
html += this.renderCart();
html += this.renderCompleted();
this.content(html);
this.renderTickets();
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderEvent: function () {
return "" + this._eventInfo.event.name + " Store
" + this._eventInfo.event.startDate + "
";
},
renderNav: function () {
var html = "";
html += "";
html += " ";
html += " ";
html += "
";
html += "
";
return html;
},
renderError: function (msg) {
$("#str-error").hide();
if (msg) {
console.info(msg);
$("#str-error").html(msg);
$("#str-error").show();
this.scrollUp();
}
},
scrollUp: function () {
$([document.documentElement, document.body]).animate({scrollTop: $(".str-navigation").offset().top - 75}, 500);
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderTickets: function () {
console.clear();
if ($("[data-store-section='tickets']").length == 0) {
return "
";
}
var isLocalhost = window.location.hostname == "localhost";
var innerHtml = $store.renderStoreCodes();
var innerHtmlGroup = "";
var _groups = {}
var _groupNames = [];
$.each(this._eventInfo.products, function (i, ticket) {
//console.warn("--- TICKET ---------------------------------");
//console.info(ticket);
$store.storeTicketFees(ticket);
if (ticket.hasOwnProperty("groupingName") && ticket.groupingName != null && ticket.groupingName.trim().length != 0) {
if (!_groups.hasOwnProperty(ticket.groupingName)) {
_groups[ticket.groupingName] = [];
_groupNames.push(ticket.groupingName);
}
_groups[ticket.groupingName].push(ticket);
}
else {
innerHtml += $store.renderStoreTicket(ticket, (isLocalhost ? 2 : 0));
}
});
if (_groupNames.length != 0) {
innerHtmlGroup += "click groups below to show additional items
";
$.each(_groupNames.sort(), function (i, groupName) {
innerHtmlGroup += $store.renderStoreGroup(i, groupName, _groups[groupName]);
});
}
html = "";
html += ($store._eventInfo.hasOwnProperty("codes") && $store._eventInfo.codes.length != 0 ? "
Have Promo Code? Click HERE first.
" : "");
html += "
choose quantity for each item and press continue
";
html += "
" + innerHtml + "
";
html += innerHtmlGroup;
html += ($store._eventInfo.hasOwnProperty("codes") && $store._eventInfo.codes.length != 0 ? "
Have Promo Code? Click HERE first.
" : "");
html += "
continue
";
html += $store.renderFbPixel("PageView", undefined, window.location.href);
html += "
";
$("[data-store-section='tickets']").html(html);
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderStoreGroup: function (groupId, groupName, tickets) {
var cartQuantities = $store._storage.store("cart-quantities");
var innerHtml = "" + groupName + "
";
var count = 0;
$.each(tickets, function (i, ticket) {
var id = ticket.eventProductId;
if (cartQuantities.hasOwnProperty(id)) {
count += cartQuantities[id];
}
innerHtml += $store.renderStoreTicket(ticket, 0);
});
innerHtml = "" + innerHtml + "
";
return "" + groupName + "
" + innerHtml;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderStoreGroupShowHide: function (groupId, show) {
if (show) {
$("#grpc" + groupId).show();
$("#grp" + groupId).hide();
}
else {
$("#grpc" + groupId).hide();
$("#grp" + groupId).show();
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderStoreTicket: function (ticket, index) {
console.info("--- renderStoreTicket :: " + ticket.name + " -------------------------------------------------------");
var html = "";
var quantityHtml = this._store.inputs.quantity(ticket.eventProductId, index + "", "str-item-quantity str-override", ticket.maxPurchaseQuantity);
var imageContent = null;
if (ticket.hasOwnProperty("eventStoreProductImages")) {
imageContent = " ";
}
html += "";
html += " ";
if (imageContent != null) {
html += " " + imageContent + " ";
}
html += " " + ticket.name + " ";
html += " ";
html += (ticket.fullPrice != ticket.discountedPrice ? ticket.upto : "");
html += (ticket.priceDifferent ? "from " : "");
html += ticket._price.priceTotal;
html += (ticket._price.breakdown != null ? "(" + ticket._price.breakdown + ")
" : "");
html += quantityHtml;
html += " ";
html += " ";
html += " " + ticket.description + " ";
html += "
";
return html;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
storeTicketFees: function (ticket) {
console.info("--- storeTicketFees :: " + ticket.name + " ------------------------------");
var max = ticket.maxPurchaseQuantity;
var fullPrice = ticket.price;
var price = ticket.price;
var discountCodes = $store._store.codes();
var discount = null;
var isAmount = true;
$.each(discountCodes, function (key, discountCode) {
if (discount == null && discountCode.skipQuantities && (discountCode.haveProducts || (discountCode.exclusive == "EXCLUSIVE" && discountCode.discountCodeAmountType == "PERCENTAGE"))) {
if (discountCode.groups.length == 0) {
//console.info(discountCode);
discount = discountCode.price;
isAmount = discountCode.discountCodeAmountType == "AMOUNT";
}
$.each(discountCode.groups, function (g, group) {
$.each(group.products, function (p, product) {
if (ticket.eventProductId == product.eventProductId) {
//console.info(discountCode);
discount = discountCode.price;
isAmount = discountCode.discountCodeAmountType == "AMOUNT";
ticket["upto"] = (product.hasOwnProperty("maxQuantity") ? "(up to " + product.maxQuantity + " count) " : "");
}
});
});
}
});
//console.info("\t\tdiscount: " + discount);
//console.info("\t\tisAmount: " + isAmount);
ticket["priceDifferent"] = false;
if (price == undefined) {
//console.info("\t\t--- NO PRICE ---");
var different = false;
$.each(ticket.variations, function (v, variation) {
//console.warn("--- variation :: " + variation.name + " ---");
variation.price = parseFloat(variation.price);
if (price != undefined) {
different |= price != variation.price;
}
fullPrice = price = (price == undefined || parseFloat(price) > parseFloat(variation.price) ? variation.price : price);
variation["_price"] = $store.storeTicketFeeCalculate(variation, variation.price, variation.price - (discount != null ? (isAmount ? discount : variation.price * discount / 100) : 0))
//console.info(variation);
if (variation.hasOwnProperty("maxPurchaseQuantity")) {
if (max == undefined || max > variation.maxPurchaseQuantity) {
max = variation.maxPurchaseQuantity;
}
}
});
var discountAmount = (discount != null ? (isAmount ? discount : price * discount / 100) : 0);
ticket["_price"] = $store.storeTicketFeeCalculate(ticket, fullPrice, price - discountAmount);
ticket.priceDifferent = different;
}
else {
//console.info("\t\t--- PRICE ---");
var discountAmount = (discount != null ? (isAmount ? discount : price * discount / 100) : 0);
ticket["_price"] = $store.storeTicketFeeCalculate(ticket, fullPrice, price - discountAmount);
}
if (ticket.hasOwnProperty("options")) {
$.each(ticket.options, function (o, option) {
if (option.hasOwnProperty("variations")) {
var different = false;
$.each(option.variations, function (v, variation) {
variation.price = parseFloat(variation.price);
if (price != undefined) {
different |= price != variation.price;
}
fullPrice = price = (price == undefined || parseFloat(price) > parseFloat(variation.price) ? variation.price : price);
variation["_price"] = $store.storeTicketFeeCalculate(ticket, variation.price, variation.price, 1, true)
console.info(variation);
if (variation.hasOwnProperty("maxPurchaseQuantity")) {
if (max == undefined || max > variation.maxPurchaseQuantity) {
max = variation.maxPurchaseQuantity;
}
}
});
}
});
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
storeTicketFeeCalculate: function (ticket, fullPrice, discountedPrice, count, excludeDollarAmountFee) {
if (count == undefined) count = 1;
fullPrice = parseFloat(fullPrice);
discountedPrice = parseFloat(discountedPrice);
console.warn("\t\t--- storeTicketFeeCalculate :: " + fullPrice + " :: " + discountedPrice + " ------------------------------");
console.info(ticket);
ticket.feeType.dollarAmount = parseFloat(ticket.feeType.dollarAmount);
ticket.feeType.percentageAmount = parseFloat(ticket.feeType.percentageAmount);
var _price = {
price: discountedPrice,
optionPrice: 0.00,
feeType: ticket.feeType,
fee: 0.00,
salesTax: 0.00,
priceTotal: $store._formatPrice(0.00),
breakdown: null,
breakdownTxt: null,
maxPrice: fullPrice,
maxOptionPrice: 0.00,
maxFeeType: ticket.feeType,
maxFee: 0.00,
maxSalesTax: 0.00,
maxPriceTotal: 0.00,
maxBreakdown: null,
same: true
};
_price.salesTax = (($store._eventInfo.salesTax / 100) * _price.price);
_price.maxFee = parseFloat((((excludeDollarAmountFee != true ? _price.feeType.dollarAmount : 0) * count) + (_price.maxPrice * _price.feeType.percentageAmount)).toFixed(2));
_price.maxSalesTax = parseFloat(($store._eventInfo.salesTax / 100 * (_price.maxPrice + _price.maxFee)).toFixed(2));
_price.maxPriceTotal = $store._formatPrice(_price.maxPrice + _price.maxFee + _price.maxSalesTax);
_price.maxBreakdown = $store._formatPrice(_price.maxPrice) + (_price.maxFee > 0 ? " + " + $store._formatPrice(_price.maxFee) + " fee" : "") + (_price.maxSalesTax > 0 ? " + " + $store._formatPrice(_price.maxSalesTax) + " sales tax" : "");
if (_price.price > 0) {
_price.fee = parseFloat((((excludeDollarAmountFee != true ? _price.feeType.dollarAmount : 0) * count) + (_price.price * _price.feeType.percentageAmount)).toFixed(2));
_price.salesTax = parseFloat((($store._eventInfo.salesTax / 100) * (_price.price + _price.fee)).toFixed(2));
console.info(JSON.parse(JSON.stringify(_price)));
_price.priceTotal = $store._formatPrice(_price.price + _price.fee + _price.salesTax);
var _pt = $store._formatPrice(_price.price);
var _p = (_price.maxPrice != _price.price ? "" + $store._formatPrice(_price.maxPrice) + " " : "") + _pt;
var _ft = (_price.fee > 0 ? $store._formatPrice(_price.fee) + " fee" : "");
var _f = (_price.fee > 0 ? " + " + (_price.maxPrice != _price.price && false ? "" + $store._formatPrice(_price.maxFee) + " " : "") + _ft : "");
var _st = (_price.salesTax > 0 ? $store._formatPrice(_price.salesTax) + " sales tax" : "");
var _s = (_price.salesTax > 0 ? " + " + (_price.maxPrice != _price.price && false ? "" + $store._formatPrice(_price.maxSalesTax) + " " : "") + _st : "");
_price.breakdown = _p + _f + _s;
_price.breakdownTxt = _pt + (_price.fee > 0 ? " + " + _ft : "") + (_price.salesTax > 0 ? " + " + _st : "");
}
else {
if (_price.maxPrice > 0) {
_price.breakdown = "" + $store._formatPrice(_price.maxPrice) + (_price.maxFee > 0 ? " + " + $store._formatPrice(_price.maxFee) + " fee" : "") + (_price.maxSalesTax > 0 ? " + " + $store._formatPrice(_price.maxSalesTax) + " sales tax" : "") + " ";
}
}
return _price;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderStoreCodes: function () {
var html = "";
var discountCodes = $store._store.codes();
$.each(discountCodes, function (key, discountCode) {
var code = undefined;
$.each($store._eventInfo.codes, function (i, c) {
if (c.code.toUpperCase() == key.toUpperCase()) {
code = c;
}
});
if (code) {
html += $store.renderStoreCode(discountCode);
}
else {
delete discountCodes[key];
}
});
$store._store.codes(discountCodes);
return html;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderStoreCode: function (code) {
//console.clear();
console.warn("--------------------------------------------------------------------------------");
console.warn("--------------------------------------------------------------------------------");
console.warn("--- renderStoreCode ------------------------------------------------------------");
console.info(code);
var html = "";
var price = 0.00;
var discount = 0.00;
var isAmount = code.discountCodeAmountType == "AMOUNT";
var isPercentage = code.discountCodeAmountType == "PERCENTAGE";
var isExclusive = code.exclusive == "EXCLUSIVE";
var isEach = code.applyTo == "EACH";
var isCollection = code.applyTo == "COLLECTION";
var isDefault = code.applyToType == "DEFAULT";
var isGroups = code.applyToType == "GROUPS";
var haveProducts = code.haveProducts;
$.each(code.groups, function (g, group) {
if (group.hasOwnProperty("count") && group.count > 0) {
if (group.hasOwnProperty("priceEach")) {
price += group.count * group.priceEach;
discount += group.count * group.discountAmountEach;
}
else {
$.each(group.products, function (p, product) {
if (product.hasOwnProperty("count")) {
price += group.count * product.count * product.priceEach;
discount += group.count * product.count * product.discountAmountEach;
}
});
}
}
});
var _html = "";
var _tmp = 0;
var _tp = 0;
var _tf = 0;
var _ts = 0;
var _p = 0;
var _f = 0;
var _s = 0;
if (code.haveProducts) {
_html += "";
var skipQuantities = false;
$.each(code.groups, function (g, group) {
var _gtmp = 0;
var _gtp = 0;
var _gtf = 0;
var _gts = 0;
if (group.count > 0 || code.skipQuantities) {
var groupPrice = 0;
_html += "" + (code.skipQuantities ? "applies to:" : (isGroups ? "products included:" : "includes:")) + "
";
_html += "";
_html += "";
_html += "";
var _t = 0.0;
if (isCollection || (isEach && isGroups)) {
$.each(group.products, function (p, product) {
if (product.count > 0 || code.skipQuantities) {
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
eventProduct.price = parseFloat(eventProduct.price);
_t += eventProduct.price * product.count;
}
});
}
});
}
_p = 0;
var _td = 0.00;
var _lp = null;
var _lep = null;
var _d = null;
$.each(group.products, function (p, product) {
if (product.count > 0 || code.skipQuantities) {
_lp = product;
console.info(product);
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
console.info(eventProduct);
_lep = eventProduct;
_p = eventProduct.price * product.count;
_d = parseFloat((code.price * (isAmount ? _p / _t : _p / 100)).toFixed(2));
_td += _d;
product["_price"] = $store.storeTicketFeeCalculate(eventProduct, _p, _p - _d, product.count);
}
});
}
});
if (_lep != null && isAmount && _td != code.price) {
_lp._price = $store.storeTicketFeeCalculate(_lep, _p, _p - _d - (code.price - _td), _lp.count);
}
$.each(group.products, function (p, product) {
if (product.count > 0 || code.skipQuantities) {
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
_gtmp += product._price.maxPrice;
_gtp += product._price.price;
_gtf += product._price.fee;
_gts += product._price.salesTax;
_html += "" + eventProduct.name + (product.hasOwnProperty("priceEach") ? "@ " + symbol + product.priceEach + " ea." : "") + (code.skipQuantities ? (product.hasOwnProperty("maxQuantity") ? "(up to " + product.maxQuantity + " count) " : "") : "(" + product.count + " count) ") + " ";
}
});
}
});
_p = (_gtmp != _gtp ? "" + $store._formatPrice(_gtmp) + " " + $store._formatPrice(_gtp) : "");
_f = (_gtf > 0 ? " + " + $store._formatPrice(_gtf) + " fee" : "");
_s = (_gts > 0 ? " + " + $store._formatPrice(_gts) + " sales tax" : "");
group["_price"] = {
price: _gtp,
fee: _gtf,
salesTax: _gts,
priceTotal: _gtp + _gtf + _gts,
breakdown: "(" + _p + _f + _s + ")",
breakdownTxt: (_gtp > 0 ? "(" + $store._formatPrice(_gtp) + _f + _s + ")" : "")
}
_tmp += _gtmp * group.count;
_tp += _gtp * group.count;
_tf += _gtf * group.count;
_ts += _gts * group.count;
_html += " ";
_html += " ";
if (isCollection || (isEach && isGroups)) {
var allStyle = "vertical-align: middle;font-size: 110%;";
var connectorStyle = allStyle + "font-size: 105%;padding: 0 5px;";
if (group.hasOwnProperty("discountPriceEach")) {
_html += "@ ";
_html += "";
_html += $store._formatPrice(group.discountPriceEach);
_html += " ";
}
_html += "x ";
_html += "" + group.count + " ";
}
_html += "
";
skipQuantities |= code.skipQuantities;
}
});
_html += "IMPORTANT: " + (skipQuantities ? " Select quantities from the products listed below to add to the cart." : " Items listed above will be added to the cart IN ADDITION to those selected below.
");
_html += "
";
}
_p = (_tmp != _tp ? "" + $store._formatPrice(_tmp) + " " + $store._formatPrice(_tp) : "");
_f = (_tf > 0 ? " + " + $store._formatPrice(_tf) + " fee" : "");
_s = (_ts > 0 ? " + " + $store._formatPrice(_ts) + " sales tax" : "");
var discountedPrice = "";
if (!haveProducts || code.skipQuantities) {
discountedPrice = (isAmount ? $store._formatPrice(code.price) : code.price + "%") + "off" + (code.haveProducts ? " each" : "") + "
";
}
else {
discountedPrice = $store._formatPrice(_tp + _tf + _ts);
}
html += "";
html += " ";
html += " PROMO CODE
";
html += " ";
html += code.code + (isExclusive ? "EXCLUSIVE " : "") + (code.haveProducts && !code.skipQuantities ? "(" + _p + _f + _s + ")
" : "");
html += " ";
html += " ";
html += " " + discountedPrice;
html += " ";
html += " " + $store._svg.trash + " ";
html += " ";
html += " "
html += " ";
html += _html;
html += " ";
html += " ";
html += "
";
html += this.renderCodeDebug(code);
console.warn("--- renderStoreCode ------------------------------------------------------------");
console.warn("--------------------------------------------------------------------------------");
console.warn("--------------------------------------------------------------------------------");
return html;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderCode: function (code) {
var codeInput = (this.debug && false ? "P01" : "");
if ($("[data-store-section='code']").length == 0) {
return "
";
}
var html = "";
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
if (code) {
//console.clear();
console.info("--- renderCode ----------------------------------------");
console.info(code);
var haveCodes = false;
var haveExclusiveCode = false;
$.each($store._store.codes(), function (c, _code) {
haveCodes = true;
haveExclusiveCode |= _code.exclusive == "EXCLUSIVE";
});
code.price = parseFloat(code.price);
code["skipQuantities"] = false;
code["haveProducts"] = false;
$.each(code.groups, function (g, group) {
code.haveProducts |= group.products.length != 0;
});
var symbol = $store._eventInfo.currency.symbol;
var isAmount = code.discountCodeAmountType == "AMOUNT";
var isPercentage = code.discountCodeAmountType == "PERCENTAGE";
var isExclusive = code.exclusive == "EXCLUSIVE";
var isEach = code.applyTo == "EACH";
var isCollection = code.applyTo == "COLLECTION";
var isDefault = code.applyToType == "DEFAULT";
var isGroups = code.applyToType == "GROUPS";
var haveProducts = code.haveProducts;
var canAddDiscountCode = !haveCodes || (isExclusive && !haveCodes) || (!haveExclusiveCode && !isExclusive);
var discount = parseFloat(code.price);
if (canAddDiscountCode && (!haveProducts || (isEach && isDefault))) {
code.skipQuantities = (isExclusive && (haveProducts || (!haveProducts && isAmount)) ? false : true);
$store.processCode(code.code);
return;
}
html += "";
html += (!canAddDiscountCode ? "
Promo code \"" + code.code + "\" cannot be used with other promo codes in the cart.
" : "");
html += "
";
html += " ";
html += " " + code.code.toUpperCase() + (isExclusive ? "EXCLUSIVE, cannot be used with any other offer " : "") + " ";
html += " " + (isAmount ? symbol : "") + discount + (isPercentage ? "%" : "") + (!isExclusive ? "off each
" : " off") + " ";
html += " ";
html += " " + (code.description ? code.description : "") + " ";
// ##############################################################################################################################
// ##############################################################################################################################
if (code.haveProducts) {
html += " ";
$.each(code.groups, function (g, group) {
html += (g != 0 && isCollection ? "- OR -
" : "");
html += "";
var totalGroupPrice = 0.0;
$.each(group.products, function (p, product) {
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
totalGroupPrice += $store.productPrice(eventProduct) * product.quantity;
}
});
});
// ##########################################################################################################################
// ##########################################################################################################################
if (isGroups || isCollection) {
var discountAmount = (isPercentage ? totalGroupPrice * code.price / 100 : code.price);
var discountPrice = totalGroupPrice - discountAmount;
group["priceEach"] = totalGroupPrice;
group["discountPriceEach"] = discountPrice;
group["discountAmountEach"] = discountAmount;
html += "
";
$.each(group.products, function (p, product) {
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
html += " ";
html += " " + eventProduct.name + (product.hasOwnProperty("quantity") && product.quantity > 0 ? " (" + product.quantity + " count) " : "") + " ";
if (p == 0) {
html += "";
html += $store._formatPrice(group.discountPriceEach);
html += "" + $store._formatPrice(group.priceEach) + "
";
html += "";
html += (isExclusive && isGroups && canAddDiscountCode ? "select " : "");
html += $store._store.inputs.quantity("g-" + group.eventDiscountCodeGroupId, (isExclusive && isCollection ? 1 : 0) + "", "str-item-quantity str-override " + (isExclusive ? "str-hidden" : ""), (group.hasOwnProperty("maxQuantity") ? group.maxQuantity : undefined));
html += "
";
html += " ";
}
html += " ";
html += " " + eventProduct.description + " ";
}
});
});
html += "
";
}
// ##########################################################################################################################
// ##########################################################################################################################
else {
$.each(group.products, function (p, product) {
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
var price = parseFloat($store.productPrice(eventProduct));
var discountAmount = (isPercentage ? price * code.price / 100 : code.price);
var discountPrice = price - discountAmount;
product["priceEach"] = price;
product["discountAmountEach"] = discountAmount;
html += "
";
html += " ";
html += " " + eventProduct.name + (product.hasOwnProperty("quantity") && product.quantity > 0 ? " (" + (product.hasOwnProperty("maxQuantity") ? "up to " + product.maxQuantity : product.quantity + " count") + ") " : "") + " ";
html += " ";
if (!isCollection) {
html += $store._formatPrice(discountPrice);
html += "" + $store._formatPrice(price) + "
";
}
html += " ";
html += $store._store.inputs.quantity("p-" + product.eventProductId, 0 + "", "str-item-quantity str-override", (product.hasOwnProperty("maxQuantity") ? product.maxQuantity : undefined));
html += "
";
html += " ";
html += " ";
html += " " + eventProduct.description + " ";
html += "
";
}
});
});
}
// ##########################################################################################################################
// ##########################################################################################################################
html += "
";
});
}
// ##############################################################################################################################
// ##############################################################################################################################
html += " ";
html += "
";
html += "
";
html += "";
html += "back ";
html += ((isExclusive && isGroups) || !canAddDiscountCode ? "" : "continue ");
html += "
";
//------------------------------------------------------------
//--- DEBUG
//------------------------------------------------------------
html += this.renderCodeDebug(code);
if (this.debugEventKey) {
html += "HAVE CODES: " + haveCodes + " :: HAVE EXCLUSIVE CODES: " + haveExclusiveCode + " :: IS EXCLUSIVE: " + isExclusive + " :: CAN ADD DISCOUNT: " + canAddDiscountCode + "
";
html += "" + JSON.stringify(code, null, 2) + "
";
}
//------------------------------------------------------------
//--- DEBUG
//------------------------------------------------------------
$("#str-navigation-title").html("Promo Code - " + code.code.toUpperCase());
$("[data-store-section='code']").html(html);
}
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
else {
if (this.debug) {
var btns = {};
var abtns = [];
$.each($store._eventInfo.codes, function (i, __code) {
btns[__code.code] = "" + __code.code + " ";
abtns.push(__code.code);
});
abtns.sort();
html += "
[ Available Promo Codes For Testing ] ";
$.each(abtns, function (i, abtn) {
html += btns[abtn];
});
html += " ";
html += "
";
html += "cancel
";
}
else {
html += "enter your promo code below and press continue
";
html += "
";
html += "back continue
";
}
$("#str-navigation-title").html("Promo Code");
$("[data-store-section='code']").html(html);
$(".str-section:visible").hide();
$("[data-store-section='code']").show();
$("#str-code").focus();
if (codeInput.length > 0) {
$store.processCode();
}
}
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
},
renderCodeDebug: function (code) {
var html = "";
if (this.debugEventKey) {
html = "";
html += " " + (code.haveProducts ? "PRODUCTS" : "NO PRODUCTS") + " :: ";
html += " " + (code.skipQuantities ? "SKIP" : "NO SKIP") + " :: ";
html += " " + code.exclusive + " :: ";
html += " " + code.discountCodeAmountType + " :: ";
html += " " + code.applyTo + " :: ";
html += " " + code.applyToType + " ";
html += "
";
}
return html;
},
clickCode: function (_code) {
$("#str-code").val(_code);
$store.processCode();
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
productPrice: function (product) {
var different = false;
var symbol = $store._eventInfo.currency.symbol;
var price = product.price;
if (price == undefined) {
$.each(product.variations, function (v, variation) {
if (price != undefined) {
different |= price != variation.price;
}
price = (price == undefined || parseFloat(price) > parseFloat(variation.price) ? variation.price : price);
});
}
return price;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
processCode: function (_code, _groupid) {
this.renderError();
// ##########################################################################################################################
// ##########################################################################################################################
if (_code) {
var haveGroupCount = false;
var haveProductCounts = false;
var haveProducts = false;
var skipQuantityCheck = false;
//console.clear();
console.info("--- processCode :: CODE ----------------------------------------");
console.info(_code);
console.info(_groupid);
$.each($store._eventInfo.codes, function (i, __code) {
if (__code.code == _code) {
var code = JSON.parse(JSON.stringify(__code));
var discountCodes = $store._store.codes();
console.info(discountCodes);
console.info(code);
var isAmount = code.discountCodeAmountType == "AMOUNT";
var isPercentage = code.discountCodeAmountType == "PERCENTAGE";
var isExclusive = code.exclusive == "EXCLUSIVE";
var isEach = code.applyTo == "EACH";
var isCollection = code.applyTo == "COLLECTION";
var isDefault = code.applyToType == "DEFAULT";
var isGroups = code.applyToType == "GROUPS";
haveProducts = code.haveProducts == 1;
console.info(code.haveProducts);
discountCodes[_code] = code;
if (!haveProducts || (isEach && isDefault)) {
console.info("--- SKIP QUANTITY CHECK ---");
skipQuantityCheck = true;
}
else {
if (isExclusive) {
$.each(code.groups, function (g, group) {
if (_groupid == undefined || _groupid == group.eventDiscountCodeGroupId) {
group["count"] = 1;
haveGroupCount = true;
$.each(group.products, function (p, product) {
product["count"] = product.quantity;
haveProductCounts = true;
});
}
else {
delete group["count"];
}
});
}
else {
$.each(code.groups, function (g, group) {
console.info("\t--- GROUP " + g + " -----------------------");
console.info(group);
var groupCount = $("[data-form-item-id='g-" + group.eventDiscountCodeGroupId + "']").html();
if (!isNaN(groupCount)) {
groupCount = parseInt(groupCount);
group["count"] = parseInt(groupCount);
haveGroupCount |= group.count > 0;
}
$.each(group.products, function (p, product) {
console.info("\t\t--- PRODUCT " + product.eventProductId + "-----------------------");
if (haveGroupCount) {
product["count"] = product.quantity;
haveProductCounts = true;
}
else {
var productCount = $("[data-form-item-id='p-" + product.eventProductId + "']").html();
if (!isNaN(productCount)) {
productCount = parseInt(productCount);
if (productCount > 0) {
product["count"] = (product.hasOwnProperty("maxQuantity") && product.maxQuantity < productCount ? product.maxQuantity : productCount);
haveProductCounts = true;
}
}
}
if (product.hasOwnProperty("count") && !group.hasOwnProperty("count")) {
group["count"] = 1;
}
});
});
}
}
$store._store.codes(discountCodes);
}
});
console.info("HAVE GROUPS: " + haveGroupCount + " HAVE PRODUCTS: " + haveProducts + " :: HAVE PRODUCT COUNT: " + haveProductCounts);
if (!haveProducts || (haveProductCounts && haveGroupCount) || skipQuantityCheck) {
$("[data-store-section='code']").html("");
$store.back(haveProducts ? "code" : "code");
}
else {
this.renderError("Make the necessary quantity choices prior to proceeding.");
}
}
// ##########################################################################################################################
// ##########################################################################################################################
else {
console.info("--- processCode :: INPUT ----------------------------------------");
var val = $("#str-code").val().toUpperCase();
var code = null;
$.each($store._eventInfo.codes, function (i, c) {
if (c.code.toUpperCase() == val) {
code = c;
}
});
if (code != null) {
$store.renderCode(code);
return;
}
this.renderError("The promo code you entered is not valid.");
}
// ##########################################################################################################################
// ##########################################################################################################################
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
clearCode: function (code) {
var codes = $store._store.codes();
delete codes[code];
$store._store.codes(codes);
$("[data-store-section='code']").html("");
$store.back("code");
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderInfo: function () {
if ($("[data-store-section='info']").length == 0) {
return "
";
}
console.warn("--- renderInfo ----------------------------------------");
var symbol = $store._eventInfo.currency.symbol;
var accountInfos = this._storage.store("accountInfos");
var infos = this._store.infos();
var html = "specify information for each ticket below
";
html += "" + this._form.required() + "
";
$.each(infos, function (ii, info) {
html += "";
for (var i = 0; i < info.quantity; i++) {
var price = info.price;
var different = false;
var accountInfo = accountInfos[info.eventProductId];
accountInfo = (accountInfo && accountInfo.length > i ? accountInfo = accountInfo[i] : null);
if (info.variations) {
$.each(info.variations, function (v, variation) {
if (variation.price) {
if (price != undefined) {
different |= price != variation.price;
}
else {
price = variation.price;
}
}
});
$.each(info.variations, function (v, variation) {
price = (price == undefined || price > variation.price ? variation.price : price);
});
}
price = (different ? "
from " : "") + $store._formatPrice(price);
html += "
";
html += " ";
html += " " + (info.quantity > 1 ? "(" + (i + 1) + ") " : "") + info.name + (info.uniqueAccount ? "(one per email address) " : "") + " ";
html += " ";
html += " ";
if (info.variations) {
var options = null;
var value = (accountInfo && accountInfo["variation"] ? accountInfo["variation"] : "");
$.each(info.variations, function (v, variation) {
options += "" + variation.name + (different ? " @ " + variation._price.priceTotal + (variation._price.breakdownTxt != null ? " (" + variation._price.breakdownTxt + ")" : "") : "") + " ";
});
html += "" + (info.variationLabel ? info.variationLabel : "Choose a ticket").toLowerCase() + " ";
html += "" + $store._store.inputs.choice(info.eventProductId, i + 1, options) + " ";
}
if (info.form) {
$.each(info.form.parts, function (pi, part) {
part["product"] = info.name;
var datas = undefined;
if (info.uniqueAccount && part.key == "emailAddress") {
datas = {
"unique": "emailAddress"
};
}
html += "" + part.name.toLowerCase() + " ";
html += "" + $store._form.render(info.eventProductId, i + 1, part, (accountInfo && accountInfo[part.key] ? accountInfo[part.key] : ""), datas) + " ";
});
}
if (info.options) {
$.each(info.options, function (oi, eventProductOption) {
html += "" + (eventProductOption.variationLabel ? eventProductOption.variationLabel : eventProductOption.name).toLowerCase() + " ";
if (eventProductOption.productType == "Option") {
var price = eventProductOption.price;
var different = false;
$.each(eventProductOption.variations, function (v, variation) {
if (variation.price) {
if (price != undefined) {
different |= price != variation.price;
}
else {
price = variation.price;
}
}
});
var value = (accountInfo && accountInfo[eventProductOption.eventProductId] ? accountInfo[eventProductOption.eventProductId] : "");
var options = null;
if (eventProductOption.requireResponse != true) {
options += " ";
}
$.each(eventProductOption.variations, function (v, variation) {
options += "" + variation.name + (different ? " @ " + variation._price.priceTotal + (variation._price.breakdownTxt != null ? " (" + variation._price.breakdownTxt + ")" : "") : "") + " ";
});
html += "" + $store._store.inputs.choice(info.eventProductId, i + 1, options, undefined, eventProductOption.eventProductId) + " ";
}
});
}
console.info(info);
if (i == 0 && info.quantity > 1 && info.allowCopyToAll != false) {
html += "copy to all \"" + info.name + "\" ";
}
else {
html += " ";
}
html += "
";
}
html += "
"
});
html += "back continue
";
html += $store.renderFbPixel("AddToCart");
$("[data-store-section='info']").html(html);
setTimeout($store._form.validate, 500);
},
renderGGEvent: function (event, price, comment) {
if (event == "PurchaseComplete") {
if ($store._eventInfo.hasOwnProperty("attributes") && $store._eventInfo.attributes.hasOwnProperty("ggGTMPurchaseComplete")) {
var ggGTMPurchaseComplete = $store._eventInfo.attributes.ggGTMPurchaseComplete;
console.info("renderGGEvent :: " + event + " :: " + ggGTMPurchaseComplete);
/*************** GTM -- Google Tag Manager ***************/
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', ggGTMPurchaseComplete);
/*************** GTM -- Google Tag Manager ***************/
}
}
},
renderFbPixel: function (event, price, comment) {
if (comment == undefined) {
comment = "";
}
//console.info("renderFbPixel :: " + event + " :: " + comment);
if (event != "AddToCart" && event != "RemoveFromCart") {
$store._store.activity.record(event, comment);
}
if ($store._eventInfo.hasOwnProperty("attributes") && $store._eventInfo.attributes.hasOwnProperty("fbPixel")) {
var args = "&dl=" + encodeURIComponent(window.location.href);
if (event == "Purchase" && price != undefined) {
args = "&cd[currency]=" + encodeURIComponent($store._eventInfo.currency.code.toUpperCase()) + "&cd[value]=" + encodeURIComponent(price);
}
return " ";
}
return "";
},
copyInfos: function (id, quantity) {
$("[data-form-item-id='" + id + "'][data-form-item-index='1']").each(function () {
for (var index = 2; index < quantity + 1; index++) {
$("[data-form-item-id='" + id + "'][data-form-item-index='" + index + "'][data-form-item-name='" + $(this).data("formItemName") + "']").val($(this).val());
}
});
$store._form.validate();
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderCart: function () {
//console.clear();
console.info("--- renderCart ----------------------------------------");
if ($("[data-store-section='cart']").length == 0) {
return "
";
}
var cart = this._store.cart();
var codes = $store._store.codes();
var html = "";
var subtotal = 0.0;
var discount = 0.0;
var fee = 0.0;
var tax = 0.0;
var billingName = undefined;
var billingEmail = undefined;
var billingPhone = undefined;
html += "Cart
";
html += "";
//console.clear();
console.warn("--------------------------------------------------------");
console.info("--- cart -----------------------------------------------");
$.each(cart, function (k, v) {
console.info(v);
});
if (Object.keys(codes).length > 0) {
$.each(codes, function (c, code) {
if (code.skipQuantities !== true && code.haveProducts) {
console.info("--- cartCode w/ Products ------------------------------------------");
console.info(code);
$.each(code.groups, function (g, group) {
for (var i = 0; i < group.count; i++) {
var _price = 0;
var _fee = 0;
var _tax = 0;
var _codeCartItems = {};
console.warn("\t" + code.code + " :: " + i);
html += "";
html += " ";
html += " ";
html += " ";
html += " " + code.code + "
";
html += " ";
html += (group._price.breakdown != null ? "" + group._price.breakdownTxt + "
" : "");
html += "";
console.info("\t\tgroup products ---------");
$.each(group.products, function (p, product) {
for (var j = 0; j < product.count; j++) {
var cartProduct = null;
$.each(cart, function (c, cartItem) {
if (cartProduct == null && cartItem.eventProductId == product.eventProductId && !cartItem.haveCode) {
cartItem.haveCode = true;
cartItem.haveGroupCode = true;
console.info(cartItem);
_codeCartItems[cartItem.id] = cartItem;
cartProduct = cartItem;
}
});
}
});
$.each(_codeCartItems, function (id, cartItem) {
var eventProductOptionsHtml = "";
if (cartItem.productOptionsInfos) {
eventProductOptionsHtml += "";
$.each(cartItem.productOptionsInfos, function (j, productOptionsInfo) {
if (productOptionsInfo.hasOwnProperty("_price")) {
_price += productOptionsInfo._price.price;
_fee += productOptionsInfo._price.fee;
_tax += productOptionsInfo._price.salesTax;
_haveOptions = true;
}
eventProductOptionsHtml += "
" + productOptionsInfo.label + (productOptionsInfo.hasOwnProperty("_price") && productOptionsInfo._price.breakdownTxt != null ? "
(" + productOptionsInfo._price.breakdownTxt + ")
" : "") + "
";
});
eventProductOptionsHtml += "
";
}
html += "" + cartItem.name + eventProductOptionsHtml + " ";
});
html += " ";
html += " ";
html += " ";
html += "
";
html += " ";
html += " " + $store._formatPrice(group._price.priceTotal + _price + _fee + _tax) + " ";
html += " ";
code["rendered"] = true;
subtotal += group._price.price;
fee += group._price.fee;
tax += group._price.salesTax;
}
});
}
});
}
console.warn("--------------------------------------------------------");
console.warn("--- cartItems ------------------------------------------");
$.each(cart, function (i, item) {
if (!item.haveCode || !item.haveGroupCode) {
console.warn("--- LINE ITEM ---");
console.info(item);
console.info(item._price);
var _breakdown = item._price.maxBreakdown;
var _price = item._price.maxPrice;
var _fee = item._price.maxFee;
var _tax = item._price.maxSalesTax;
var _priceTotal = 0;
var _haveOptions = false;
if (item.haveCode) {
_breakdown = item._price.breakdownTxt;
_price = item._price.price;
_fee = item._price.fee;
_tax = item._price.salesTax;
}
$store.renderFbPixel("AddToCart", undefined, item.name);
if (item.hasOwnProperty("accountInfo")) {
if (billingName == undefined && item.accountInfo.hasOwnProperty("name") && item.accountInfo.name != null && item.accountInfo.name.trim().length > 0) {
billingName = item.accountInfo.name;
}
if (billingEmail == undefined && item.accountInfo.hasOwnProperty("emailAddress") && item.accountInfo.emailAddress != null && item.accountInfo.emailAddress.trim().length > 0) {
billingEmail = item.accountInfo.emailAddress;
}
if (billingPhone == undefined && item.accountInfo.hasOwnProperty("phoneNumber") && item.accountInfo.phoneNumber != null && item.accountInfo.phoneNumber.trim().length > 0) {
billingPhone = item.accountInfo.phoneNumber;
}
}
var eventProductOptionsHtml = "";
if (item.productOptionsInfos) {
eventProductOptionsHtml += "";
$.each(item.productOptionsInfos, function (j, productOptionsInfo) {
if (productOptionsInfo.hasOwnProperty("_price")) {
_price += productOptionsInfo._price.price;
_fee += productOptionsInfo._price.fee;
_tax += productOptionsInfo._price.salesTax;
_haveOptions = true;
}
eventProductOptionsHtml += "
" + productOptionsInfo.label + (productOptionsInfo.hasOwnProperty("_price") && productOptionsInfo._price.breakdownTxt != null ? "
(" + productOptionsInfo._price.breakdownTxt + ")
" : "") + "
";
});
eventProductOptionsHtml += "
";
}
_priceTotal += _price + _fee + _tax;
console.info("\t\t_price: " + _price + "\tfee: " + _fee + "\ttax: " + _tax)
html += "";
html += " " + item.name + (_breakdown != null ? "(" + _breakdown + ")
" : "") + eventProductOptionsHtml + " ";
html += "" + $store._formatPrice(_priceTotal) + " ";
html += " ";
subtotal += _price;
fee += _fee;
tax += _tax;
}
});
if (Object.keys(codes).length > 0) {
$.each(codes, function (c, code) {
if (code.rendered !== true) {
console.info("--- cartCode w/o Products ------------------------------------------");
console.info(code);
if (!code.haveProducts && code.discountCodeAmountType == "AMOUNT") {
discount += code.price;
}
}
});
}
var haveBalance = parseFloat(subtotal - discount) > 0.00;
console.info("haveBalance: " + haveBalance);
subtotal = parseFloat(subtotal).toFixed(2);
discount = parseFloat(discount).toFixed(2);
fee = (haveBalance ? parseFloat(fee).toFixed(2) : 0.00);
var total = parseFloat(parseFloat(subtotal) + parseFloat(fee) + parseFloat(tax)).toFixed(2);
if (this.debug && subtotal > 0) {
console.info("subtotal: " + subtotal);
console.info("discount: " + discount);
console.info(" fee: " + fee);
console.info(" tax: " + tax);
console.info(" ----------------");
console.info(" total: " + total);
html += " ";
html += "SUBTOTAL " + $store._formatPrice(subtotal) + " ";
html += (haveBalance ? "CONVENIENCE FEE " + $store._formatPrice(fee) + " " : "");
html += (tax > 0.0 ? "SALES TAX " + $store._formatPrice(tax) + " " : "");
}
html += (discount > 0.0 ? "DISCOUNT " + $store._formatPrice((discount * -1)) + " " : "");
html += " ";
html += "TOTAL " + $store._formatPrice(total - discount) + " ";
html += "
";
html += $store.renderFbPixel("InitiateCheckout");
$store._storage.store("store-totals", {
subtotal: subtotal,
discount: discount,
fee: fee,
tax: tax,
total: total
});
$("[data-store-section='cart']").html("" + html + "" + this.renderPayment(billingName, billingEmail, billingPhone) + "
");
if (haveBalance) {
$store._store.paymentService.populate();
}
setTimeout($store._form.validate, 500);
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
_formatPrice: function (_price) {
return $store._eventInfo.currency.symbol + parseFloat(_price).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
}
,
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
_paymentFields: [
{
"ordering": 1,
"formPartType": "text",
"name": "Name on Credit Card",
"choices": [],
"required": true,
"key": "name",
"onblur": " onblur=\"$store._store.activity.record('CheckoutFullName', this.value)\""
}, {
"ordering": 2,
"formPartType": "email",
"name": "e-mail address",
"choices": [],
"required": true,
"key": "emailAddress",
"onblur": " onblur=\"$store._store.activity.record('CheckoutEmailAddress', this.value)\""
}, {
"ordering": 3,
"formPartType": "phone",
"name": "cellphone number",
"choices": [],
"required": true,
"key": "phoneNumber",
"onblur": " onblur=\"$store._store.activity.record('CheckoutPhoneNumber', this.value)\""
}
],
_purchaseFields: [
{
"ordering": 1,
"formPartType": "text",
"name": "full name",
"choices": [],
"required": true,
"key": "name",
"onblur": " onblur=\"$store._store.activity.record('CheckoutFullName', this.value)\""
}, {
"ordering": 2,
"formPartType": "email",
"name": "e-mail address",
"choices": [],
"required": true,
"key": "emailAddress",
"onblur": " onblur=\"$store._store.activity.record('CheckoutEmailAddress', this.value)\""
}, {
"ordering": 3,
"formPartType": "phone",
"name": "cellphone number",
"choices": [],
"required": true,
"key": "phoneNumber",
"onblur": " onblur=\"$store._store.activity.record('CheckoutPhoneNumber', this.value)\""
}
],
renderPayment: function (billingName, billingEmail, billingPhone) {
$store.processingPayment = false;
var html = "";
var haveBalance = parseFloat($store._storage.store("store-totals").total) > 0.00;
$.each((haveBalance ? this._paymentFields : this._purchaseFields), function (pi, part) {
var val = "";
switch (part.key) {
case "name":
val = (billingName != undefined ? billingName : "");
if (val != null && val.trim().length != 0) $store._store.activity.record('CheckoutFullName', val);
break;
case "emailAddress":
val = (billingEmail != undefined ? billingEmail : "");
if (val != null && val.trim().length != 0) $store._store.activity.record('CheckoutEmailAddress', val);
break;
case "phoneNumber":
val = (billingPhone != undefined ? billingPhone : "");
if (val != null && val.trim().length != 0) $store._store.activity.record('CheckoutPhoneNumber', val);
break;
}
html += "" + part.name.toLowerCase() + " ";
html += "" + $store._form.render("paymentInfo-" + part.key, 0, part, val, undefined, part.onblur) + " ";
});
if (haveBalance) {
html += "credit card information ";
html += "" + $store._store.paymentService.render() + " ";
}
var ret = "";
ret += "" + (haveBalance ? "Payment Information" : "Purchase Information") + "
";
ret += "" + this._form.required() + "
";
ret += "";
ret += "back complete purchase
";
ret += "- processing purchase -
";
return ret;
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
processPayment: function () {
if ($store._form.validate()) {
console.warn("--- processPayment :: IN -------------------------------------------------------");
var haveBalance = parseFloat($store._storage.store("store-totals").total) > 0.00;
$("#str-buttons-payment").hide();
$("#str-message-payment").show();
if (haveBalance) {
console.info(haveBalance);
$store._store.paymentService.token();
}
else {
$store._store.processPurchase();
}
console.warn("--- processPayment :: OUT -------------------------------------------------------");
}
else {
this.renderError("Provide all required payment information.");
if ($store.debug) {
$store._store.processPurchase("-bob=");
}
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
renderCompleted: function () {
if ($("[data-store-section='cart']").length == 0) {
return "
";
}
var html = "";
html += "";
html += "
Thank you for your purchase!
";
html += "
Your order has been successfully processed.
";
html += "
Your order number is " + $store._eventInfo.receipt.id + " .
";
html += "
";
html += "
You should receive a purchase receipt email within the next 5 minutes. If you do not, please check your Spam folder! Mark the email as safe if it landed there so your purchase details are easily accessible in your inbox for the event.
";
/*html += "
";*/
html += "
We hope you enjoy the event!
";
html += "
";
html += "done
";
html += $store.renderFbPixel("Purchase", $store._storage.store("store-totals").total);
$store._storage.store("store", {});
$store._storage.store("accountInfos", {});
$store._storage.store("cart-quantities", {});
$store._storage.store("store-codes", {});
$store.renderTickets();
$("[data-store-section='completed']").html(html);
$store.renderGGEvent("PurchaseComplete");
$store._store.activity.clearUniqueId();
},
formatDates: function (json, which, pre) {
if (json) {
var start = (json.hasOwnProperty("availableStartDate") && (which == null || which == "availableStartDate") && json.availableStartDate != null ? json.availableStartDate : (json.hasOwnProperty("startDate") && json.startDate != null ? json.startDate : null));
var end = (json.hasOwnProperty("availableEndDate") && (which == null || which == "availableStartDate") && json.availableEndDate != null ? json.availableEndDate : (json.hasOwnProperty("endDate") && json.endDate != null ? json.endDate : null));
if (start == null && which != undefined) {
start = json[which];
end = json[which];
}
if ((start != null && !start.hasOwnProperty("year")) || (end != null && !end.hasOwnProperty("year"))) {
return "";
}
if (start != null && end != null) {
if (start.year.name == end.year.name) {
if (start.month.id == end.month.id) {
if (start.day.id == end.day.id) {
return "" + start.month.short + " " + start.day.name + ", " + start.year.name + " ";
}
else {
return "" + start.month.short + " " + start.day.name + "-" + end.day.name + ", " + start.year.name + " ";
}
}
else {
return "" + start.month.short + " " + start.day.name + " - " + end.month.short + " " + end.day.name + ", " + end.year.name + " ";
}
}
else {
return "" + start.month.short + " " + start.day.name + ", " + start.year.name + " - " + end.month.short + " " + end.day.name + ", " + end.year.name + " ";
}
}
else if (start != null) {
return "" + (pre != undefined ? pre : "from") + " " + start.month.short + " " + start.day.name + ", " + start.year.name + " "
}
else if (end != null) {
return "" + (pre != undefined ? pre : "until") + " " + end.month.short + " " + end.day.name + ", " + end.year.name + " "
}
return "no dates available ";
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
render: function (type) {
console.info("--- render :: " + type);
switch (type) {
//---------------------------------------------------------------------------------------------------
case "receipt":
this.next();
$("#str-message-payment").hide();
$("#str-buttons-payment").show();
break;
case "error":
this.renderError("Error occurred processing payment. " + $store._eventInfo.error.error);
$("#str-message-payment").hide();
$("#str-buttons-payment").show();
break;
case "uniqueCheck":
if ($store._eventInfo.uniqueCheck.status != "success") {
this.renderError($store._eventInfo.uniqueCheck.status);
}
else {
$store.nextTo("cart", "Checkout");
$store.renderCart();
}
break;
}
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
content: function (html) {
$("#store-" + $store._conf._eventKey).html("" + html + "
");
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
data: function (type, data) {
console.info("--- data :: " + type);
console.info(data);
this._eventInfo[type] = data;
this.render(type);
},
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
// @formatter:off
style: {
".str": "max-width: 800px;margin:7px auto !important;border: 1px solid #aaa;border-radius: 7px;padding: 7px !important;background-color:#fff;color:#333;box-shadow:#ccc 0px 0px 6px;",
".str, .str *": "font:12pt Arial;",
".str a": "color:inherit !important;font-size:inherit !important;",
".str table": "border-spacing: 0px;border-collapse: separate;width:100%;margin:0 0 0 0 !important;border:none;",
".str table tr td": "border:0px;padding:0 7px;text-align:left;",
".str img": "max-width:98%;margin:1px 1%;border-radius:4px;",
".str svg": "max-width:26px;height:26px;margin:2px;",
".str button": "text-align:center;color:inherit;border:1px solid #aaa;background-color:#eee;font-size:90%;border-radius:3px;padding:1px 10px;cursor:pointer;",
".str input, .str select": "padding:10px 2%;width:96% !important;border:1px solid #bbb;border-radius:3px;color:#333;box-sizing:border-box;",
".str ul": "margin:0px;padding:5px 5px 5px 25px;",
".str ul li": "list-style-type: square;margin-top:2px;",
".str .str-hidden": "display:none !important;",
".str .str-noselect": "-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;",
".str .str-buttons": "text-align:center;padding-top:10px;",
".str .str-buttons button,.str .str-buttons-button": "padding:10px 30px;margin:5px 3px;",
".str .str-buttons button.str-back": "border:1px solid #ccc;background-color:#fff;",
".str .str-buttons-remove": "vertical-align: top;width: 1%;padding:5px;",
".str .str-buttons-remove button": "padding:3px 7px 0px 7px;background-color:rgba(200,0,0,.15);border:1px solid #900 !important;text-align:center;",
".str .str-buttons-remove button *": "color:#900;margin-right:0px;",
".str .str-buttons-remove button svg": "height:20px;",
".str .str-message": "display:none;text-align:center;padding:20px;font-style:italic;color:rgb(200,0,0);font-size:90%;",
".str .str-event-info": "text-align:center;background-color:#999;color:#fff;margin:auto;margin-top:-7px;margin-bottom:10px;max-width:85%;font-size:70%;padding:5px; border-radius:0 0 7px 7px;",
".str .str-event-info>div": "text-align:center;font-size:70%;font-style:italic;margin-top:3px;display:none;",
".str .str-navigation": "width:100%;border-bottom:0px solid #999;margin-bottom:10px;padding-bottom:5px;",
".str .str-navigation tr td": "text-align:center;padding:4px;",
".str .str-navigation tr td.str-title": "font-size:120%;",
".str .str-navigation tr td:first-child, .str .str-navigation tr td:last-child": "width:30px;",
".str .str-error": "text-align:center;border:1px solid rgba(200,0,0,.1);border-radius:5px;background-color:rgba(200,0,0,.05);color:rgb(200,0,0);padding:5px;font-style:italic;font-size:85%;margin-bottom:5px;display:none;",
".str .str-instructions": "font-size:75%;text-align:center;font-style:italic;color:#aaa;padding:5px;",
".str .str-item-exclusive": "color:#900;background-color:rgba(200,0,0,.08);margin:0px 15px;padding:3px 5px;font-style:italic;font-size:60%;display:inline-block;border-radius:5px;",
".str .str-item-exclusive.full": "font-size:90%;display:block;text-align:center;padding:10px;",
".str .str-section": "display:none",
".str .str-section-heading": "font-size:120%;margin:20px 2px 2px 2px;",
".str .str-section-heading:first-child": "margin-top:2px",
".str .str-ticket-groups": "color:#000;background-color:#ddd;border:1px solid #bbb;border-radius:5px;margin:6px 0;padding:10px;box-shadow:#ccc 2px 2px 8px;cursor:pointer;",
".str .str-tickets": "border:1px solid #bbb;border-radius:5px;margin:0 0 15px 0;padding-bottom:10px;box-shadow:#ccc 2px 2px 8px;",
".str .str-tickets .str-ticket-group-name": "color:#000;background-color:#ddd;padding:10px;border-radius:5px 5px 0 0;",
".str .str-ticket-group": "border: 1px solid #ccc;padding: 5px;border-radius: 5px;margin:20px 0;",
".str .str-ticket": "border-width:0px;border-top:1px solid #ccc;width:100%;cursor:pointer;margin:4px;",
".str .str-ticket:first-child": "border-top:none;",
".str .str-item-promo-code": "background-color:#ddd;background-color:rgba(187, 85, 0,.2);border:1px solid #b50 !important;width:23px;border-radius:8px;vertical-align:middle;",
".str .str-item-promo-code > div": "transform: rotate(-90deg);font-size:55%;text-align:center;color:#b50;",
".str .str-item-promo-code-code": "padding:15px 5px 5px 20px;font-size:110%;",
".str .str-item-promo-code-important ": "color:#444;padding-top:15px;font-size:80%!important;",
".str .str-item-promo-code-important span": "color:#700 !important;text-decoration:underline;background-color:rgba(200,0,0,.1) !important;padding:2px 5px;margin-right:5px;border-radius:5px;",
".str .str-ticket .str-item-image": "vertical-align:middle;padding:5px;width:1%;",
".str .str-ticket .str-item-image img": "max-width:100px;max-height:100px;",
".str .str-ticket .str-item-name": "font-size:130%;padding:10px;",
".str .str-ticket .str-item-count": "font-size:70%;padding-left:10px;opacity:.8;font-style:italic;",
".str .str-ticket .str-item-unique": "font-size:75%;margin-left:5px;font-style:italic;",
".str .str-ticket .str-item-price": "white-space:nowrap;text-align:right;font-size:120%;padding:5px;vertical-align:top;width:1%;",
".str .str-ticket .str-item-price .str-item-price-from": "font-size:65%;opacity:.6;margin-right:10px;",
".str .str-ticket .str-item-price .str-item-count": "font-size:65%;opacity:.6;margin-right:10px;",
".str .str-ticket .str-price-breakdown": "font-size:65%;opacity:.60;font-style:italic;margin:2px;margin-top:5px;",
".str .str-ticket .str-price-breakdown .str-item-price-original": "font-size:90%;opacity:.8;font-style:inherit;",
".str .str-ticket .str-item-price-original": "font-size:100%;text-decoration: line-through;margin:0 2px;",
".str .str-ticket .str-item-price-discount": "text-align:center;font-size:110%;padding:10px;vertical-align:top;width:1%;",
".str .str-ticket .str-item-price-discount > *": "opacity:.7",
".str .str-ticket .str-item-description": "padding:5px 15px 0 15px;font-size:85%;font-style:italic;color:#555;opacity:.9;",
".str .str-ticket .str-item-description *": "font-size:inherit;font-style:inherit;border:none;",
".str .str-ticket .str-item-description > *": "max-width:98%;",
".str .str-ticket .str-item-quantity": "text-align:center;display:inline-block;margin:20px 0 0 0;float:right;background-color:rgba(255,255,255,.75);border:1px solid #eee;border-radius:5px;",
".str .str-ticket .str-item-quantity tr td": "padding:5px;font-size:140%;font-weight:300;font-style:normal;",
".str .str-ticket .str-item-quantity tr td:first-child,.str .str-ticket .str-item-quantity tr td:last-child ": "text-align:center;font-size:140%;opacity:.7;",
".str .str-ticket .str-item-quantity tr td svg ": "cursor:pointer;",
".str .str-ticket .str-item-heading": "padding:5px 15px 0 15px;font-size:85%;font-style:italic;color:#555;",
".str .str-item-items": "padding:10px 0 10px 15px;",
".str .str-item-items>div": "font-weight:bold;",
".str .str-item-items>div>span": "font-weight:normal;font-size:70%;margin-left:10px;font-style:italic;",
".str .str-item-items>div>div": "font-weight:normal;color:#777",
".str .str-item-items>div>div>p": "margin:0px 10px;font-size:85%;",
".str .str-code-link": "text-align:left;cursor:pointer;xtext-shadow: 1px 1px 3px #aaa;color:inherit;padding:0 15px;font-weight:bold;font-size:80%;",
".str .str-code-link strong": "color:#111;xtext-shadow: 1px 1px 3px #666;font-size:110%;font-weight:bold;",
".str .str-code-link.str-code-link-bottom": "margin-top:20px;",
".str .str-code": "padding:10px;text-align:center;",
".str .str-code input": "text-align:center;",
".str .str-item-label": "width:100%;font-size:85%;font-style:italic;padding:7px 7px 3px 7px;color:#999;",
".str .str-item-text": "width:100%;",
".str .str-item-full>*": "width:100% !important;",
".str .str-item-shaded": "background-color:#f0f0f0;",
".str .str-divider": "border-top:2px solid #bbb;padding:0px;",
".str .str-cart": "font-size:90%;font-weight:normal;border:1px solid #bbb;border-radius:5px;padding:10px;",
".str .str-sub-heading": "font-size:120%;border-bottom:1px solid #aaa;padding:5px;background-color:#eee;text-align:center;margin-top:15px;",
".str .str-sub-heading:first-child": "margin-top:0px;",
".str .str-cart .str-cart-item": "padding:6px 5px 4px 5px;border-top:1px solid #d1d1d1;",
".str .str-cart .str-cart-item .str-promo-code": "margin-right: 5px;padding:2px 7px;font-style: italic;font-size: 80%;background-color:rgba(187, 85, 0,.2);color:#b50;border:1px solid #b50;border-radius:5px;",
".str .str-cart .str-cart-item-name": "",
".str .str-cart .str-cart-item-name .str-price-breakdown":"font-size:65%;opacity:.6;font-style:italic;margin:5px 5px 5px 20px;display:inline-block;float:right;",
".str .str-cart .str-cart-item-price": "text-align:right;white-space:nowrap;width:1%;padding-right:3px;padding-top:8px;vertical-align:top;",
".str .str-cart .str-cart-total": "white-space:nowrap;width:1%;font-size:90%;text-align:right;padding-right:5px;padding-left:80px;padding-top:8px;font-size:70%;color:#999;",
".str .str-completed div": "margin:10px 0;",
".str .str-completed .str-completed-thankyou": "font-size:120%;",
".str .str-completed .str-completed-order-number": "font-size:120%;font-weight:bolder;",
".str .str-completed .str-completed-receipt": "border:1px solid #aaa;padding:10px;display:inline-block;text-decoration: none;margin:15px;",
".str .str-completed .str-completed-instruction": "font-size:85%;",
".str .str-completed .str-completed-enjoy": "font-size:120%;font-weight:bold;color:#111;text-align:center;",
".str .str-form-item-required": "background-color:rgba(221, 119, 0, .05);border:1px solid #aaa;",
".str-card-elements > div": "border:1px solid #999;border-radius: 4px;background-color: white;box-shadow: none;width:15% !important;display:inline-block;margin:1px;",
"#pay-theory-credit-card-number": "width:50% !important;",
".str-card-elements > div .field-wrapper > iframe": "height:35px;",
".str .StripeElement ": "box-sizing: border-box;padding: 13px;border: 1px solid #999;border-radius: 4px;background-color: white;box-shadow: none;-webkit-transition: box-shadow 150ms ease;transition: box-shadow 150ms ease;",
".str .StripeElement--focus ": "box-shadow: none",
".str .StripeElement--invalid ": "border-color: #fa755a;",
".str .StripeElement--webkit-autofill ": " background-color: #fefde5 !important;",
},
css: function () {
var css = "";
$.each(this.style, function (k, v) {
css += k + "{" + v + "} ";
});
$("").appendTo("head");
},
_svg: {
plus:" ",
minus:" ",
trash:" ",
thin: {
plus:" ",
minus:" ",
trash:" "
}
},
// @formatter:on
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
// @formatter:off
_eventInfo: { "codes": [ { "applyTo": "EACH", "code": "LOVE", "applyToType": "DEFAULT", "price": "100.00", "discountCodeType": "MANUAL", "groups": [{ "maxQuantity": 1, "products": [ { "maxQuantity": 2, "eventProductId": 13093 }, { "maxQuantity": 10, "eventProductId": 13091 } ] }], "exclusive": "NON-EXCLUSIVE", "isPackage": false, "maxUsageCounts": 3000, "discountCodeAmountType": "PERCENTAGE", "eventDiscountCodeId": 2429 }, { "applyTo": "EACH", "code": "WEDDING", "applyToType": "DEFAULT", "price": "100.00", "discountCodeType": "MANUAL", "groups": [{ "maxQuantity": 1, "products": [ { "maxQuantity": 10, "eventProductId": 13091 }, { "maxQuantity": 2, "eventProductId": 13093 } ] }], "exclusive": "NON-EXCLUSIVE", "isPackage": false, "maxUsageCounts": 3000, "discountCodeAmountType": "PERCENTAGE", "eventDiscountCodeId": 2430 } ], "paymentService": { "uid": "acct_1QybliGH8Zw8XFOq", "jsApiUrl": "https://js.stripe.com/v3/", "name": "Stripe", "active": false, "serviceInstanceId": 9, "publicKey": "pk_live_7nlSMNC5CczWf6uwLsZ6Khhs", "serviceId": 21 }, "currency": { "symbol": "$", "code": "usd", "dollarAmount": "0.00", "name": "USD ($)", "id": 1, "percentageAmount": "0.000" }, "attributes": { "fbPixel": "422670756028064", "makeWebhookId": "0-1", "makeAuthApiKey": "maDajBZQ8tsL8S1MZ*QdLWwbol0dkWwAJNke" }, "event": { "eventId": 1745, "name": "2026/08/09 - Knoxville TN - Pink Bride", "producer": { "phone": "+1 (423) 309-1476", "name": "The Pink Bride Wedding and Women's Expo", "email": "info@thepinkbride.com" }, "startDate": "August 9, 2026 @ 4:00PM" }, "salesTax": "0.000", "storeProductOrdering": "priceAscendingNameAscending", "eventStoreFee": "Processing Fee", "enabled": true, "eventStoreButton": "buy tickets", "products": [ { "minPurchaseQuantity": 0, "maxPurchaseQuantity": 0, "variationLabel": "", "ordering": 1, "allowCopyToAll": true, "description": "Only select/purchase this ticket for an engaged bride/groom only! Your emailed receipt is your ticket into the show.<\/strong><\/p>", "requireResponse": false, "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" }, "form": { "code": "dbd054aaa69ae", "stage": "", "parts": [ { "ordering": 1, "formPartType": "text", "name": "Full Name", "choices": [], "required": true, "key": "name" }, { "ordering": 2, "formPartType": "email", "name": "e-Mail Address", "choices": [], "required": true, "key": "emailAddress" }, { "ordering": 4, "formPartType": "phone", "name": "Phone Number", "choices": [], "required": true, "key": "phoneNumber" }, { "ordering": 6, "formPartType": "choice", "name": "Have Wedding Date?", "choices": [ { "aux1": "", "ordering": 1, "label": "Yes", "value": "true" }, { "aux1": "", "ordering": 2, "label": "No", "value": "false" } ], "required": true, "key": "weddingDateProvided" }, { "parentKey": "weddingDateProvided", "ordering": 7, "formPartType": "date", "name": "Wedding Date", "choices": [], "parentChoiceKey": "true", "required": true, "key": "weddingDate" } ], "formTypeId": 1, "name": "Store Default", "key": "storeAttendeeInfo" }, "price": "0.00", "variations": [], "formName": "storeAttendeeInfo", "options": [], "eventProductId": 13093, "name": "Engaged Bride/Groom Ticket", "productType": "Ticket" }, { "minPurchaseQuantity": 0, "maxPurchaseQuantity": 0, "variationLabel": "", "ordering": 1, "allowCopyToAll": true, "description": "Purchase guest admission tickets here! For engaged couples and their guests please use the tickets labeled \"Engaged Bride/Groom Ticket\".<\/em><\/strong><\/p>Your emailed receipt is your ticket into the show.<\/strong><\/p>", "requireResponse": false, "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" }, "price": "0.00", "variations": [], "formName": "storeGuestInfo", "options": [], "eventProductId": 13091, "name": "General Admission Tickets", "productType": "Ticket" }, { "minPurchaseQuantity": 0, "maxPurchaseQuantity": 0, "variationLabel": "", "ordering": 1, "allowCopyToAll": true, "description": "VIP Bride Bundle: <\/em><\/strong><\/p>· Bride Ticket<\/em><\/strong><\/p>· 4 Guest Tickets<\/em><\/strong><\/p>· Bride Swag Bag (includes 5 goodies)<\/em><\/strong><\/p>· VIP Exclusive Promos and Giveaways<\/em><\/strong><\/p>· *Nashville Show Only* - Reserved seating for the Fashion Runway Show<\/em><\/strong><\/p>", "requireResponse": false, "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "2.00", "dollarAmountOther": "0.00", "name": "Default", "percentageAmount": "0.040", "percentageAmountOtherType": "default" }, "form": { "code": "dbd054aaa69ae", "stage": "", "parts": [ { "ordering": 1, "formPartType": "text", "name": "Full Name", "choices": [], "required": true, "key": "name" }, { "ordering": 2, "formPartType": "email", "name": "e-Mail Address", "choices": [], "required": true, "key": "emailAddress" }, { "ordering": 4, "formPartType": "phone", "name": "Phone Number", "choices": [], "required": true, "key": "phoneNumber" }, { "ordering": 6, "formPartType": "choice", "name": "Have Wedding Date?", "choices": [ { "aux1": "", "ordering": 1, "label": "Yes", "value": "true" }, { "aux1": "", "ordering": 2, "label": "No", "value": "false" } ], "required": true, "key": "weddingDateProvided" }, { "parentKey": "weddingDateProvided", "ordering": 7, "formPartType": "date", "name": "Wedding Date", "choices": [], "parentChoiceKey": "true", "required": true, "key": "weddingDate" } ], "formTypeId": 1, "name": "Store Default", "key": "storeAttendeeInfo" }, "price": "40.00", "variations": [], "formName": "storeAttendeeInfo", "options": [], "eventProductId": 13123, "name": "VIP Bride Bundle", "productType": "Ticket" } ] },
_conf: { _uri:"https://www.bridescan.com", _authKey:"jmi", _eventKey:"knox" },
_store: { init: function (storeInfo) { if (!this.initialized) { console.info("### STORE :: init :: --------------------------------------------------------------------------------------------------------------"); console.info(storeInfo); if (storeInfo.hasOwnProperty("paymentService")) { this["paymentService"] = (storeInfo.paymentService.name == "Stripe" ? this.stripe : this.paytheory); $("head").append(""); } $.each(storeInfo.products, function (i, p) { if (p.hasOwnProperty("variations") && p.variations.length == 0) { delete p.variations; } }); $store._storage.store("store", {}); if (!$store._storage.store("cart-quantities")) { $store._storage.store("cart-quantities", {}); } this["initialized"] = true; if (this.hasOwnProperty("paymentService")) { setTimeout(this.paymentService.init, 2000); } } }, update: function () { console.clear(); console.warn("---------------------------------------------------------------------"); console.warn("### STORE :: update :: " + this._eventKey); var store = $store._storage.store("store"); var codes = $store._store.codes(); $("[data-store='" + this._eventKey + "']").each(function () { var id = $(this).data("formItemId"); var index = $(this).data("formItemIndex"); var name = $(this).data("formItemName"); var type = $(this).data("formItemType"); var val = $(this).val(); if (name == "quantity") val = $(this).html(); console.info(id + " :: " + index + " :: " + name + " :: " + type + " :: " + val); if (val != null && val != 0 && val.length == 0) val = null; if (!store.hasOwnProperty(id)) { store[id] = {id: id}; } if (index) { if (!store[id].hasOwnProperty("infos")) { store[id]["infos"] = {}; } if (!store[id].infos.hasOwnProperty(index)) { store[id].infos[index] = {}; } if (val) store[id].infos[index][name] = val; else delete store[id].infos[index][name]; } else { if (val) store[id][name] = (type == "number" ? parseInt(val) : val); else delete store[id][name]; } }); $.each(store, function (pid, storeProduct) { delete storeProduct["discountCode"]; delete storeProduct["discountCount"]; delete storeProduct["discountAmount"]; delete storeProduct["discountAmountType"]; }); $.each(codes, function (c, code) { console.info("-----------------------------"); console.info(code); if (code.groups.length == 0) { if (code.exclusive != "EXCLUSIVE" || code.discountCodeAmountType == "PERCENTAGE") { $.each(store, function (pid, storeProduct) { if (!storeProduct.hasOwnProperty("discountCount")) { storeProduct["discountCode"] = code.code; storeProduct["discountCount"] = storeProduct.quantity; storeProduct["discountAmount"] = code.price; storeProduct["discountAmountType"] = code.discountCodeAmountType; } }); } } else { $.each(code.groups, function (c, group) { if ((group.hasOwnProperty("count") && group.count > 0) || code.skipQuantities) { $.each(group.products, function (c, product) { if ((product.hasOwnProperty("count") && product.count > 0) || code.skipQuantities) { if (code.skipQuantities) { if (store.hasOwnProperty(product.eventProductId)) { if (store[product.eventProductId].quantity > 0) { store[product.eventProductId]["discountCode"] = code.code; store[product.eventProductId]["discountCount"] = (product.hasOwnProperty("maxQuantity") && product.maxQuantity < store[product.eventProductId].quantity ? product.maxQuantity : store[product.eventProductId].quantity); store[product.eventProductId]["discountAmount"] = code.price; store[product.eventProductId]["discountAmountType"] = code.discountCodeAmountType; group["count"] = 1; product["count"] = store[product.eventProductId]["discountCount"]; } } } else { store[product.eventProductId].quantity += product.count * group.count; } } }); } }); } }); console.info("--- STORE -------------------------------"); console.info(store); $.each(store, function (k, v) { if (v.quantity > 0) console.info("\t\t" + k + " :: " + JSON.stringify(v)); }); console.info(codes); console.info("--- STORE -------------------------------"); $store._storage.store("store", store); $store._store.codes(codes); accountInfos = {}; $.each(store, function (i, item) { if (item.hasOwnProperty("infos")) { $.each(item.infos, function (i, info) { var accountInfo = JSON.parse(JSON.stringify(info)); if (!accountInfos.hasOwnProperty(item.id)) { accountInfos[item.id] = []; } accountInfos[item.id].push(accountInfo); }); } }); if (Object.keys(accountInfos).length > 0) { console.info("--- ACCOUNT INFOS -------------------------------"); console.info(accountInfos); console.info("--- ACCOUNT INFOS -------------------------------"); $store._storage.store("accountInfos", accountInfos); } console.warn("---------------------------------------------------------------------"); }, infos: function () { console.warn("---------------------------------------------------------------------"); console.info("### STORE :: infos :: " + this._eventKey); var products = []; var storeInfo = $store._eventInfo; var store = $store._storage.store("store"); $.each(store, function (id, item) { if (item.quantity > 0) { var product = null; $.each(storeInfo.products, function (ip, p) { if (p.eventProductId == id) product = p; }); if (product && (product.hasOwnProperty("form") || product.hasOwnProperty("variations"))) { console.info(product); var p = {eventProductId: product.eventProductId, variationLabel: product.variationLabel, name: product.name, price: product.price, quantity: item.quantity, form: product.form, allowCopyToAll: true}; if (product.hasOwnProperty("variations")) { p["variations"] = product.variations; } if (product.hasOwnProperty("options")) { p["options"] = product.options; } if (product.hasOwnProperty("uniqueAccount")) { p["uniqueAccount"] = product.uniqueAccount; } if (product.hasOwnProperty("allowCopyToAll")) { p["allowCopyToAll"] = product.allowCopyToAll; } products.push(p); } } }); return (products.length != 0 ? products : null) }, codes: function (codes) { if (codes) $store._storage.store("store-codes", codes); return $store._storage.store("store-codes"); }, cart: function () { console.clear(); console.warn("---------------------------------------------------------------------------------------------------------"); console.warn("---------------------------------------------------------------------------------------------------------"); console.warn("### STORE :: cart"); var cart = []; var storeInfo = $store._eventInfo; var store = $store._storage.store("store"); $.each(store, function (id, item) { var product = null; $.each(storeInfo.products, function (ip, p) { if (p.eventProductId == id) product = p; }); if (product) { if (item.quantity > 0) { console.warn("- - - - - -"); console.info(item); console.info(product); } var usedDiscount = 0; var availableDiscount = (item.hasOwnProperty("discountCount") ? item.discountCount : 0); var discountAmount = (item.hasOwnProperty("discountAmount") ? item.discountAmount : null); var isDiscountAmount = item.discountAmountType == "AMOUNT"; var discountCode = (item.hasOwnProperty("discountCode") ? "" + item.discountCode + " " : ""); for (var i = 0; i < item.quantity; i++) { var variation = null; var info = null; var optionsTotal = 0.0; var productOptionsInfos = []; if (item.hasOwnProperty("infos") && item.infos.hasOwnProperty(i + 1)) { info = item.infos[i + 1]; if (product.variations) { $.each(product.variations, function (iv, v) { if (v.eventProductVariationId == info.variation) { variation = v; } }); } if (product.options) { var auxs = []; $.each(product.options, function (io, o) { if (info.hasOwnProperty(o.eventProductId)) { if (o.variations) { $.each(o.variations, function (iv, v) { if (v.eventProductVariationId == info[o.eventProductId] && v.hasOwnProperty("price")) { optionsTotal += parseFloat(v.price); productOptionsInfos.push({label: v.name, _price: v._price}); auxs.push({"id": o.eventProductId, "value": info[o.eventProductId], "ordering": io}); } }); } else { productOptionsInfos.push({label: info[o.eventProductId]}); auxs.push({"id": o.eventProductId, "value": info[o.eventProductId], "ordering": io}); } } }); info["infos"] = [{auxs: auxs}]; } } var code = ""; var haveCode = false; if (discountAmount != null && usedDiscount < availableDiscount) { code = discountCode; haveCode = true; } var cartItem = { id: "p" + id + "-" + i, eventProductId: id, name: code + product.name + (variation ? " - " + variation.name : ""), haveCode: haveCode, haveGroupCode: false, quantity: 1, feeType: product.feeType, _price: variation ? variation._price : product._price, productOptionsInfos: productOptionsInfos }; console.info(cartItem); if (info) { var accountFields = ",name,companyName,contactName,emailAddress,phoneNumber,mobilePhoneNumber,streetAddress1,streetAddress2,city,state,country,zip,"; var attributes = {}; $.each(info, function (field, value) { if (accountFields.indexOf("," + field + ",") == -1 && field != "infos") { attributes[field] = value; } }); if (Object.keys(attributes).length != 0) { info["attributes"] = attributes; } cartItem["accountInfo"] = info; if (info.hasOwnProperty("variation")) { cartItem["eventProductVariationId"] = info.variation; cartItem.feeType = variation.feeType ? variation.feeType : product.feeType; delete info.variation; } } if (cartItem.hasOwnProperty("feeType") && cartItem.feeType != null && cartItem.feeType.hasOwnProperty("dollarAmount")) { cartItem.feeType.dollarAmount = parseFloat(cartItem.feeType.dollarAmount); cartItem.feeType.percentageAmount = parseFloat(cartItem.feeType.percentageAmount); } cart.push(cartItem); usedDiscount++; } } }); console.warn("--- CART ----------------------------------------------------"); console.info(cart); console.warn("---------------------------------------------------------------------------------------------------------"); console.warn("---------------------------------------------------------------------------------------------------------"); return cart; }, processPurchase: function (token) { console.clear(); console.warn("---------------------------------------------------------------------"); console.warn("--- processPurchase"); console.info("### STORE :: processPurchase :: " + token); var subtotal = 0.0; var fee = 0.0; var cart = $store._store.cart(); var json = {eventId: $store._eventInfo.event.eventId, name: $("[data-form-item-id='paymentInfo-name']").val(), emailAddress: $("[data-form-item-id='paymentInfo-emailAddress']").val(), phoneNumber: $("[data-form-item-id='paymentInfo-phoneNumber']").val(), paymentType: 1, products: [], eventDiscountCodes: []}; if (token) { json["paymentServiceToken"] = token; } $.each(cart, function (index, item) { var product = JSON.parse(JSON.stringify(item)); delete product.fee; delete product.id; delete product.name; delete product.price; delete product.symbol; json.products.push(product); subtotal += item.price; fee += item.fee; }); $.each($store._store.codes(), function (c, code) { var _code = {eventDiscountCodeId: code.eventDiscountCodeId, groups: []}; $.each(code.groups, function (g, group) { if (group.hasOwnProperty("count") && group.count > 0) { var _group = {eventDiscountCodeGroupId: 0, count: group.count, products: []}; if (group.hasOwnProperty("eventDiscountCodeGroupId")) { _group["eventDiscountCodeGroupId"] = group.eventDiscountCodeGroupId; } $.each(group.products, function (p, product) { if (product.hasOwnProperty("count") && product.count > 0) { _group.products.push({eventProductId: product.eventProductId, count: product.count}); } }); _code.groups.push(_group); } }); json.eventDiscountCodes.push(_code); }); json["total"] = parseFloat($store._storage.store("store-totals").total).toFixed(2); console.info(json); if (token != "-bob-") { $store._comm._post("/api/embedPurchase", json); } console.warn("--- processPurchase"); console.warn("---------------------------------------------------------------------"); }, quantity: function (id, val, inc, max) { var products = $store._eventInfo.products; var product = null; $.each(products, function (i, p) { if (p.eventProductId == id) { product = p; } }); var cartQuantities = $store._storage.store("cart-quantities"); if (!cartQuantities.hasOwnProperty(id)) { cartQuantities[id] = val; } var o = cartQuantities[id]; cartQuantities[id] += inc; cartQuantities[id] = max !== undefined && max > 0 && cartQuantities[id] > max ? max : cartQuantities[id]; cartQuantities[id] = cartQuantities[id] < 0 ? 0 : cartQuantities[id]; var n = cartQuantities[id]; if (product != null) { if (o < n) $store._store.activity.record("AddToCart", product.name); if (o > n) $store._store.activity.record("RemoveFromCart", product.name); } $store._storage.store("cart-quantities", cartQuantities); $("[data-form-item-id='" + id + "']").html(cartQuantities[id]); }, hasQuantity: function () { var store = $store._storage.store("store"); var ret = false; $.each(store, function (key, item) { ret |= item.quantity > 0; }); var codes = $store._store.codes(); $.each(codes, function (c, code) { $.each(code.groups, function (g, group) { ret |= group.hasOwnProperty("count") && group.count > 0; }); }); return ret; }, inputs: { number: function (id, val, cls, max) { return " "; }, quantity: function (id, val, cls, max, ro) { var cartQuantities = $store._storage.store("cart-quantities"); if (cartQuantities.hasOwnProperty(id)) { val = cartQuantities[id]; } var txt = ""; if (ro !== true) txt += "" + $store._svg.minus + " "; txt += "" + val + " "; if (ro !== true) txt += "" + $store._svg.plus + " "; txt += "
"; return txt; }, choice: function (id, index, options, cls, key) { return "" + options + " "; } }, activity: { record: function (auxLogTypeAction, comment, record) { var json = {eventId: $store._eventInfo.event.eventId, auxLogTypeAction: auxLogTypeAction, comment: comment, uniqueId: $store._store.activity.getUniqueId()}; var params = new URLSearchParams(window.location.search); if (params.get("fbclid") != null) { json["fbclid"] = params.get("fbclid"); } if (record != undefined) { json["record"] = record; } $store._comm._postAction("/api/embedStoreActivity", json); }, getUniqueId: function () { var uniqueIdJson = $store._storage.store("_app_aux_log_id"); if (uniqueIdJson == null || uniqueIdJson == undefined || uniqueIdJson.uniqueId == null || uniqueIdJson.uniqueId == undefined) { uniqueId = ""; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var charactersLength = characters.length; for (var i = 0; i < 10; i++) { uniqueId += characters.charAt(Math.floor(Math.random() * charactersLength)); } $store._storage.store("_app_aux_log_id", {"uniqueId": "EM_" + uniqueId + "-" + new Date().getTime()}); } return $store._storage.store("_app_aux_log_id").uniqueId; }, clearUniqueId: function () { $store._storage.store("_app_aux_log_id", null); } }, paytheory: { init: function () { console.warn("### STORE :: PAYTHEORY :: INIT"); $store["paytheory"] = window.paytheory }, render: function () { console.info("### STORE :: PAYTHEORY :: RENDER"); var html = ""; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; return html; }, populate: function () { console.warn("### STORE :: PAYTHEORY :: POPULATE"); $store.paytheory.payTheoryFields({apiKey: $store._eventInfo.paymentService.apiKey}); }, token: async function () { console.warn("### STORE :: PAYTHEORY :: TOKEN"); var name = $("[data-form-item-id='paymentInfo-name']").val(); var emailAddress = $("[data-form-item-id='paymentInfo-emailAddress']").val(); var phoneNumber = $("[data-form-item-id='paymentInfo-phoneNumber']").val(); console.info(name + " :: " + emailAddress + " :: " + phoneNumber); var firstName = name; var lastName = name; if (name.split(" ").length > 1) { firstName = name.split(' ').slice(0, -1).join(' '); lastName = name.split(' ').slice(-1).join(' '); } const TOKENIZE_PAYMENT_METHOD_PARAMETERS = { payorInfo: { "first_name": firstName, "last_name": lastName, "email": emailAddress, "phone": phoneNumber } }; let result = await $store.paytheory.tokenizePaymentMethod(TOKENIZE_PAYMENT_METHOD_PARAMETERS); console.info(result); if (result.type === "TOKENIZED") { $store._store.processPurchase(result.body.payment_method_id); } else if (result.type === "ERROR") { $("#str-message-payment").hide(); $("#str-buttons-payment").show(); $store.renderError("Processing of your payment did not succeed. Please verify your payment information and try again."); } } }, stripe: { init: function () { console.warn("### STORE :: STRIPE :: INIT"); var paymentService = $store._eventInfo.paymentService; try { if (paymentService.hasOwnProperty("uid")) { $store["stripe"] = Stripe(paymentService.publicKey, {"stripeAccount": paymentService.uid}); } else { $store["stripe"] = Stripe(paymentService.publicKey); } } catch (e) { /*setTimeout(this.initStripe, 1000);*/ } }, render: function () { console.warn("### STORE :: STRIPE :: RENDER"); return "
"; }, populate: function () { console.warn("### STORE :: STRIPE :: POPULATE"); if ($store.stripe) { if ($store.stripe.elements()) { var style = { base: { color: '#32325d', fontFamily: '"Helvetica Neue", Helvetica, sans-serif', fontSmoothing: 'antialiased', fontSize: '14px', '::placeholder': {color: '#aab7c4'} }, invalid: { color: '#fa755a', iconColor: '#fa755a' } }; var elements = $store.stripe.elements(); $store["card"] = elements.create('card', {style: style}); $store.card.mount('#card-element'); $store.card.addEventListener('change', function (event) { if (event.error) { $store.renderError(event.error.message); } }); } } }, token: function () { console.warn("### STORE :: STRIPE :: TOKEN"); var name = $("[data-form-item-id='paymentInfo-name']").val(); var emailAddress = $("[data-form-item-id='paymentInfo-emailAddress']").val(); var phoneNumber = $("[data-form-item-id='paymentInfo-phoneNumber']").val(); $store.stripe.createPaymentMethod({type: "card", card: $store.card, billing_details: {name: name, email: emailAddress, phone: phoneNumber}}).then(function (result) { if (result.error) { $("#str-message-payment").hide(); $("#str-buttons-payment").show(); $store.renderError(result.error.message); } else { $store._store.processPurchase(result.paymentMethod.id); } }); } } },
_form: { _css_prefix_: "", render: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; return this[field.formPartType](id, index, field, value, datas,onblur); }, text: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; return " "; }, email: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; return " "; }, phone: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; return " "; }, hidden: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; return " "; }, date: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; return " "; }, choice: function (id, index, field, value, datas, onblur) { onblur = onblur !== undefined ? onblur : ""; var choices = " "; $.each(field.choices, function (i, c) { choices += "" + c.label + " "; }); return "" + choices + " "; }, required: function () { return "required
"; }, datas: function (id, index, field, datas) { var additionalDatas = ""; if (datas) { $.each(datas, function (k, v) { additionalDatas += "data-" + k + "='" + v + "' "; }) } return additionalDatas + "data-store='" + this._eventKey + "' " + "data-form-item-id='" + id + "' " + "data-form-item-lbl-id='" + id + "-" + (index ? index + "-" : "") + field.key + "' " + (index ? "data-form-item-index='" + index + "' " : "") + "data-form-item-name='" + field.key + (field.product ? "' data-form-item-product='" + field.product : "") + (field.name ? "' data-form-item-lbl='" + field.name : "") + "' data-form-item-type='" + field.formPartType + "' " + "data-form-item-required='" + field.required + "' " + "data-form-item-required-css='" + this._css_prefix_ + "form-item-required' " + (field.parentKey ? "data-form-item-parent='" + field.parentKey + "' " : "") + (field.parentChoiceKey ? "data-form-item-parent-value='" + field.parentChoiceKey + "' " : "") + "onkeyup=\"" + this._root + "._form.validate('" + id + "')\" " + "onchange=\"" + this._root + "._form.validate('" + id + "')\""; }, lbldatas: function (id, index, field) { return " data-form-lbl-id='" + id + "-" + (index ? index + "-" : "") + field.key + "' "; }, validate: function (iid) { var _valid = true; $("[data-store='" + $store._form._eventKey + "']").each(function () { var parentKey = $(this).data("formItemParent"); var parentValue = $(this).data("formItemParentValue") + ""; var index = $(this).data("formItemIndex"); if (parentKey != null) { var parent = $("[data-store='" + $store._form._eventKey + "'][data-form-item-name='" + parentKey + "']" + (index ? "[data-form-item-index='" + index + "']" : "") + ":visible"); var value = parent.val() + ""; if (parent.length == 0 || value != parentValue) { $(this).hide(); $("[data-form-lbl-id='" + $(this).data("formItemLblId") + "']").hide(); } else { $(this).show(); $("[data-form-lbl-id='" + $(this).data("formItemLblId") + "']").show(); } } }); $("[data-store='" + $store._form._eventKey + "']:visible").each(function () { var id = $(this).data("formItemId"); var val = $(this).val(); var name = $(this).data("formItemName"); var type = $(this).data("formItemType"); var required = $(this).data("formItemRequired"); var requiredCss = $(this).data("formItemRequiredCss"); if (iid == undefined || (iid != undefined && (iid == id))) { $(this).removeClass(requiredCss); valid = true; if (id && required && !val) { valid = false; } if (val) { switch (type) { case "email": valid = $store._form.validateEmailAddress(val); break; case "phone": valid = $store._form.validatePhone(val); break; } switch (name) { case "state": valid = $store._form.validateState(val); break; case "zip": valid = $store._form.validateZip(val); break; } } _valid &= valid; if (!valid) $(this).addClass(requiredCss); } }); return _valid; }, validateUnique: function (iid) { var _valid = this.validate(); if (_valid) { var uniques = {}; var duplicates = false; $("[data-unique]").each(function () { console.info($(this).data()); if (!uniques.hasOwnProperty($(this).val())) { uniques[$(this).val()] = $(this).data("formItemId"); } else { duplicates = true; _valid = "Only one " + $(this).data("formItemProduct") + " per " + $(this).data("formItemLbl") + " can be purchased."; } }); if (!duplicates) { var emailsProducts = []; $.each(uniques, function (email, eventProductId) { emailsProducts.push({emailAddress: email, eventProductId: eventProductId}); }); if (emailsProducts.length != 0) { $store._comm._post("/api/purchasedProductCheck", emailsProducts); return "uniqueCheck"; } } } return _valid; }, validateEmailAddress: function (value) { return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value); }, validatePhone: function (value) { return /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im.test(value); }, validateState: function (value) { return /^(A[BLKSZRAEP]|BC|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ABDEHINOPST]|N[BCDEHJLMVSY]|O[NHKR]|P[AERW]|QC|RI|S[CDK]|T[NX]|UT|V[AIT]|W[AIVY])$/.test(value); }, validateZip: function (value) { return /^[0-9A-Z -]{1,10}$/.test(value); } },
_storage: { store: function (key, value) { if (window.localStorage) { if (key !== undefined) { if (value !== undefined) { if (value != null) { value = JSON.stringify(value); window.localStorage[this._eventKey + "-" + key] = value; if (window.localStorage[this._eventKey + "-" + key] != value) alert("SYSTEM ERROR: Unable to store local data!!!"); return window.localStorage[this._eventKey + "-" + key] == value; } else { delete window.localStorage[this._eventKey + "-" + key]; } } else { if (window.localStorage[this._eventKey + "-" + key]) { return JSON.parse(window.localStorage[this._eventKey + "-" + key]); } return {}; } } } } },
_comm: { _uri: "https://www.bridescan.com", _initialize: function () { $("body").append(""); $("body").append(""); $("body").append(""); $("body").append(""); $("body").append(""); for (var i = 0; i < 20; i++) { $("body").append(""); } }, _get: function (url) { url = this._uri + (url.indexOf("/") == 0 ? "" : "/") + url; $("#comm-" + this._eventKey.toLowerCase() + "-form-get").attr("action", url); $("#comm-" + this._eventKey.toLowerCase() + "-form-get").submit(); }, _post: function (url, json) { console.info("------ _post :: " + url); url = this._uri + (url.indexOf("/") == 0 ? "" : "/") + url; var ljson = JSON.stringify(json); $("#comm-" + this._eventKey.toLowerCase() + "-form-post").attr("action", url); $("#comm-" + this._eventKey.toLowerCase() + "-form-post-json").val(ljson); $("#comm-" + this._eventKey.toLowerCase() + "-form-post").submit(); }, _postAction: function (url, json) { console.info("------ _postAction :: " + url); if (!$store.hasOwnProperty("_postActionIndex")) { $store["_postActionIndex"] = 0; } var index = $store["_postActionIndex"] % 20; url = this._uri + (url.indexOf("/") == 0 ? "" : "/") + url; var ljson = JSON.stringify(json); var eventKey = this._eventKey.toLowerCase(); $("#comm-" + eventKey + "-form-post-action-" + index).attr("action", url); $("#comm-" + eventKey + "-form-post-action-json-" + index).val(ljson); var f = function () { console.info("_postAction :: " + index + " :: " + url + " :: SUBMIT"); $("#comm-" + eventKey + "-form-post-action-" + index).submit(); }; setTimeout(f, index * 750); $store["_postActionIndex"]++; } },
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------
// @formatter:on
_xyz: {}
};
if ($ == undefined) {
$ = jQuery.noConflict();
}
$(function () {
if (store.ok()) {
eval("window.$store = store").init();
}
});
window.addEventListener("message", function (event) {
if (typeof event.data === "string") {
var parts = event.data.replace(/(<([^>]+)>)/ig, "").split("::");
if (parts.length == 2) {
var type = parts[0];
var data = JSON.parse(parts[1]);
$store.data(type, data);
}
}
});
console.info("--- STORE -----------------------------------------------");