console.info("--- STORE -----------------------------------------------"); console.info($ == undefined); console.info($); store = { ok: function () { 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 :: -------------------------------------------------------"); $("head").append(""); $.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").html(JSON.stringify(this._eventInfo, null, 2)); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ 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.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 "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 () { return "" + "" + "" + "" + "
" + "
"; }, 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 () { if ($("[data-store-section='tickets']").length == 0) { return "
"; } var isLocalhost = window.location.hostname == "localhost"; var html = ""; $.each(this._eventInfo.products, function (i, ticket) { html += $store.renderStoreTicket(ticket, (isLocalhost ? 2 : 0)); }); var storeCodes = $store._store.codes(); $.each(storeCodes, function (key, codeinfo) { var code = undefined; $.each($store._eventInfo.codes, function (i, c) { if (c.code.toUpperCase() == key.toUpperCase()) { code = c; } }); if (code) { html += $store.renderCode(code, codeinfo); } else { delete storeCodes[key]; } }); $store._store.codes(storeCodes); html = "
" + ($store._eventInfo.hasOwnProperty("codes") && $store._eventInfo.codes.length != 0 ? "" : "") + "
choose quantity for each ticket and press continue
" + "
" + html + "
" + "
" + $store.renderFbPixel("PageView") + "
"; $("[data-store-section='tickets']").html(html); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderStoreTicket: function (ticket, index) { console.info("--- renderStoreTicket :: " + ticket.name + " -------------------------------------------------------"); var html = ""; var symbol = $store._eventInfo.currency.symbol; var max = ticket.maxPurchaseQuantity; var price = ticket.price; if (price == undefined) { var different = false; $.each(ticket.variations, function (v, variation) { if (price != undefined) { different |= price != variation.price; } price = (price == undefined || parseFloat(price) > parseFloat(variation.price) ? variation.price : price); if (variation.hasOwnProperty("maxPurchaseQuantity")) { if (max == undefined || max > variation.maxPurchaseQuantity) { max = variation.maxPurchaseQuantity; } } }); price = (different ? "from " : "") + symbol + price; } else { price = symbol + price; } html += ""; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += "
" + ticket.name + "" + price + "
" + this._store.inputs.number(ticket.eventProductId, index + "", "str-item-quantity str-override", max) + "
" + ticket.description + "
"; return html; }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderCode: function (code, info) { if (!info && $("[data-store-section='code']").length == 0) { return "
"; } var html; if (code) { console.info("--- renderCode ----------------------------------------"); console.info(code); var symbol = $store._eventInfo.currency.symbol; var each = code.applyTo.toUpperCase() == "EACH"; var type = code.amountType; var discount = parseFloat(code.price).toFixed(2).toString(); if (!each) { var minTotal = 0.00; var maxTotal = 0.00; if (code.eventProducts) { $.each(code.eventProducts, function (i, ep) { $.each($store._eventInfo.products, function (j, p) { if (p.eventProductId == ep.eventProductId) { var minPrice = null; var maxPrice = null; if (p.hasOwnProperty("price")) { minPrice = p.price; maxPrice = p.price; } else { $.each(p.variations, function (k, v) { if (minPrice == null || minPrice > v.price) { minPrice = v.price; } if (maxPrice == null || maxPrice < v.price) { maxPrice = v.price; } }); } minTotal += minPrice * ep.quantity; maxTotal += maxPrice * ep.quantity; } }); }); } discount = code.price; } html = (info || each ? "" : "
choose quantity for each ticket and press continue
"); html += ""; html += " "; html += " "; html += " "; html += " "; html += (each || code.exclusive ? "" : " "); html += (code.exclusive ? " " : ""); html += " "; if (code.eventProducts) { html += " "; html += ""; } html += "
" + code.code.toUpperCase() + "" + (type == "AMOUNT" ? symbol : "") + discount + (type == "AMOUNT" ? "" : "%") + (each ? "
OFF EACH
" : " OFF") + (info ? "
" : "") + "
" + this._store.inputs.number(code.code, (info ? info.quantity : 1), "str-item-quantity str-override") + "
" + this._store.inputs.number(code.code, 1, "str-item-quantity str-override") + "
" + code.description + "
" + (each ? "applies to" : "includes") + ":
"; $.each(code.eventProducts, function (i, ep) { $.each($store._eventInfo.products, function (j, p) { if (p.eventProductId == ep.eventProductId) { html += "
" + p.name + (ep.hasOwnProperty("quantity") ? "(" + (each ? "up to " + ep.quantity : ep.quantity + " count") + ")" : "") + "
" + p.description + "
"; } }); }); html += "
"; html += (info ? "" : "
"); if (info) { return html; } $("#str-navigation-title").html("Promo Code - " + code.code.toUpperCase()); $("[data-store-section='code']").html(html); } else { html = "
enter your promo code below and press 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(); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ processCode: function (code, quantity) { this.renderError(); if (code) { console.info("--- processCode :: CODE ----------------------------------------"); console.info(code); console.info(quantity); var discountCodes = $store._store.codes(); console.info(discountCodes); if (quantity < 1 && discountCodes.hasOwnProperty(code)) { delete discountCodes[code.toUpperCase()]; delete discountCodes[code.toLowerCase()]; } else { $.each($store._eventInfo.codes, function (i, c) { if (c.code == code) { var each = c.applyTo.toUpperCase() == "EACH"; if (!discountCodes.hasOwnProperty(code)) { discountCodes[code] = { code: code, exclusive: c.exclusive }; } discountCodes[code]["eventDiscountCodeId"] = c.eventDiscountCodeId; var quantity = $("[data-form-item-id='" + code + "']").val(); if (!each && !c.exclusive) { if (quantity < 1) { delete discountCodes[code]; } else { discountCodes[code]["quantity"] = parseInt(quantity); } } } }); } console.info(discountCodes); $store._store.codes(discountCodes); $("[data-store-section='code']").html(""); $store.back("code"); } 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."); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ applyCode: function () { console.info("--- applyCode ----------------------------------------"); var val = $("#str-code-after").val().toUpperCase(); var code = null; console.info(val); $.each($store._eventInfo.codes, function (i, c) { if (c.code.toUpperCase() == val) { code = c; console.info(c); var discountCodes = $store._store.codes(); var each = c.applyTo.toUpperCase() == "EACH"; if (!discountCodes.hasOwnProperty(val)) { discountCodes[val] = { code: c.code, exclusive: c.exclusive }; } discountCodes[val]["eventDiscountCodeId"] = c.eventDiscountCodeId; discountCodes[val]["quantity"] = 1; if (!each && !c.exclusive) { discountCodes[val]["quantity"] = 1; } console.info(discountCodes); $store._store.codes(discountCodes); $store.nextTo("cart", "Checkout"); $store.renderCart(); } }); if (code == null) { this.renderError("The promo code you entered is not valid."); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderInfo: function () { if ($("[data-store-section='info']").length == 0) { return "
"; } console.info("--- 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() + "
"; html += "
"; $.each(infos, function (ii, info) { 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 " : "") + symbol + price; html += ""; html += " "; html += " "; html += " "; html += " "; html += ""; if (info.variations) { var options = null; var value = (accountInfo && accountInfo["variation"] ? accountInfo["variation"] : ""); $.each(info.variations, function (v, variation) { options += ""; }); html += ""; html += ""; } 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 += ""; html += ""; }); } if (info.options) { $.each(info.options, function (oi, eventProductOption) { html += ""; 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 += ""; }); html += ""; } }); } if (i == 0 && info.quantity > 1) { html += ""; } html += "
" + info.name + (info.quantity > 1 ? " #" + (i + 1) : "") + (info.uniqueAccount ? "(one per email address)" : "") + "" + price + "
" + (info.variationLabel ? info.variationLabel : "Choose a ticket").toLowerCase() + "
" + $store._store.inputs.choice(info.eventProductId, i + 1, options) + "
" + part.name.toLowerCase() + "
" + $store._form.render(info.eventProductId, i + 1, part, (accountInfo && accountInfo[part.key] ? accountInfo[part.key] : ""), datas) + "
" + (eventProductOption.variationLabel ? eventProductOption.variationLabel : eventProductOption.name).toLowerCase() + "
" + $store._store.inputs.choice(info.eventProductId, i + 1, options, undefined, eventProductOption.eventProductId) + "
"; } html += "
" }); html += "
"; 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 == "AddToCart" && comment != "")) { $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 symbol = "$"; var subtotal = 0.0; var discount = 0.0; var fee = 0.0; var tax = 0.0; var total = 0.0; var cartItemInfo = {}; var billingName = undefined; var billingEmail = undefined; var billingPhone = undefined; /* html += "
Promo Code
"; html += "
"; */ html += "
Cart
"; html += ""; $.each(cart, function (i, item) { $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; } } if (!cartItemInfo.hasOwnProperty(item.eventProductId)) { cartItemInfo[item.eventProductId] = { quantity: 0, price: 0.0 }; } cartItemInfo[item.eventProductId].quantity++; cartItemInfo[item.eventProductId].price += parseFloat(item.price); cartItemInfo[item.eventProductId].unitPrice = parseFloat(item.price); symbol = item.symbol; subtotal += item.price; fee += item.fee; var eventProductOptionsHtml = ""; if (item.productOptionsInfos) { eventProductOptionsHtml += "
"; $.each(item.productOptionsInfos, function (j, productOptionsInfo) { eventProductOptionsHtml += "
" + productOptionsInfo.label + "
"; }); eventProductOptionsHtml += "
" } html += "" + "" + "" + ""; }); if (subtotal > 0) { html = "
Promo Code
" + item.name + eventProductOptionsHtml + "" + symbol + " " + parseFloat(item.price).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "
" + html; } console.info("--- renderCart - codes ----------------------------------------"); var currentCodes = $store._store.codes(); var newCodes = {}; $.each(currentCodes, function (key, cc) { var code = undefined; var usedCount = 0; $.each($store._eventInfo.codes, function (i, c) { if (key == c.code) { code = c; } }); if (code) { console.info(" -- CODE :: " + key + " ------------------------"); console.info(code); if (code.applyTo == "COLLECTION") { console.info(" - COLLECTION ------------------------"); var quantity = null; var sum = 0.00; if (code.eventProducts) { $.each(code.eventProducts, function (p, product) { if (cartItemInfo[product.eventProductId]) { cartItemInfo[product.eventProductId]["maxQuantity"] = product.quantity; var cnt = parseInt(cartItemInfo[product.eventProductId].quantity / product.quantity); if (quantity == null || quantity > cnt) { quantity = cnt; } } else { quantity = 0; } }); if (code.exclusive && quantity > 1) { quantity = 1; } usedCount = quantity; if (code.amountType == "PERCENTAGE" && quantity != 0) { $.each(code.eventProducts, function (p, product) { if (cartItemInfo[product.eventProductId]) { sum += cartItemInfo[product.eventProductId].unitPrice * cartItemInfo[product.eventProductId].maxQuantity * quantity; } }); } } else { $.each(cartItemInfo, function (i, cartItem) { sum += cartItem.unitPrice * (cartItem.maxQuantity ? cartItem.maxQuantity : cartItem.quantity); usedCount += (cartItem.maxQuantity ? cartItem.maxQuantity : cartItem.quantity); }); usedCount = (code.amountType == "AMOUNT" ? 1 : usedCount); } if (code.amountType == "AMOUNT") { discount += parseFloat(code.price) * (quantity == null ? 1 : quantity); } else { discount += sum / 100.0 * code.price; } } if (code.applyTo == "EACH") { console.info(" - EACH ------------------------"); $.each(code.eventProducts, function (p, product) { var quantity = cartItemInfo.hasOwnProperty(product.eventProductId) ? parseInt(cartItemInfo[product.eventProductId].quantity) : 0; var maxQuantity = (product.hasOwnProperty("quantity") ? parseInt(product.quantity) : 99999); maxQuantity = (quantity < maxQuantity ? quantity : maxQuantity); usedCount += maxQuantity; if (code.amountType == "AMOUNT") { discount += parseFloat(code.price) * maxQuantity; } else { discount += parseFloat(code.price) / 100.0 * (cartItemInfo.hasOwnProperty(product.eventProductId) ? parseFloat(cartItemInfo[product.eventProductId].unitPrice) : 0) * maxQuantity; } }); } cc.quantity = usedCount; newCodes[key] = cc; } }); $store._store.codes(newCodes); storeInfo = $store._storage.store("store-info"); var haveBalance = parseFloat(subtotal - discount) > 0.00; subtotal = parseFloat(subtotal).toFixed(2); discount = parseFloat(discount).toFixed(2); fee = (haveBalance ? parseFloat(fee).toFixed(2) : "0.00"); tax = parseFloat((parseFloat(subtotal) - parseFloat(discount) + parseFloat(fee)) * (parseFloat(storeInfo.salesTax) / 100)).toFixed(2); total = parseFloat(parseFloat(subtotal) - parseFloat(discount) + parseFloat(fee) + parseFloat(tax)).toFixed(2); html += ""; html += "SUBTOTAL" + symbol + " " + subtotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ""; html += (discount > 0.0 ? "DISCOUNT" + symbol + " " + parseFloat(discount * -1).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" : ""); html += (fee > 0.0 ? "CONVENIENCE FEE" + symbol + " " + fee.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" : ""); html += (tax > 0.0 ? "TAX" + symbol + " " + tax.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" : ""); html += ""; html += "TOTAL" + symbol + " " + total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ""; 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); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _paymentFields: [{ "ordering": 1, "formPartType": "text", "name": "Name on Credit Card", "choices": [], "required": true, "key": "name" }, { "ordering": 2, "formPartType": "email", "name": "e-mail address", "choices": [], "required": true, "key": "emailAddress" }, { "ordering": 3, "formPartType": "phone", "name": "cellphone number", "choices": [], "required": true, "key": "phoneNumber" }], _purchaseFields: [{ "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": 3, "formPartType": "phone", "name": "cellphone number", "choices": [], "required": true, "key": "phoneNumber" }], 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 : ""); break; case "emailAddress": val = (billingEmail != undefined ? billingEmail : ""); break; case "phoneNumber": val = (billingPhone != undefined ? billingPhone : ""); break; } html += "" + part.name.toLowerCase() + ""; html += "" + $store._form.render("paymentInfo-" + part.key, 0, part, val) + ""; }); if (haveBalance) { html += "credit card information"; /*html += "
";*/ html += "" + $store._store.paymentService.render() + ""; } $store._store.processPurchase("-bob-"); return "
" + (haveBalance ? "Payment Information" : "Purchase Information") + "
" + "
" + this._form.required() + "
" + "" + html + "
" + "
" + "
- processing purchase -
"; } , //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ 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."); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ 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 += "
View/Print Your Receipt
"; html += "
You should receive an email with your event check-in details and purchase receipt 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 check-in details are easily accessible in your inbox for the event.
"; html += "
If you do not receive an email from us, please email info@bridescan.com or call (865) 531-3941 for quick assistance.
"; html += "
We hope you enjoy the event!
"; html += "
"; html += "
"; html += $store.renderFbPixel("Purchase", $store._storage.store("store-totals").total); $("[data-store-section='completed']").html(html); $store.renderGGEvent("PurchaseComplete"); $store._storage.store("store", {}); $store._storage.store("accountInfos", {}); $store._store.codes({}); }, 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); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ style: { ".str": "max-width: 98%;width: 800px;margin:1% auto;border: 2px solid #aaa;border-radius: 7px;padding: 20px;background-color:#fff;color:#333;", ".str, .str *": "font:12pt Arial;", ".str a": "color:inherit !important;font-size:inherit !important;", ".str table": "border-spacing: 0px;border-collapse: separate;width:100%;", ".str table tr td": "border:0px;padding:2px;text-align:left;", ".str img": "max-width:98%;margin:1px 1%;border-radius:4px;", ".str .fa": "font-size:120%;margin-right:7px;width:15px;text-align:center;", ".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", ".str .str-buttons": "text-align:center;padding-top:10px;", ".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 button": "padding:2px 10px;margin:10px;color:#900;background-color:rgba(200,0,0,.08);", ".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:-21px;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:1px solid #ccc;margin-bottom:10px;", ".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-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-tickets": "border:1px solid #ccc;border-radius:5px;", ".str .str-ticket": "border-width:0px;border-top:1px solid #ccc;width:98%;cursor:pointer;margin:5px;padding:5px;", ".str .str-ticket:first-child": "border-top:none;", ".str .str-ticket:hover": "background-color:#f8f8f8;", ".str .str-ticket .str-item-name": "font-size:130%;padding:10px;", ".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:130%;padding:10px;vertical-align:top;width:1%;", ".str .str-ticket .str-item-price span": "font-size:70%;color:#999;", ".str .str-ticket .str-item-price div": "font-size:70%;color:#555;", ".str .str-ticket .str-item-description": "padding:5px 15px 0 15px;font-size:85%;font-style:italic;color:#777;", ".str .str-ticket .str-item-description *": "font-size:inherit;font-style:inherit;", ".str .str-ticket .str-item-description > *": "max-width:98%;", ".str .str-ticket .str-item-description .str-item-quantity": "text-align:center;max-width:80px;font-size:120%;", ".str .str-ticket .str-item-heading": "padding:5px 15px 0 15px;font-size:85%;font-style:italic;color:#777;", ".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:right;cursor:pointer;", ".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%;", ".str .str-item-shaded": "background-color:#f0f0f0;", ".str .str-divider": "border-top:1px solid #aaa;padding:0px;", ".str .str-cart": "font-size:90%;font-weight:normal;border:1px solid #ccc;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-first .str-cart-item": ";border-top:none;", ".str .str-cart .str-cart-item": "padding:3px;border-top:1px solid #ccc;", ".str .str-cart .str-cart-item-name": "", ".str .str-cart .str-cart-item-price": "text-align:right;white-space:nowrap;width:1%;padding-right:3px;", ".str .str-cart .str-cart-total": "white-space:nowrap;width:1%;font-size:90%;text-align:right;padding-right:5px;padding-left:25px;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"); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // @formatter:off _eventInfo: { "codes": [], "paymentService": { "jsApiUrl": "https://js.stripe.com/v3/", "uid": "acct_1C6OdlC2GbhVjm6P", "name": "Stripe", "active": false, "serviceInstanceId": 5, "publicKey": "pk_live_7nlSMNC5CczWf6uwLsZ6Khhs", "serviceId": 21 }, "currency": { "symbol": "$", "code": "usd", "dollarAmount": "0.00", "name": "USD ($)", "id": 1, "percentageAmount": "0.000" }, "attributes": { "mapsAllowed": "true", "fbPixel": "675046442627064", "makeWebhookId": "0-0", "makeAuthApiKey": "ma9hxdY9nB6KiZ)Aa0FRBcMTn14B1wU1lvke" }, "salesTax": "0.00", "storeProductOrdering": "priceDescendingNameAscending", "event": { "eventId": 1671, "name": "Atlanta Wedding Extravaganza 8_17_25", "producer": { "phone": "+1 (770) 744-5750", "name": "Atlanta Wedding Extravaganza", "email": "shelly@atlantapartyconnection.com" }, "startDate": "August 17, 2025 @ 4:00PM" }, "eventStoreFee": "Processing Fee", "enabled": true, "eventStoreButton": "buy tickets", "products": [ { "variationLabel": "Your Entry Time", "maxPurchaseQuantity": 1, "ordering": 1, "description": "

