console.info("--- STORE -----------------------------------------------");
console.info($ == undefined);
console.info($);
store = {
debug: (window.location.origin == "http://bs" && true),
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
//------------------------------------------------------------
if (this.debug) {
//this.renderCode();
var div = "
"
var html = "";
var completedCodes = {"P01": false};
html += JSON.stringify(this._eventInfo, null, 2);
$("#atbta-debug-atbta").html(html);
}
//------------------------------------------------------------
//--- 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.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 innerHtml = "";
$.each(this._eventInfo.products, function (i, ticket) {
innerHtml += $store.renderStoreTicket(ticket, (isLocalhost ? 2 : 0));
});
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) {
innerHtml += $store.renderStoreCode(discountCode);
} else {
delete discountCodes[key];
}
});
$store._store.codes(discountCodes);
html = "
";
html += ($store._eventInfo.hasOwnProperty("codes") && $store._eventInfo.codes.length != 0 ? "
Have Promo Code? Click HERE.
" : "");
html += "
choose quantity for each ticket and press continue
";
html += "
" + innerHtml + "
";
html += "";
html += $store.renderFbPixel("PageView");
html += "
";
$("[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 += "
( Exclusive promo code, cannot be used with any other offer )
" : "") + "
";
html += "
";
html += " " + (code.haveProducts ? symbol + parseFloat(price).toFixed(2) : "") + "" + discountedPrice;
html += " ";
html += "
";
html += "
";
html += "
";
html += "
";
$.each(code.groups, function (g, group) {
if (group.count > 0) {
html += "
";
$.each(group.products, function (p, product) {
if (product.count > 0) {
console.info(product);
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
html += "
";
// ##############################################################################################################################
// ##############################################################################################################################
// ##############################################################################################################################
// ##############################################################################################################################
// ##############################################################################################################################
// ##############################################################################################################################
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["discountAmountEach"] = discountAmount;
html += "
";
$.each(group.products, function (p, product) {
$.each($store._eventInfo.products, function (j, eventProduct) {
if (eventProduct.eventProductId == product.eventProductId) {
html += "
";
if (info.variations) {
var options = null;
var value = (accountInfo && accountInfo["variation"] ? accountInfo["variation"] : "");
$.each(info.variations, function (v, variation) {
options += "";
});
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 for assistance.