1var _shoppingCart = /** @class */ (function () { 2 function _shoppingCart() { 3 } 4 _shoppingCart.prototype.PageScripts = function () { 5 _shoppingCart.prototype.OnLoadScripts(); 6 }; 7 //shoppingCart 8 _shoppingCart.prototype.OnLoadScripts = function () { 9 var _a, _b; 10 var isAdvanceOrderTriage = ((_a = $('#hdn_IsAdvanceOrderTriage').val()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "true"; 11 var noEcertAvailableInAOT = ((_b = $('#hdn_NoEcertAvailableInAOT').val()) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === "true"; 12 // Show error message for Advance Order Triage if Enable Ecertificate or Bulk Purchase Management flag is disabled. 13 if (isAdvanceOrderTriage && noEcertAvailableInAOT) { 14 ZnodeNotification.prototype.DisplayNotificationMessagesHelper(ZnodeBase.prototype.getResourceByKeyName("NoEcertInAOTError"), 'error', isFadeOut, fadeOutTime); 15 } 16 // Function to determine the display of 'Free Shipping' Message 17 function freeShippingDisplay(cartDollarPrice) { 18 var freeShippingElement = document.getElementById("value-free-shipping"); 19 if (freeShippingElement) { 20 var freeShippingCutoff = 250; // Dollar amount required for Free Shipping 21 var objCartNotification = document.getElementById("cart-shipping-notification"); 22 if (cartDollarPrice >= freeShippingCutoff) { 23 //'Free Shipping' active. 24 if (freeShippingElement != undefined && freeShippingElement != null) { 25 freeShippingElement.classList.add("active"); 26 } 27 if (objCartNotification != undefined && objCartNotification != null) { 28 objCartNotification.classList.add("active"); 29 } 30 $('#ship-countdown').removeClass("active"); 31 $('#ship-qualifies').addClass("active"); 32 } 33 else if (cartDollarPrice >= 175) { 34 //'Free Shipping' inactive. 35 if (freeShippingElement != undefined && freeShippingElement != null) { 36 freeShippingElement.classList.remove("active"); 37 } 38 if (objCartNotification != undefined && objCartNotification != null) { 39 objCartNotification.classList.add("active"); 40 } 41 $('#ship-countdown').addClass("active"); 42 $('#ship-qualifies').removeClass("active"); 43 var almostShipPrice = (freeShippingCutoff - cartDollarPrice).toFixed(2); 44 $(".free-ship-almost").append("$" + almostShipPrice); 45 } 46 else { 47 //'Free Shipping' inactive. 48 if (freeShippingElement != undefined && freeShippingElement != null) { 49 freeShippingElement.classList.remove("active"); 50 } 51 if (objCartNotification != undefined && objCartNotification != null) { 52 objCartNotification.classList.remove("active"); 53 } 54 $('#ship-countdown').removeClass("active"); 55 $('#ship-qualifies').removeClass("active"); 56 } 57 } 58 } 59 var cartValue = 0; 60 var reloadPageFlag = $("#dontreload").val(); 61 var reloadPage = (reloadPageFlag != undefined && reloadPageFlag != null && reloadPageFlag != "" && reloadPageFlag == "false"); 62 if ($("._shoppingCart").length > 0) { 63 $("._shoppingCart").each(function (index, element) { 64 var _a, _b, _c, _d, _e, _f, _g; 65 $.ajax({
66 cache: false, 67 url: "/cart/calculatecart", 68 type: "get", 69 success: function (res) { 70 if (res != undefined && res.totalTableHtml != undefined && res.totalTableHtml != "") { 71 CommonHelper.prototype.LoadHtmlById("#" + 72 $(".cart-total-content").attr("id"), res.totalTableHtml); 73 $("#checkOut-link").off("click").on("click", function (e) { 74 var isUseSPPOneInventoryEnable = $("#hdnIsUseSPPOneInventoryEnable").val(); 75 if (isUseSPPOneInventoryEnable != undefined && isUseSPPOneInventoryEnable != null && isUseSPPOneInventoryEnable != "" && (isUseSPPOneInventoryEnable === null || isUseSPPOneInventoryEnable === void 0 ? void 0 : isUseSPPOneInventoryEnable.toLowerCase()) === "true") { 76 $('.cartLoader').css("display", "flex"); 77 var hasError = _shoppingCart.prototype.GetRealTimeZnodeInventory(); 78 if (hasError) { 79 $('.cartLoader').css("display", "none"); 80 e.preventDefault(); 81 return false; 82 } 83 } 84 var IsMaximumPurchaseRequired = $("#IsMaximumPurchaseRequired").val(); 85 if (IsMaximumPurchaseRequired != undefined && IsMaximumPurchaseRequired != null && IsMaximumPurchaseRequired.toLowerCase() === "true" && window.location.pathname.includes("/cart")) { 86 _MaxPurchaseRequired.prototype.loadMaxPurchaseCart(); 87 } 88 return BindClickEventOnCheckout(e); 89 }); 90 } 91 else { 92 CommonHelper.prototype.LoadHtmlById("#" + 93 $(CommonHelper.prototype.JQControl(element, ".cart-total-content")).attr("id"), res); 94 } 95 _TotalTable.prototype.PageScripts(); 96 if ($("#dynamic-order-total").length > 0) 97 $("#dynamic-cart-order-total").html($("#dynamic-order-total")[0].innerText); 98 $('#removeAllCartItems').on("click", function () { 99 $(this).closest('form').submit(); 100 }); 101 }, 102 error: function (request, error) { 103 var isFreeGiftPromotion = $("#hdn_isFreeGiftPromotion").val(); 104 if (reloadPage && isFreeGiftPromotion != undefined && isFreeGiftPromotion.toLowerCase() == 'true') 105 window.location.reload(); 106 } 107 }); 108 if (($("#enableDisplayAsPointValue").val() != undefined && $("#enableDisplayAsPointValue").val().toLowerCase() == 'true') || 109 ($("#isDisplayPriceAsPointEnabledOnly").val() != undefined && $("#isDisplayPriceAsPointEnabledOnly").val().toLowerCase() == 'true')) { 110 var pointValue = $("#hdn_subTotal").val().substring($("#hdn_subTotal").val().indexOf('$') + 1); 111 var numericValue = parseInt(pointValue.toString().replace(/,/g, '')); 112 if ($("#currentThemePath").val() === 'SageSerpent') { 113 $(".cart .headerSubtotal").html(numericValue.toString()); 114 } 115 else { 116 $(".cart .headerSubtotal").html(numericValue.toString() + " point(s)"); 117 } 118 } 119 else { 120 $(".cart #headerCart").removeAttr("aria-label"); 121 var totalQty = parseInt($("#hdn_totalCartQuantities").val(), 10) || 0; 122 var itemReader = totalQty > 1 ? "items" : "item"; 123 var isDisplayItemPricing = ((_d = (_c = (_b = (_a = $("#isDisplayItemPricing")) === null || _a === void 0 ? void 0 : _a.val()) === null || _b === void 0 ? void 0 : _b.toString()) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === "true"; 124 if (isDisplayItemPricing) { 125 var subTotal = $("#hdn_subTotal").val() || ""; 126 $(".cart .headerSubtotal").html(subTotal); 127 $(".cart #headerCart").attr("aria-label", "Shopping cart, ".concat(totalQty, " ").concat(itemReader, ", total ").concat(subTotal)); 128 } 129 else { 130 $(".cart .headerSubtotalQuantity").html(totalQty.toString()); 131 $(".cart #headerCart").attr("aria-label", "Shopping cart, ".concat(totalQty, " ").concat(itemReader)); 132 } 133 } 134 $(".cart .combinedHeaderQuantity").html((_g = (_f = (_e = $("#hdnConsolidatedItemCount")) === null || _e === void 0 ? void 0 : _e.val()) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : ""); 135 $(".cart .headerQuantity").html($("#hdn_totalCartQuantities").val()); 136 if (CommonHelper.prototype 137 .JQControl(element, "#hdn_totalCartQuantities") 138 .val() > 0) { 139 $(".cart > a").addClass("hasItem"); 140 cartValue = parseFloat($("#hdn_subTotal") 141 .val() 142 .replace(/\$|,/g, "")); 143 } 144 else { 145 $(".cart > a").removeClass("hasItem"); 146 } 147 freeShippingDisplay(cartValue);
148 sessionStorage.setItem("cartValue", String(cartValue)); // Store in session 149 $.each(CommonHelper.prototype.JQList(element, ".cart-item-remove-all"), function (idx, ele) { 150 $(ele) 151 .off("click") 152 .on("click", function (e) { 153 $("#hdn_FreeGiftCallExecuted").val('false'); 154 CommonHelper.prototype.SubmitForm($(ele).closest("form"), function (result) { }); 155 }); 156 }); 157 CommonHelper.prototype 158 .JQControl(element, "#checkOut-link") 159 .off("click") 160 .on("click", function (e) { 161 var allProductguids = []; 162 $('input[data-productguid]').each(function () { 163 allProductguids.push($(this).attr('data-productguid')); 164 }); 165 var allParentProductIds = []; 166 $('input[data-cart-ppid]').each(function () { 167 allParentProductIds.push($(this).attr('data-cart-ppid')); 168 }); 169 CustomCart.prototype.ClearCartErrorContext(allProductguids, allParentProductIds); 170 var isUseSPPOneInventoryEnable = $("#hdnIsUseSPPOneInventoryEnable").val(); 171 if (isUseSPPOneInventoryEnable && (isUseSPPOneInventoryEnable === null || isUseSPPOneInventoryEnable === void 0 ? void 0 : isUseSPPOneInventoryEnable.toLowerCase()) === "true") { 172 $('.cartLoader').css("display", "flex"); 173 var hasError = _shoppingCart.prototype.GetRealTimeZnodeInventory(); 174 if (hasError) { 175 $('.cartLoader').css("display", "none"); 176 e.preventDefault(); 177 return false; 178 } 179 } 180 return BindClickEventOnCheckout(e); 181 }); 182 function BindClickEventOnCheckout(e) { 183 var _a; 184 $('.cartLoader').css("display", "flex"); 185 var isMinimumPurchaseRequired = $("#hdnMinimumPurchaseRequired").val(); 186 if (isMinimumPurchaseRequired && isMinimumPurchaseRequired.toLowerCase() == 'true') { 187 var isMinimumPurchasedValidationRequired = $('#IsMinimumPurchasedValidationRequired').val(); 188 if ((isMinimumPurchasedValidationRequired && isMinimumPurchasedValidationRequired.toLowerCase() == 'true') && !CustomCart.prototype.ValidateCartPageForMinimumPurchaseRequired()) { 189 e.preventDefault(); 190 $('.cartLoader').css("display", "none"); 191 return false; 192 } 193 } 194 if (!_shoppingCart.prototype.ShowMaxPurchaseError()) { 195 e.preventDefault(); 196 $('.cartLoader').css("display", "none"); 197 return false; 198 } 199 else { 200 if (Number((_a = $('#hdn_CartItemCount')) === null || _a === void 0 ? void 0 : _a.val()) > 300) { 201 $('.cartLoader').css("display", "none"); 202 ZnodeNotification.prototype.DisplayNotificationMessagesHelper(ZnodeBase.prototype.getResourceByKeyName("LineItemExceeded"), 'error', isFadeOut, fadeOutTime); 203 return false; 204 } 205 if (CustomCart.prototype.ValidateProductQuantity()) { 206 var validateNoteCardProduct = CustomCart.prototype.ValidateNotecardProductQuantity(); 207 if (!validateNoteCardProduct) { 208 $('.cartLoader').css("display", "none"); 209 return false; 210 } 211 } 212 else { 213 $('.cartLoader').css("display", "none"); 214 return false; 215 } 216 var skus = $("#publishProductSKUs").val(); 217 var publishProductdetails = $("#publishProductdetails").val(); 218 CustomEndpoint.prototype.GetPublishProductDetails(skus, publishProductdetails, function (res) { 219 if (res && res.removedProductNames != "") 220 $('.cartLoader').css("display", "none"); 221 }); 222 } 223 } 224 $("#lblsignin").on("click", function (e) { 225 User.prototype.LoginMethod(); 226 }); 227 }); 228 } 229 var targetDiv = $("div .cart-products").find("div[data-allpsinvetoryzero='True']"); 230 if (targetDiv.length > 0) { 231 targetDiv.css({ 232 opacity: 0.5, 233 pointerEvents: "none" 234 }); 235 } 236 $("div .cart-products").find("div[data-allPsinvetoryzero-message='True']").css("display", "block"); 237 $("._eCertCartRowDescription").each(function () { 238 $(this).closest("li#ecertproduct").addClass("ecertcartitem"); 239 }); 240 }; 241 _shoppingCart.prototype.GetRealTimeZnodeInventory = function () { 242 var skus = $("#cartProductsSKU").val(); 243 var errorCount = 0; 244 $.ajax({
245 url: "/CustomProduct/GetRealTimeInventory", 246 type: "GET", 247 data: { skus: skus }, 248 dataType: 'json', 249 async: false, 250 success: function (data) { 251 if (data === null || data === void 0 ? void 0 : data.isRedirectToLogin) { 252 document.location.href = data.link; 253 return; 254 } 255 else if (data && data != null && data != undefined && data.length > 0) { 256 var outOfStockOptionDict_1 = JSON.parse($("#hdnOutOfStockOptions").val()); 257 $('.quantity-spinner input[name="Quantity"]').each(function (index, element) { 258 var sku = element.getAttribute('data-config-sku'); 259 if (sku === null || sku.trim() === '') { 260 sku = element.getAttribute('data-cart-sku'); 261 } 262 var qtyValue = element.getAttribute('value'); 263 $.each(data, function (index) { 264 var item = data[index]; 265 if (item.SKU == sku) { 266 var outOfStockOption = outOfStockOptionDict_1 === null || outOfStockOptionDict_1 === void 0 ? void 0 : outOfStockOptionDict_1[item.SKU]; 267 if (outOfStockOption && outOfStockOption.toLowerCase() != "disablepurchasing") { 268 return true; 269 } 270 if (qtyValue > item.Quantity) { 271 $('#znode_inventory_out_of_stock_' + sku).show(); 272 $('.cartLoader').css("display", "none"); 273 errorCount++; 274 } 275 else { 276 $('#znode_inventory_out_of_stock_' + sku).hide(); 277 } 278 } 279 }); 280 }); 281 } 282 }, 283 error: function (error) { 284 } 285 }); 286 return errorCount > 0 ? true : false; 287 }; 288 _shoppingCart.prototype.CheckRealTimeZnodeInventory = function () { 289 var data = {}; 290 //Get all the selected values required to submit order. 291 Checkout.prototype.SetOrderFormData(data); 292 //Create form to submit order. 293 var form = Checkout.prototype.CreateForm(data); 294 // submit form 295 $.ajax({
296 type: "POST", 297 url: "/checkout/submitorder", 298 data: $(form).serialize(), 299 success: function (response) { 300 if (response.success) { 301 window.location.href = "/checkout/ordercheckoutreceipt"; 302 } 303 else { 304 Checkout.prototype.HideLoader(); 305 ZnodeNotification.prototype.DisplayNotificationMessagesHelper(ZnodeBase.prototype.getResourceByKeyName("ErrorProcessOrder"), "error", isFadeOut, fadeOutTime); 306 } 307 }, 308 error: function () { 309 Checkout.prototype.HideLoader(); 310 ZnodeNotification.prototype.DisplayNotificationMessagesHelper(ZnodeBase.prototype.getResourceByKeyName("ErrorProcessOrder"), "error", isFadeOut, fadeOutTime); 311 }, 312 complete: function () { 313 form.remove(); 314 } 315 }); 316 }; 317 _shoppingCart.prototype.ShowMaxPurchaseError = function () { 318 var result = true; 319 var IsMaximumPurchaseRequired = $("#IsMaximumPurchaseRequired").val(); 320 if (IsMaximumPurchaseRequired != undefined && IsMaximumPurchaseRequired != null && IsMaximumPurchaseRequired.toLowerCase() === "true") { 321 var productDataStr = $("#AvailableQuantityProductData").val(); 322 var productData = productDataStr ? JSON.parse(productDataStr) : []; 323 var isDataCaptureMatched = $("#IsDataCaptureAvailable").val(); 324 if (productData != undefined && productData != null) { 325 if (isDataCaptureMatched != null && isDataCaptureMatched != undefined && isDataCaptureMatched.toLowerCase() === "true") { 326 for (var i = 0; i < productData.length; i++) { 327 var product = productData[i]; 328 var Quantity = 0; 329 Quantity = ClearErrorContextAndGetQuantities(product, Quantity); 330 if (product.PublishProductId != undefined && product.PublishProductId != null && parseInt(product.PublishProductId) > 0) { 331 if (product.AvailableQuantities == 0) { 332 CustomCart.prototype.ShowPreviouslyPurchaseError(product.PublishProductId); 333 CustomCart.prototype.SetFocusOnErrorQuantityBox(); 334 result = false; 335 } 336 else if (Quantity > product.AvailableQuantities) { 337 CustomCart.prototype.ShowMaxPurchaseErrorMessage(product.PublishProductId, product.AvailableQuantities); 338 result = false; 339 } 340 } 341 } 342 } 343 else if (isDataCaptureMatched != null && isDataCaptureMatched != undefined && isDataCaptureMatched.toLowerCase() === "false") { 344 for (var i = 0; i < productData.length; i++) { 345 var product = productData[i]; 346 var Quantites = 0; 347 Quantites = ClearErrorContextAndGetQuantities(product, Quantites); 348 if (product.PublishProductId != undefined && product.PublishProductId != null && parseInt(product.PublishProductId) > 0) { 349 if (Quantites >
349 product.MaximumQuantities) { 350 CustomCart.prototype.ShowMaxPurchaseErrorMessage(product.PublishProductId, product.MaximumQuantities); 351 result = false; 352 } 353 } 354 } 355 } 356 } 357 } 358 return result; 359 // Clear error messages of all line items and return quanities of line items per product. 360 function ClearErrorContextAndGetQuantities(product, Quantity) { 361 var inputs = document.querySelectorAll("input[name=Quantity][data-cart-ppid=\"" + product.PublishProductId + "\"]"); 362 if (inputs && inputs.length === 0) { 363 var anchorLink = document.querySelectorAll("a[data-cart-ppid=\"" + product.PublishProductId + "\"]"); 364 if (anchorLink.length > 0) { 365 anchorLink.forEach(function (anchor) { 366 var newQuantity = parseInt(anchor.getAttribute('data-quantity')); 367 if (!isNaN(newQuantity)) { 368 Quantity += newQuantity;
368 // Add the quantity from the anchor link to the total quantity 369 } 370 }); 371 } 372 } 373 else { 374 inputs.forEach(function (element) { 375 var externalId = $(element).attr('data-productguid'); 376 $(element).closest('.itemQuantity').find('#quantity_error_msg_' + externalId).text(""); 377 element.classList.remove('error'); 378 Quantity += parseInt($(element).attr('value')); 379 }); 380 document.querySelectorAll("#quantity_error_msg_" + product.PublishProductId).forEach(function (element) { 381 element.textContent = ""; 382 }); 383 } 384 return Quantity; 385 } 386 }; 387 return _shoppingCart; 388}()); 389$(document).ready(function () { 390 _shoppingCart.prototype.PageScripts(); 391 var notification = new ZnodeNotification(); 392 notification.DisplayNotificationMessages(); 393}); 394//Polyfill for bootstrap requiring data-target to be an id (#) in order to toggle 'collapsed' on the trigger element 395function ToggleCollapse(trigger) { 396 $(trigger).toggleClass("collapsed"); 397} 398//# sourceMappingURL=_shoppingCart.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.