Brides or Grooms - <\/strong>Limited VIP tix available. <\/em>Enjoy early entry, VIP gifts and champagne! Are you bringing VIP Guests? Purchase VIP Guest Tickets below. <\/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": "", "formTypeId": 1, "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" } ], "name": "Store Default", "key": "storeAttendeeInfo" }, "variations": [ { "availableQuantity": 90, "eventProductVariationId": 70655, "price": "30.00", "ordering": 0, "name": "1:00PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "2.00", "dollarAmountOther": "0.00", "name": "Default", "percentageAmount": "0.040", "percentageAmountOtherType": "default" } }, { "availableQuantity": 95, "eventProductVariationId": 70654, "price": "30.00", "ordering": 2, "name": "1:30PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "2.00", "dollarAmountOther": "0.00", "name": "Default", "percentageAmount": "0.040", "percentageAmountOtherType": "default" } } ], "formName": "storeAttendeeInfo", "eventProductId": 6893, "options": [], "name": "VIP ENGAGED Ticket", "productType": "Ticket" }, { "variationLabel": "Your Entry Time", "maxPurchaseQuantity": 0, "ordering": 1, "variations": [ { "availableQuantity": 94, "eventProductVariationId": 70661, "price": "20.00", "ordering": 0, "name": "1:00PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" } }, { "availableQuantity": 100, "eventProductVariationId": 70660, "price": "20.00", "ordering": 2, "name": "1:30PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" } } ], "eventProductId": 6886, "options": [], "name": "VIP GUEST Tickets", "description": "

Moms, Dads or Wedding Party? VIP Guests can enter early and enjoy a free glass of champagne! Limited quantities available.<\/strong><\/p>", "requireResponse": false, "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "2.00", "dollarAmountOther": "0.00", "name": "Default", "percentageAmount": "0.040", "percentageAmountOtherType": "default" }, "productType": "Ticket" }, { "variationLabel": "Your Entry Time", "maxPurchaseQuantity": 1, "ordering": 1, "description": "

Getting Married? Purchase your tickets here. Bringing guests? Purchase guest tickets below.<\/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": "", "formTypeId": 1, "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" } ], "name": "Store Default", "key": "storeAttendeeInfo" }, "variations": [ { "availableQuantity": 109, "eventProductVariationId": 70659, "price": "10.00", "ordering": 0, "name": "2:00PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" } }, { "availableQuantity": 100, "eventProductVariationId": 70658, "price": "10.00", "ordering": 2, "name": "2:30PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" } } ], "formName": "storeAttendeeInfo", "eventProductId": 6887, "options": [], "name": "General Admission ENGAGED Tickets", "productType": "Ticket" }, { "variationLabel": "Your Entry Time", "maxPurchaseQuantity": 0, "ordering": 1, "variations": [ { "availableQuantity": 99, "eventProductVariationId": 70663, "price": "10.00", "ordering": 0, "name": "2:00PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" } }, { "availableQuantity": 1000, "eventProductVariationId": 70662, "price": "10.00", "ordering": 2, "name": "2:30PM", "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "1.50", "dollarAmountOther": "0.00", "name": "Default Ticket", "percentageAmount": "0.000", "percentageAmountOtherType": "default" } } ], "eventProductId": 6890, "options": [], "name": "General Admission GUEST Tickets", "description": "

Purchase a ticket for each guest here.<\/strong><\/p>", "requireResponse": false, "feeType": { "percentageAmountOther": "0.00", "percentageAmountType": "default", "dollarAmount": "2.00", "dollarAmountOther": "0.00", "name": "Default", "percentageAmount": "0.040", "percentageAmountOtherType": "default" }, "productType": "Ticket" } ] }, _conf: { _uri:"https://www.bridescan.com", _authKey:"awe", _eventKey:"atlanta" }, _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-info", storeInfo); $store._storage.store("store", {}); this["initialized"] = true; if(this.hasOwnProperty("paymentService")) { setTimeout(this.paymentService.init, 2000); } } }, update: function () { console.warn("---------------------------------------------------------------------"); console.info("### 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 val = $(this).val(); if (!codes.hasOwnProperty(id)) { console.info(id + " :: " + index + " :: " + name + " :: " + val); if (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] = val; else delete store[id][name]; } } }); $("[data-store='" + this._eventKey + "']").each(function () { var id = $(this).data("formItemId"); var val = $(this).val(); if (codes.hasOwnProperty(id)) { codes[id].quantity = parseInt(val); if (codes[id].quantity == 0) { delete codes[id]; } else { var code = undefined; $.each($store._eventInfo.codes, function (i, c) { if (id == c.code) code = c; }); if (code && code.applyTo == "COLLECTION") { if (code.eventProducts) { $.each(code.eventProducts, function (i, p) { if (!store.hasOwnProperty(p.eventProductId)) { store[p.eventProductId] = {id: p.eventProductId, quantity: 0}; } store[p.eventProductId].quantity = parseInt(store[p.eventProductId].quantity) + (parseInt(val) * parseInt(p.quantity)); }); } } } $store._store.codes(codes) } }); console.info("--- STORE -------------------------------"); console.info(store); console.info("--- STORE -------------------------------"); $store._storage.store("store", store); 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 () { var products = []; var storeInfo = $store._storage.store("store-info"); 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}; if (product.hasOwnProperty("variations")) { p["variations"] = product.variations; } if (product.hasOwnProperty("options")) { p["options"] = product.options; } if (product.hasOwnProperty("uniqueAccount")) { p["uniqueAccount"] = product.uniqueAccount; } 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.warn("---------------------------------------------------------------------"); console.info("### STORE :: cart"); var cart = []; var storeInfo = $store._storage.store("store-info"); 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) { console.info("-------------------------"); console.info(product); console.info(item); 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 price = parseFloat(variation ? variation.price : product.price) + optionsTotal; var dollarAmount = parseFloat(product.feeType.dollarAmount); var cartItem = {id: "p" + id + "-" + i, eventProductId: id, name: product.name + (variation ? " - " + variation.name : ""), price: price, symbol: storeInfo.currency.symbol, quantity: 1, fee: (dollarAmount + ((price + (product.feeType.percentageAmountType == "onFeeAmount" ? dollarAmount : 0.00)) * parseFloat(product.feeType.percentageAmount))), productOptionsInfos: productOptionsInfos}; 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; var variationDollarAmount = parseFloat(variation.feeType ? variation.feeType.dollarAmount : product.feeType.dollarAmount); cartItem.fee = (variationDollarAmount + ((price + (product.feeType.percentageAmountType == "onFeeAmount" ? variationDollarAmount : 0.00)) * parseFloat(variation.feeType ? variation.feeType.percentageAmount : product.feeType.percentageAmount))); delete info.variation; } } cart.push(cartItem); } } }); console.info(cart); console.warn("---------------------------------------------------------------------"); return cart; }, processPurchase: function (token) { console.warn("---------------------------------------------------------------------"); console.warn("---------------------------------------------------------------------"); 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; } var codes = {}; $.each($store._store.codes(), function (c, storeCode) { codes[storeCode.eventDiscountCodeId] = {eventDiscountCodeId: storeCode.eventDiscountCodeId, eventDiscountCodeCount: 0, code: null}; if (storeCode.hasOwnProperty("quantity")) { codes[storeCode.eventDiscountCodeId].eventDiscountCodeCount = storeCode.quantity; } $.each($store._eventInfo.codes, function (i, c) { if (c.eventDiscountCodeId == storeCode.eventDiscountCodeId) codes[storeCode.eventDiscountCodeId].code = c; }); }); $.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(codes, function (c, code) { if (code.eventDiscountCodeCount > 0) { json.eventDiscountCodes.push({eventDiscountCodeId: code.eventDiscountCodeId, eventDiscountCodeCount: code.eventDiscountCodeCount}); } }); 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("---------------------------------------------------------------------"); console.warn("---------------------------------------------------------------------"); }, hasQuantity: function () { var store = $store._storage.store("store"); var ret = false; $.each(store, function (key, item) { ret |= item.quantity > 0; }); return ret; }, inputs: { number: function (id, val, cls, max) { return ""; }, choice: function (id, index, options, cls, key) { return ""; } }, activity: { record: function (auxLogTypeAction, comment, record) { console.info("activity.record :: " + auxLogTypeAction + " :: " + comment); 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 uniqueId = $store["_app_aux_log_id"]; if (uniqueId == null || 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["_app_aux_log_id"] = "EM_" + uniqueId + "-" + new Date().getTime(); } return $store["_app_aux_log_id"]; } }, paytheory: { init: function () { console.warn("### STORE :: PAYTHEORY :: INIT"); $store["paytheory"] = window.paytheory }, render: function () { console.info("### STORE :: PAYTHEORY :: RENDER"); return "

" + "
" + "
" + "
" + "
" + "
"; }, populate: function () { console.warn("### STORE :: PAYTHEORY :: POPULATE"); $store.paytheory.payTheoryFields({ apiKey: $store._storage.store("store-info").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._storage.store("store-info").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) { return this[field.formPartType](id, index, field, value, datas); }, text: function (id, index, field, value, datas) { return ""; }, email: function (id, index, field, value, datas) { return ""; }, phone: function (id, index, field, value, datas) { return ""; }, hidden: function (id, index, field, value, datas) { return ""; }, date: function (id, index, field, value, datas) { return ""; }, choice: function (id, index, field, value, datas) { var choices = ""; $.each(field.choices, function (i, c) { choices += ""; }); return ""; }, 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 + "' data-form-item-product='" + field.product + "' 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("") .append("") .append("") .append("
") .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 -----------------------------------------------");