1import { 2 validateInput 3} from "./chunk-W3RKY5WP.js"; 4import { 5 CFErrorWithCause, 6 CFFetcherError, 7 CFstackWithCauses, 8 Fetcher, 9 checkoutNonceParams, 10 fetchCheckoutNonce, 11 init_error_with_cause, 12 init_fetcher, 13 init_nonce 14} from "./chunk-5CDFUW2T.js"; 15import { 16 getSelectedVariant, 17 init_addToCart 18} from "./chunk-T2PQTTID.js"; 19import { 20 Cart, 21 atom, 22 batched, 23 cleanEmptyObjectKeys, 24 computed, 25 init_Cart, 26 init_general, 27 init_nanostores, 28 isElementVisibleOnViewport, 29 map, 30 onMount, 31 sleepMs 32} from "./chunk-WDQK6HWQ.js"; 33import { 34 validateValue 35} from "./chunk-4AIF3XZW.js"; 36import { 37 init_radio_v1 38} from "./chunk-MSPQW4FO.js"; 39import { 40 init_checkbox_v1, 41 init_input_v1 42} from "./chunk-USXYI4AH.js"; 43import { 44 addPageScroll, 45 closeOnClickOutside, 46 init_cfLodash, 47 init_cf_utils, 48 isEqual, 49 isEventInside, 50 removePageScroll, 51 uuidv4 52} from "./chunk-VVEAJADP.js"; 53import { 54 init_modal_v1 55} from "./chunk-L4HCJ2FE.js"; 56import { 57 CF2Component, 58 init_runtime, 59 registerComponent 60} from "./chunk-7CTAZQES.js"; 61import { 62 __privateAdd, 63 __privateGet, 64 __privateMethod, 65 __privateSet, 66 __publicField, 67 init_define_process 68} from "./chunk-RFSPGZ3L.js"; 69
70// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-tos-v1.ts 71init_define_process(); 72init_checkbox_v1(); 73init_runtime(); 74var CheckoutTosV1 = class extends CF2Component { 75 constructor(el, runtimeSel) { 76 super(el, runtimeSel); 77 } 78 onAcceptedChange(accepted) { 79 } 80 get accepted() { 81 return this.element.querySelector("input").checked; 82 } 83 mount() { 84 const input = this.element.querySelector("input"); 85 input.addEventListener("change", (event) => { 86 this.onAcceptedChange(!!event?.target?.checked); 87 }); 88 } 89}; 90registerComponent("CheckoutTos/V1", CheckoutTosV1); 91window["CheckoutTosV1"] = CheckoutTosV1; 92
93// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-multi-step-v2.ts 94init_define_process(); 95init_general(); 96init_runtime(); 97var CheckoutMultiStepV2 = class extends CF2Component { 98 constructor(el, runtimeSel) { 99 super(el, runtimeSel); 100 } 101 // TODO: For now we have to register it like this 102 // We can use a special syntax to register it in the future 103 // like @Handler(onStepChange) and process it in the build phase 104 onStepChange(oldStep, step) { 105 } 106 onValidateStep(step) { 107 } 108 mount() { 109 this.totalSteps = parseInt(this.totalSteps); 110 this.totalStepsArray = [...Array(this.totalSteps).keys()]; 111 const body = this.element.querySelectorAll(".elMultiStepBody"); 112 const headers = this.element.querySelectorAll(".elMultiStepHeader"); 113 this.steps = this.totalStepsArray.map((i) => { 114 return { 115 body: body[i], 116 header: headers[i] 117 }; 118 }); 119 headers.forEach((header, stepNumber) => { 120 header.addEventListener("click", (evt) => { 121 evt.preventDefault(); 122 this.setStep(stepNumber); 123 }); 124 }); 125 const buttons = this.element.querySelectorAll('[href="#!next-step"], [href="#!prev-step"], [href="#!open-step"]'); 126 buttons.forEach((button) => { 127 const href = button.getAttribute("href"); 128 if (href === "#!next-step") { 129 button.addEventListener("click", (evt) => { 130 evt.preventDefault(); 131 if (button.dataset.disabled == "true") return; 132 this.nextStep(); 133 }); 134 } else if (href === "#!prev-step") { 135 button.addEventListener("click", (evt) => { 136 evt.preventDefault(); 137 if (button.dataset.disabled == "true") return; 138 this.prevStep(); 139 }); 140 } 141 }); 142 Checkout.store.state.listen((state) => { 143 if (state === Checkout.StoreStates.INITIALIZED) { 144 document.addEventListener("keydown", (evt) => { 145 if (evt.isComposing || evt.keyCode === 229) return; 146 const activeStep = this.element.querySelector(".elMultiStepBody[data-step-state='active']"); 147 const checkoutElement = this.element.closest(".elCheckout"); 148 const activeNextStepButton = activeStep.querySelector('[href="#!next-step"]'); 149 if (evt.keyCode === 13 && activeNextStepButton && isElementVisibleOnViewport(checkoutElement, 20)) { 150 activeNextStepButton.focus(); 151 this.nextStep(); 152 } 153 }); 154 } 155 }); 156 Checkout.store.checkout.step.listen((step) => { 157 this.changeStep(step); 158 }); 159 } 160 changeStep(step) { 161 const activeUiStep = this.element.querySelector(".elMultiStepBody[data-step-state='active']").dataset.stepNumber; 162 const oldStep = this.convertUiStepToData(activeUiStep); 163 if (oldStep != step) { 164 this.setStepActive(oldStep, step); 165 } 166 } 167 async validateStep(step) { 168 return (await Promise.all(this.onValidateStep(step)))?.every((result) => result); 169 } 170 setStepActive(oldStep, step) { 171 this.onStepChange(oldStep, step); 172 this.totalStepsArray.forEach((stepNumber) => { 173 const isCurrentStep = stepNumber == step; 174 const activeText = isCurrentStep ? "active" : "inactive"; 175 this.steps[stepNumber].body.setAttribute("data-step-state", activeText); 176 const header = this.steps[stepNumber].header; 177 if (header) { 178 header.setAttribute("data-step-state", activeText); 179 if (header.children.length > 0) { 180 header.children[0].setAttribute("data-step-state", activeText); 181 } 182 } 183 }); 184 $([document.documentElement, document.body]).animate({ 185 scrollTop: $(this.element).offset().top - 50 186 }, 200); 187 } 188 setStep(step) { 189 Checkout.store.checkout.step.set(step); 190 } 191 async nextStep() { 192 const currentStep = Checkout.store.checkout.step.get(); 193 if (await this.validateStep(currentStep)) { 194 this.setStep(currentStep + 1); 195 } 196 } 197 prevStep() { 198 const step = Checkout.store.checkout.step.get() - 1; 199 this.setStep(step); 200 } 201 convertUiStepToData(step) { 202 return parseInt(step) - 1; 203 } 204}; 205registerComponent("CheckoutMultiStep/V2", CheckoutMultiStepV2); 206window["CheckoutMultiStepV2"] = CheckoutMultiStepV2; 207
208// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-coupon-form-v1.ts 209init_define_process(); 210init_input_v1(); 211init_runtime(); 212var CheckoutCouponFormV1 = class extends CF2Component { 213 constructor(el, runtimeSel) { 214 super(el, runtimeSel); 215 } 216 hydrate(store) { 217 this.checkoutStore = store; 218 this.isCouponReadySubs = Checkout.computed.isCouponReady.subscribe((isCouponReady) => { 219 this.updateElementWithCanApply(isCouponReady); 220 }); 221 this.currentCodeListen = this.checkoutStore.coupons.currentCode.listen((value) => { 222 if (this.checkoutStore.coupons.state.get() === Checkout.CouponStates.APPLIED) return; 223 this.setInputValue(value); 224 }); 225 this.couponsStateListen = this.checkoutStore.coupons.state.listen((state) => { 226 this.updateElementWithCouponState(state); 227 }); 228 this.renderElement(); 229 this.setupInputListeners(); 230 } 231 cleanup() { 232 this.isCouponReadySubs?.(); 233 this.currentCodeListen?.(); 234 this.couponsStateListen?.(); 235 } 236 updateElementWithCanApply(isCouponReady) { 237 if (isCouponReady) { 238 const appliedCode = Checkout.store.coupons.appliedCode.get(); 239 if (!appliedCode) { 240 this.enableCoupon(); 241 } 242 } else { 243 this.disableCoupon(); 244 } 245 } 246 updateElementWithCouponState(state) { 247 switch (state) { 248 case Checkout.CouponStates.READY: { 249 this.clearError(); 250 this.enableCoupon(); 251 this.hideAppliedChip(); 252 this.updateLoader(false); 253 break; 254 } 255 case Checkout.CouponStates.ERROR: { 256 this.setError(this.checkoutStore.coupons.errorMessage.get()); 257 this.enableCoupon(); 258 this.hideAppliedChip(); 259 this.updateLoader(false); 260 break; 261 } 262 case Checkout.CouponStates.APPLIED: { 263 this.clearError(); 264 this.disableCoupon(); 265 this.setInputValue(""); 266 this.showAppliedChip(this.checkoutStore.coupons.appliedCode.get()); 267 this.updateLoader(false); 268 break; 269 } 270 case Checkout.CouponStates.APPLYING: { 271 this.disableCoupon(); 272 this.clearError(); 273 this.hideAppliedChip(); 274 this.updateLoader(true); 275 break; 276 } 277 } 278 } 279 renderElement() { 280 const currentCode = this.checkoutStore.coupons.currentCode.get(); 281 const state = this.checkoutStore.coupons.state.get(); 282 if (state !== Checkout.CouponStates.APPLIED && currentCode) { 283 this.getCouponInput().value = currentCode; 284 this.getCouponInputContainer().classList.add("hasValue"); 285 } 286 this.updateElementWithCouponState(state); 287 const isCouponReady = Checkout.computed.isCouponReady.get(); 288 this.updateElementWithCanApply(isCouponReady); 289 } 290 setupInputListeners() { 291 const input = this.getCouponInput(); 292 if (input !== null) { 293 input.addEventListener("blur", () => { 294 this.checkoutStore.coupons.currentCode.set(input.value?.trim()); 295 }); 296 input.addEventListener("focus", () => { 297 if (!input.value) { 298 this.clearError(); 299 } 300 }); 301 input.addEventListener("change", () => { 302 this.clearError(); 303 }); 304 input.addEventListener("keydown", (evt) => { 305 if (evt.isComposing || evt.keyCode === 229) return; 306 if (evt.key === "Enter") { 307 evt.preventDefault(); 308 evt.stopPropagation(); 309 evt.stopImmediatePropagation(); 310 this.applyCoupon(); 311 } 312 }); 313 } 314 this.getCouponApplyButton().addEventListener("click", (ev) => { 315 ev.preventDefault(); 316 ev.stopPropagation(); 317 this.applyCoupon(); 318 }); 319 this.getCouponChipRemove()?.addEventListener("click", (ev) => { 320 ev.preventDefault(); 321 ev.stopPropagation(); 322 this.removeCoupon(); 323 }); 324 } 325 applyCoupon() { 326 const code = this.getCouponInput().value?.trim(); 327 this.checkoutStore.coupons.currentCode.set(code); 328 if (!code) { 329 this.checkoutStore.coupons.errorMessage.set(this.checkoutCouponFormErrorTexts.blankDiscountCodeError); 330 this.checkoutStore.coupons.state.set(Checkout.CouponStates.ERROR); 331 return; 332 } 333 window.dispatchEvent(new CustomEvent("ON_APPLY_COUPON", { 334 detail: { isCouponValidation: true } 335 })); 336 } 337 enableCoupon() { 338 this.getCouponApplyButton().setAttribute("data-disabled", false); 339 this.getCouponInput().removeAttribute("disabled"); 340 } 341 disableCoupon() { 342 this.getCouponApplyButton().setAttribute("data-disabled", true); 343 this.getCouponInput().setAttribute("disabled", true); 344 } 345 updateLoader(isLoading) { 346 if (isLoading == void 0) { 347 isLoading = this.lastLoading; 348 } else { 349 this.lastLoading = isLoading; 350 } 351 this.getCouponButtonContainer().dataset.loading = isLoading; 352 } 353 setInputValue(value) { 354 const input = this.getCouponInput(); 355 value = value?.trim(); 356 if (value) { 357 input.value = value; 358 this.getCouponInputContainer().classList.add("hasValue"); 359 } else { 360 input.value = ""; 361 this.getCouponInputContainer().classList.remove("hasValue"); 362 } 363 } 364 setError(message) { 365 this.getCouponErrorContainer().innerHTML = message; 366 this.getCouponInputContainer().classList.add("elInputError"); 367 this.getCouponIconContainer().classList.add("elInputError"); 368 } 369 clearError() { 370 this.getCouponErrorContainer().innerHTML = ""; 371 this.getCouponInputContainer().classList.remove("elInputError"); 372 this.getCouponIconContainer().classList.remove("elInputError"); 373 } 374 getCouponInput() { 375 return this.element.querySelector("input"); 376 } 377 getCouponInputContainer() { 378 return this.element.querySelector(".elCheckoutCouponCodeInput,.elCheckoutCartCouponCodeInput"); 379 } 380 getCouponApplyButton() { 381 return this.element.querySelector('.elCheckoutCouponCodeButton a[href="#check-coupon-code"],.elCheckoutCartCouponCodeButton a[href="#check-coupon-code"]'); 382 } 383 getCouponButtonContainer() { 384 return this.element.querySelector(".elCheckoutCouponCodeButton,.elCheckoutCartCouponCodeButton"); 385 } 386 getCouponErrorContainer() { 387 return this.element.querySelector(".elCouponCodeError"); 388 } 389 getCouponIconContainer() { 390 return this.element.querySelector(".elCheckoutCouponFormWrapper,.elCheckoutCartCouponFormWrapper"); 391 } 392 getCouponAppliedContainer() { 393 return this.element.querySelector(".elCheckoutCouponApplied"); 394 } 395 getCouponChipCode() { 396 return this.element.querySelector(".elCheckoutCouponChipCode"); 397 } 398 getCouponChipRemove() { 399 return this.element.querySelector(".elCheckoutCouponChipRemove"); 400 } 401 showAppliedChip(code) { 402 const container = this.getCouponAppliedContainer(); 403 if (!container || !code) return; 404 this.getCouponChipCode().textContent = code; 405 container.removeAttribute("hidden"); 406 } 407 hideAppliedChip() { 408 const container = this.getCouponAppliedContainer(); 409 if (!container) return; 410 this.getCouponChipCode().textContent = ""; 411 container.setAttribute("hidden", ""); 412 } 413 removeCoupon() { 414 this.hideAppliedChip(); 415 this.setInputValue(""); 416 this.checkoutStore.coupons.currentCode.set(""); 417 this.checkoutStore.coupons.appliedCode.set(""); 418 this.enableCoupon(); 419 window.dispatchEvent(new CustomEvent("ON_CLEAR_COUPON")); 420 } 421}; 422registerComponent("CheckoutCouponForm/V1", CheckoutCouponFormV1); 423window["CheckoutCouponFormV1"] = CheckoutCouponFormV1; 424
425// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-order-summary-v1.ts 426init_define_process(); 427init_cf_utils(); 428init_Cart(); 429
430// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-utils.ts 431init_define_process(); 432function hasPhysicalProducts(cart) { 433 return cart.items.some(({ product_id, variant_id }) => { 434 const product = globalThis.globalResourceData.productsById[product_id]; 435 const variant = globalThis.globalResourceData.variantsById[variant_id]; 436 let productType = variant?.product_type; 437 productType = productType || product?.product_type; 438 return productType == "physical"; 439 }); 440} 441function setupOrderSummaries(component) { 442 const pageOrderSummaries = document.querySelector('[data-page-element="CheckoutOrderSummary/V1"].elCheckout'); 443 if (pageOrderSummaries) { 444 component.getComponents("CheckoutOrderSummary/V1").forEach((c) => { 445 c.element.style.display = "none"; 446 }); 447 } 448} 449function scrollToFirstVisibleError(el) { 450 const $errorWrapper = el ? $(el) : $('[data-error-container="active"]:visible:first').closest("[data-error-wrapper]"); 451 const $checkoutFormError = $(".elCheckoutFormErrors:visible:first"); 452 if ($errorWrapper.length > 0) { 453 $("html, body").stop(true, true).animate( 454 { 455 scrollTop: $errorWrapper.offset().top - 100 456 }, 457 500 458 ); 459 } else if ($checkoutFormError.length > 0) { 460 $("html, body").stop(true, true).animate( 461 { 462 scrollTop: $checkoutFormError.offset().top - 100 463 }, 464 500 465 ); 466 } 467} 468var pageElementContexts = [ 469 { selector: '[data-page-element="ModalContainer/V1"]', context: "Modal" }, 470 { selector: '[data-page-element="ContentNode"]', context: "ContentNode" } 471]; 472function getCheckoutContext(checkoutElement) { 473 let found; 474 pageElementContexts.find(({ selector }) => { 475 found = checkoutElement.closest(selector); 476 return found; 477 }); 478 return found; 479} 480function checkValidCustomFields(checkoutElement) { 481 const contextElement = getCheckoutContext(checkoutElement); 482 if (!contextElement) return true; 483 contextElement.querySelectorAll(".elFormItemWrapper:not(.elCheckoutInput)").forEach((el) => { 484 el.classList.remove("elInputError", "elInputWarning", "elInputValid"); 485 }); 486 const formItems = $(contextElement).find(".elFormItem.required1:not(.elCheckoutInput .elFormItem.required1):visible").toArray().filter( 487 (input) => !!input.getAttribute("data-custom-type") || input.getAttribute("type") == "checkbox" 488 ); 489 const results = []; 490 formItems.forEach((input) => { 491 const result = validateInput(input); 492 results.push(result); 493 let thisInput = $(input); 494 const parent = thisInput.parents(".elFormItemWrapper"); 495 thisInput = parent.length && parent.find(".inputHolder, .borderHolder, .elCheckbox").length ? parent.find(".inputHolder, .borderHolder, .elCheckbox") : thisInput; 496 if (result) { 497 thisInput.css("border-color", "#4a8920"); 498 thisInput.css("border-width", "3px"); 499 } else { 500 thisInput.css("border-color", "#B91517"); 501 thisInput.css("border-width", "3px"); 502 } 503 }); 504 return results.every((r) => !!r); 505} 506function buildCustomFields() { 507 const fields = {}; 508 document.querySelectorAll( 509 "[type='custom_type'], select[data-custom-type], [type='custom_type'] [type='checkbox']" 510 ).forEach((input) => { 511 fields[input.name] = input.type === "checkbox" ? input.checked : input.value; 512 }); 513 return fields; 514} 515function collectLeads(contactDetails) { 516 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED, { contact: contactDetails }); 517 fetch("/user_pages/api/contacts", { 518 headers: { 519 Accept: "application/json", 520 "Content-Type": "application/json" 521 }, 522 method: "POST", 523 body: JSON.stringify(contactDetails) 524 }).then((response) => { 525 if (response.ok) { 526 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED_OK, { contact: contactDetails }); 527 document.getElementById("cfAR")?.setAttribute("data-leads-collected", "true"); 528 } 529 }); 530} 531var AVAILABLE_KLARNA_COUNTRIES = [ 532 "AU", 533 "AT", 534 "BE", 535 "CA", 536 "CZ", 537 "DK", 538 "FI", 539 "FR", 540 "DE", 541 "IE", 542 "IT", 543 "MX", 544 "NL", 545 "NZ", 546 "NO", 547 "PL", 548 "PT", 549 "RO", 550 "SK", 551 "ES", 552 "SE", 553 "CH", 554 "GB", 555 "US" 556]; 557var numberOfStepsInCheckout = () => { 558 const element = document.querySelector(".elCheckout[data-total-steps]"); 559 return parseInt(element.dataset["totalSteps"], 10); 560}; 561
562// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-order-summary-v1.ts 563init_runtime(); 564var CheckoutOrderSummaryV1 = class extends CF2Component { 565 constructor(el, runtimeSel) { 566 super(el, runtimeSel); 567 } 568 initializeWithStore(store, checkoutComputed) { 569 this.checkoutStore = store; 570 [ 571 checkoutComputed.checkoutCart, 572 this.checkoutStore.summary 573 ].forEach((store2) => { 574 store2.listen(() => { 575 this.renderSummaryDetails(); 576 }); 577 }); 578 if (Checkout.store.payment) { 579 nanostores.computed([Checkout.store.payment?.type], (paymentType) => paymentType == "apple-pay").subscribe((isDigitalWalletPaymentType) => { 580 if (isDigitalWalletPaymentType && !this.couponFieldEnabled) { 581 this.hide(); 582 } else { 583 this.show(); 584 } 585 }); 586 } 587 this.renderSummaryDetails(); 588 Checkout.store.state.listen((state) => { 589 if (state === Checkout.StoreStates.FILLING_FORM) { 590 this.renderSummaryDetails(); 591 } 592 }); 593 if (globalResourceData.resourceName == "checkout" && this.mobileBehavior != null) { 594 closeOnClickOutside(this.element, () => { 595 addPageScroll(); 596 this.element.classList.remove("elOrderSummaryMobileOpen"); 597 }); 598 } 599 } 600 show() { 601 this.element.classList.remove("elHide"); 602 } 603 hide() { 604 this.element.classList.add("elHide"); 605 } 606 renderSummaryDetails() { 607 const summary = this.checkoutStore.summary.get(); 608 this.state = summary.state; 609 this.summary = !summary.data ? {} : summary.data; 610 const is_checkout_page = globalResourceData.resourceName == "checkout"; 611 const cart = is_checkout_page ? Cart.stores.cartData.get() : Checkout.computed.checkoutCart.get(); 612 this.hasPhysicalProducts = hasPhysicalProducts(cart); 613 const cartItems = cart.items; 614 this.items = cartItems.map(({ product_id, variant_id, price_id, quantity }) => { 615 const variant = Checkout.variantsById[variant_id]; 616 const price = Checkout.pricesById[price_id]; 617 const product = Checkout.productsById[product_id]; 618 const variantNamesArray = variant.property_value_ids.map((property_value_id) => { 619 return product.all_properties_values[property_value_id]; 620 }); 621 return { 622 productName: is_checkout_page ? product.name : variant.name, 623 image_url: variant.image ?? product.image, 624 priceName: price.name, 625 imageUrl: variant.image ?? variant.images?.[0] ?? product.image ?? product.images?.[0], 626 variantNames: variantNamesArray.length > 0 ? variantNamesArray.join(", ") : void 0, 627 quantity 628 }; 629 }); 630 let couponForm = this.getComponent("CheckoutCouponForm/V1"); 631 couponForm?.cleanup(this.checkoutStore); 632 const checkoutCouponFormErrorTexts = couponForm?.checkoutCouponFormErrorTexts; 633 this.render(true); 634 this.hydrate(); 635 couponForm = this.getComponent("CheckoutCouponForm/V1"); 636 if (couponForm) couponForm.checkoutCouponFormErrorTexts = checkoutCouponFormErrorTexts; 637 couponForm?.hydrate(this.checkoutStore); 638 } 639 hydrate() { 640 this.element.querySelector(".elOrderSummaryHead")?.addEventListener("click", (evt) => { 641 evt.preventDefault(); 642 this.open = !this.open; 643 this.renderSummaryDetails(); 644 }); 645 this.element.querySelector(".elOrderSummaryCouponClear")?.addEventListener("click", (evt) => { 646 evt.preventDefault(); 647 this.checkoutStore.coupons.currentCode.set(""); 648 this.checkoutStore.coupons.appliedCode.set(""); 649 const onClearCouponEvent = new CustomEvent("ON_CLEAR_COUPON"); 650 window.dispatchEvent(onClearCouponEvent); 651 }); 652 this.element.querySelector(".elOrderSummaryHeader")?.addEventListener("click", () => { 653 if (this.element.classList.contains("elOrderSummaryMobileOpen")) { 654 addPageScroll(); 655 this.element.classList.remove("elOrderSummaryMobileOpen"); 656 } else { 657 removePageScroll(); 658 this.element.classList.add("elOrderSummaryMobileOpen"); 659 } 660 }); 661 } 662 remove() { 663 this.element.innerHTML = ""; 664 } 665 render(initializeChildrenInstances = false) { 666 const is_server = true; 667 const couponFieldEnabled = this.couponFieldEnabled ?? null; 668 const open = this.open ?? null; 669 const state = this.state ?? "ok"; 670 const items = this.items ?? []; 671 const summary = this.summary ?? {}; 672 const hasPhysicalProducts2 = this.hasPhysicalProducts ?? false; 673 const billingFields = this.billingFields ?? null; 674 const shippingFields = this.shippingFields ?? null; 675 const mobileBehavior = this.mobileBehavior ?? null; 676 const summaryTexts = this.summaryTexts ?? null; 677 const linkWithCheckout = this.element.getAttribute("data-param-linkWithCheckout"); 678 const linkedCheckoutId = this.element.getAttribute("data-param-linkedCheckoutId"); 679 const checkoutCouponFormErrorTexts = this.element.getAttribute("data-param-checkoutCouponFormErrorTexts"); 680 let html = ""; 681 { 682 if (globalResourceData?.resourceName == "checkout") { 683 if (linkWithCheckout) { 684 html += `<div class="elCheckoutWrapper" ygg-render="replace">`; 685 if (linkWithCheckout == "true" || linkWithCheckout == true) { 686 html += `<div class="elCheckoutOuterFrame"></div>`; 687 } 688 const is_checkout_page = globalResourceData?.resourceName == "checkout"; 689 if (is_checkout_page) { 690 html += `<div class="elOrderSummaryHeader`; 691 if (CF2Blank(mobileBehavior) || CF2Blank(true)) { 692 html += ` forceHide`; 693 } 694 html += `"><div class="elOrderSummaryHeaderClosed"><div><span>${summaryTexts?.viewOrderSummary}</span><i class="fas fa-chevron-down"></i></div>`; 695 if (state == "ok") { 696 html += `<span class="elOrderSummaryHeaderTotal">`; 697 if (summary?.interim) { 698 html += `${summary?.interim?.formatted}`; 699 } else { 700 html += `${summary?.total?.formatted}`; 701 } 702 html += `</span>`;
703 } 704 html += `</div><div class="elOrderSummaryHeaderOpenned"><span>${summaryTexts?.closeOrderSummary}</span><i class="fas fa-chevron-up"></i></div></div>`; 705 html += `<div class="elOrderSummaryBody elCheckoutSummaryResource"><div class="elCartOrderSummaryItems">`; 706 const c0 = items; 707 const fl1 = new CF2ForloopDrop(c0.length); 708 for (const item of c0) { 709 const forloop = fl1; 710 html += `<div class="elCartOrderSummaryRow"><div class="elCartOrderSummaryRowLeft">`; 711 const imageUrl = item?.imageUrl; 712 html += `<div class="elCartOrderSummaryProductImageContainer `; 713 if (CF2Blank(imageUrl)) { 714 html += `elCartOrderSummaryEmptyImageContainer`; 715 } 716 html += `">`; 717 if (imageUrl) { 718 html += `<div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 719 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 720 html += ` forceHide`; 721 } 722 html += `" data-liquid-replace="item">`; 723 if (imageUrl || !CF2Blank(null)) { 724 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 725 } else if (false) { 726 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 727 } 728 html += `</div>`; 729 } 730 if (item?.quantity && item?.quantity > 0) { 731 html += `<div class="elCartOrderSummaryProductImageBadge">${item?.quantity}</div>`; 732 } 733 html += `</div><div class="elCartOrderSummaryRowLeftTextContainer"><div class="elCartOrderSummaryWithImageSubRow elOrderSummaryProductNameRow">${item?.productName}</div>`; 734 if (item?.variantNames) { 735 html += `<div class="elCartOrderSummaryWithImageSubRow elOrderSummaryProductDescriptionRow">${item?.variantNames}</div>`; 736 } 737 html += `</div></div><div class="elCartOrderSummaryRowRight"><span>${item?.priceName}</span></div></div>`; 738 forloop.next(); 739 } 740 html += `</div><div class="elOrderSummaryTotals">`; 741 if (couponFieldEnabled && couponFieldEnabled != "false") { 742 html += `<hr class="elCartOrderSummaryDivider"/>`; 743 html += `<div data-page-element="CheckoutCouponForm/V1" class="elCheckoutCouponFormContainer id-CheckoutCouponForm/V1" data-liquid-replace="item">`; 744 const is_checkout_page2 = globalResourceData?.resourceName == "checkout"; 745 if (is_checkout_page2) { 746 html += `<div class="elCheckoutCartCouponFormWrapper">`; 747 const inputText = summaryTexts?.coupon?.input ?? "Discount Code"; 748 const buttonText = summaryTexts?.coupon?.button ?? "Add"; 749 html += `<div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCartCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCartCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCartCouponCodeButton id-Button/V1" data-liquid-replace="item">`; 750 const label_key = "checkcouponcode"; 751 const label_key_slice = "checkc"; 752 let data_content_key = ""; 753 data_content_key = "checkcouponcode"; 754 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 755 } else { 756 html += `<div class="elCheckoutCouponFormWrapper">`; 757 const inputText = summaryTexts?.coupon?.input ?? "Enter Coupon"; 758 const buttonText = summaryTexts?.coupon?.button ?? "Apply"; 759 html += `<i data-page-element="IconNode" class="fa-fw fa_icon fa_prepe
759nded elCheckoutCouponTagIcon fa fa-tag id-IconNode"></i><div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCouponCodeButton id-Button/V1" data-liquid-replace="item">`; 760 const label_key = "checkcouponcode"; 761 const label_key_slice = "checkc"; 762 let data_content_key = ""; 763 data_content_key = "checkcouponcode"; 764 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 765 } 766 html += `<paragraph-v1 class="elCouponCodeError"></paragraph-v1><div class="elCheckoutCouponApplied" hidden="true"><span class="elCheckoutCouponChip"><i class="fas fa-tag elCheckoutCouponChipIcon"></i><span class="elCheckoutCouponChipCode"></span><button type="button" class="elCheckoutCouponChipRemove" aria-label="${summaryTexts?.coupon?.remove ?? "Remove c
766oupon"}"><i class="fas fa-times"></i></button></span></div></div>`; 767 } 768 html += `<hr class="elCartOrderSummaryDivider"/><div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.subtotal}</div><div class="elOrderSummaryRowRight">`; 769 if (summary?.subtotal) { 770 html += `${summary?.subtotal?.formatted}`; 771 } else { 772 html += `--`; 773 } 774 html += `</div></div>`; 775 if (summary?.discount && summary?.discount?.amount > 0 && summary?.discounts?.length > 0) { 776 const c2 = summary.discounts; 777 const fl3 = new CF2ForloopDrop(c2.length); 778 for (const discount of c2) { 779 const forloop = fl3; 780 html += `<div class="elOrderSummaryRow elOrderSummaryDiscountRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.discount} `; 781 if (discount?.code) { 782 html += `(`; 783 html += `${discount?.code})`; 784 } 785 html += `<span class="elOrderSummaryCouponClear">X</span></div><div class="elOrderSummaryRowRight">${summary?.discount?.formatted}</div></div>`; 786 forloop.next(); 787 } 788 } 789 if (hasPhysicalProducts2) { 790 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.shipping}</div><div class="elOrderSummaryRowRight">`; 791 if (CF2Blank(summary) || CF2Blank(summary?.shipping) || CF2Blank(summary?.shipping?.amount)) { 792 html += `${summaryTexts?.waitingForAddress}`; 793 } else if (summary?.shipping?.amount > 0) { 794 html += `${summary?.shipping?.formatted}`; 795 } else { 796 html += `${summaryTexts?.free}`; 797 } 798 html += `</div></div>`; 799 } 800 html += `<hr class="elCartOrderSummaryDivider"/><div class="elOrderSummaryRow"><div class="elCartOrderSummaryRowLeftTextContainer"><div class="elCartOrderSummarySubRow elCartOrderSummarySubRowTotalText">${summaryTexts?.total}</div>`; 801 if (summary?.tax && summary?.tax?.amount > 0) { 802 html += `<div class="elCartOrderSummarySubRow elCartOrderSummarySubRowTaxesText">${summaryTexts?.including} ${summary?.tax?.formatted} ${summaryTexts?.inTaxes}</div>`; 803 } 804 html += `</div><div class="elCartOrderSummaryRowRight"><span class="elCartOrderSummarySubRowTotalPrice">`; 805 if (summary?.interim) { 806 html += `${summary?.interim?.formatted}`; 807 } else { 808 if (summary?.total) { 809 html += `${summary?.total?.formatted}`; 810 } else { 811 html += `--`; 812 } 813 } 814 html += `</span></div></div>`; 815 if (summary?.recurring && summary?.recurring?.showThen) { 816 html += `<div class="elOrderSummaryRow elOrderSummaryRecurringRow"><div class="elCartOrderSummaryRowLeftTextContainer"><div class="elCartOrderSummarySubRow">${summaryTexts?.then}</div></div><div class="elCartOrderSummaryRowRight">`; 817 if (summary?.recurring?.discount?.amount > 0) { 818 html += `<span class="elOrderSummaryRecurringStrikethrough">${summary?.recurring?.before_formatted}</span>`; 819 } 820 html += `${summary?.recurring?.total?.formatted}${summary?.recurring?.interval}</div></div>`; 821 } 822 html += `</div></div>`; 823 } else { 824 html += `<div class="elOrderSummaryHead"><div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft"><i class="fa fa-shopping-basket"></i><span class="elOrderSummaryHeadText">${summaryTexts?.title}</span></div><div class="elOrderSummaryRowRight">`; 825 if (state == "waiting") { 826 html += `<span> ${summaryTexts?.details} <i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span>`; 827 } else if (state == "calculating") { 828 html += `<span> ${summaryTexts?.calculating} <i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span>`;
829 } else if (state == "error") { 830 html += `<span> ${summaryTexts?.error} <i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span>`; 831 } 832 if (open) { 833 html += `<i class="fas fa-chevron-up elOrderSummaryToggleable"></i>`; 834 } else { 835 if (state == "ok") { 836 html += `<span class="elOrderSummaryTotalPrice">`; 837 if (summary?.interim) { 838 html += `${summary?.interim?.formatted}`; 839 } else { 840 html += `${summary?.total?.formatted}`; 841 } 842 html += `</span>`; 843 } 844 html += `<i class="fas fa-chevron-down elOrderSummaryToggleable"></i>`; 845 } 846 html += `</div></div></div>`; 847 if (open) { 848 if (couponFieldEnabled && couponFieldEnabled != "false") { 849 html += `<div data-page-element="CheckoutCouponForm/V1" class="elCheckoutCouponFormContainer id-CheckoutCouponForm/V1" data-liquid-replace="item">`; 850 const is_checkout_page2 = globalResourceData?.resourceName == "checkout"; 851 if (is_checkout_page2) { 852 html += `<div class="elCheckoutCartCouponFormWrapper">`; 853 const inputText = summaryTexts?.coupon?.input ?? "Discount Code"; 854 const buttonText = summaryTexts?.coupon?.button ?? "Add"; 855 html += `<div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCartCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCartCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCartCouponCodeButton id-Button/V1" data-liquid-replace="item">`; 856 const label_key = "checkcouponcode"; 857 const label_key_slice = "checkc"; 858 let data_content_key = ""; 859 data_content_key = "checkcouponcode"; 860 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 861 } else { 862 html += `<div class="elCheckoutCouponFormWrapper">`; 863 const inputText = summaryTexts?.coupon?.input ?? "Enter Coupon"; 864 const buttonText = summaryTexts?.coupon?.button ?? "Apply"; 865 html += `<i data-page-element="IconNode" class="fa-fw fa_icon fa_prepended elCheckoutCouponTagIcon fa fa-tag id-IconNode"></i><div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCouponCodeButton i
865d-Button/V1" data-liquid-replace="item">`; 866 const label_key = "checkcouponcode"; 867 const label_key_slice = "checkc"; 868 let data_content_key = ""; 869 data_content_key = "checkcouponcode"; 870 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 871 } 872 html += `<paragraph-v1 class="elCouponCodeError"></paragraph-v1><div class="elCheckoutCouponApplied" hidden="true"><span class="elCheckoutCouponChip"><i class="fas fa-tag elCheckoutCouponChipIcon"></i><span class="elCheckoutCouponChipCode"></span><button type="button" class="elCheckoutCouponChipRemove" aria-label="${summaryTexts?.coupon?.remove ?? "Remove c
872oupon"}"><i class="fas fa-times"></i></button></span></div></div>`; 873 } 874 html += `<div class="elOrderSummaryBody">`; 875 const c4 = items; 876 const fl5 = new CF2ForloopDrop(c4.length); 877 for (const item of c4) { 878 const forloop = fl5; 879 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${item?.productName}</div><div class="elOrderSummaryRowRight">`; 880 if (item?.quantity && item?.quantity > 1) { 881 html += `<span class="elOrderSummaryQuantity">${summaryTexts?.qty} ${item?.quantity}</span>`; 882 } 883 html += `<span>${item?.priceName}</span></div></div>`; 884 forloop.next(); 885 } 886 if (state == "ok") { 887 if (summary?.upcoming_invoice && summary?.upcoming_invoice?.line_items?.length) { 888 html += `<hr class="elOrderSummaryDivider"/>`; 889 const c6 = summary.upcoming_invoice.line_items; 890 const fl7 = new CF2ForloopDrop(c6.length); 891 for (const item of c6) { 892 const forloop = fl7; 893 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${item?.variant_name}</div><div class="elOrderSummaryRowRight">`; 894 if (item?.quantity && item?.quantity > 1) { 895 html += `<span class="elOrderSummaryQuantity">${summaryTexts?.qty} ${item?.quantity}</span>`; 896 } 897 html += `<span>${item?.formatted}</span></div></div>`; 898 forloop.next(); 899 } 900 } 901 html += `<hr class="elOrderSummaryDivider"/>`; 902 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.taxes}</div><div class="elOrderSummaryRowRight">`; 903 if (summary?.tax?.formatted && summary?.shipping?.amount >= 0) { 904 html += `${summary?.tax?.formatted}`; 905 } else { 906 html += ` -- `; 907 } 908 html += `</div></div>`; 909 if (summary?.discount?.amount > 0 && summary?.discounts?.length > 0) { 910 const c8 = summary.discounts; 911 const fl9 = new CF2ForloopDrop(c8.length); 912 for (const discount of c8) { 913 const forloop = fl9; 914 html += `<div class="elOrderSummaryRow elOrderSummaryDiscountRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.discount} `; 915 if (discount?.code) { 916 html += `(`; 917 html += `${discount?.code})`; 918 } 919 html += `<span class="elOrderSummaryCouponClear">X</span></div><div class="elOrderSummaryRowRight">${summary?.discount?.formatted}</div></div>`; 920 forloop.next(); 921 } 922 } 923 if (hasPhysicalProducts2) { 924 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.shipping}</div><div class="elOrderSummaryRowRight">`; 925 if (summary?.shipping?.amount > 0) { 926 html += `${summary?.shipping?.formatted}`; 927 } else if (summary?.shipping?.amount <= 0) { 928 html += `${summaryTexts?.free}`; 929 } else { 930 html += ` -- `; 931 } 932 html += `</div></div>`; 933 } 934 html += `<hr class="elOrderSummaryDivider"/>`; 935 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.total}`; 936 if (summary?.next_invoice_date) { 937 html += ` - `; 938 html += `<span class="elOrderSummaryNextInvoice"> ${summaryTexts?.dueOn} ${summary?.next_invoice_date}</span>`; 939 } 940 html += `</div><div class="elOrderSummaryRowRight"><span class="elOrderSummaryTotalPrice">`; 941 if (summary?.interim) { 942 html += `${summary?.interim?.formatted}`; 943 } else { 944 html += `${summary?.total?.formatted}`; 945 } 946 html += `</span></div></div>`; 947 if (summary?.recurring && summary?.recurring?.showThen) { 948 html += `<div class="elOrderSummaryRow elOrderSummaryRecurringRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.then}</div><div class="elOrderSummaryRowRight">`; 949 if (summary?.recurring?.discount?.amount > 0) { 950 html += `<span class="elOrderSummaryRecurringStrikethrough">${summary?.recurring?.before_formatted}</span>`;
951 } 952 html += `${summary?.recurring?.total?.formatted}${summary?.recurring?.interval}</div></div>`; 953 } 954 } 955 html += `</div>`; 956 } 957 } 958 html += `</div>`; 959 } 960 } else { 961 html += `<div class="elCheckoutWrapper" ygg-render="replace">`; 962 if (linkWithCheckout == "true" || linkWithCheckout == true) { 963 html += `<div class="elCheckoutOuterFrame"></div>`; 964 } 965 const is_checkout_page = globalResourceData?.resourceName == "checkout"; 966 if (is_checkout_page) { 967 html += `<div class="elOrderSummaryHeader`; 968 if (CF2Blank(mobileBehavior) || CF2Blank(true)) { 969 html += ` forceHide`; 970 } 971 html += `"><div class="elOrderSummaryHeaderClosed"><div><span>${summaryTexts?.viewOrderSummary}</span><i class="fas fa-chevron-down"></i></div>`; 972 if (state == "ok") { 973 html += `<span class="elOrderSummaryHeaderTotal">`; 974 if (summary?.interim) { 975 html += `${summary?.interim?.formatted}`; 976 } else { 977 html += `${summary?.total?.formatted}`; 978 } 979 html += `</span>`; 980 } 981 html += `</div><div class="elOrderSummaryHeaderOpenned"><span>${summaryTexts?.closeOrderSummary}</span><i class="fas fa-chevron-up"></i></div></div>`; 982 html += `<div class="elOrderSummaryBody elCheckoutSummaryResource"><div class="elCartOrderSummaryItems">`; 983 const c10 = items; 984 const fl11 = new CF2ForloopDrop(c10.length); 985 for (const item of c10) { 986 const forloop = fl11; 987 html += `<div class="elCartOrderSummaryRow"><div class="elCartOrderSummaryRowLeft">`; 988 const imageUrl = item?.imageUrl; 989 html += `<div class="elCartOrderSummaryProductImageContainer `; 990 if (CF2Blank(imageUrl)) { 991 html += `elCartOrderSummaryEmptyImageContainer`; 992 } 993 html += `">`; 994 if (imageUrl) { 995 html += `<div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 996 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 997 html += ` forceHide`; 998 } 999 html += `" data-liquid-replace="item">`; 1000 if (imageUrl || !CF2Blank(null)) { 1001 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 1002 } else if (false) { 1003 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 1004 } 1005 html += `</div>`; 1006 } 1007 if (item?.quantity && item?.quantity > 0) { 1008 html += `<div class="elCartOrderSummaryProductImageBadge">${item?.quantity}</div>`; 1009 } 1010 html += `</div><div class="elCartOrderSummaryRowLeftTextContainer"><div class="elCartOrderSummaryWithImageSubRow elOrderSummaryProductNameRow">${item?.productName}</div>`; 1011 if (item?.variantNames) { 1012 html += `<div class="elCartOrderSummaryWithImageSubRow elOrderSummaryProductDescriptionRow">${item?.variantNames}</div>`; 1013 } 1014 html += `</div></div><div class="elCartOrderSummaryRowRight"><span>${item?.priceName}</span></div></div>`; 1015 forloop.next(); 1016 } 1017 html += `</div><div class="elOrderSummaryTotals">`; 1018 if (couponFieldEnabled && couponFieldEnabled != "false") { 1019 html += `<hr class="elCartOrderSummaryDivider"/>`; 1020 html += `<div data-page-element="CheckoutCouponForm/V1" class="elCheckoutCouponFormContainer id-CheckoutCouponForm/V1" data-liquid-replace="item">`; 1021 const is_checkout_page2 = globalResourceData?.resourceName == "checkout"; 1022 if (is_checkout_page2) { 1023 html += `<div class="elCheckoutCartCouponFormWrapper">`; 1024 const inputText = summaryTexts?.coupon?.input ?? "Discount Code"; 1025 const buttonText = summaryTexts?.coupon?.button ?? "Add"; 1026 html += `<div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCartCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCartCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCartCouponCodeButton i
1026d-Button/V1" data-liquid-replace="item">`; 1027 const label_key = "checkcouponcode"; 1028 const label_key_slice = "checkc"; 1029 let data_content_key = ""; 1030 data_content_key = "checkcouponcode"; 1031 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 1032 } else { 1033 html += `<div class="elCheckoutCouponFormWrapper">`; 1034 const inputText = summaryTexts?.coupon?.input ?? "Enter Coupon"; 1035 const buttonText = summaryTexts?.coupon?.button ?? "Apply"; 1036 html += `<i data-page-element="IconNode" class="fa-fw fa_icon fa_prepended elCheckoutCouponTagIcon fa fa-tag id-IconNode"></i><div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCouponCodeButton id-Button/V1" data-liquid-replace="item">`; 1037 const label_key = "checkcouponcode"; 1038 const label_key_slice = "checkc"; 1039 let data_content_key = ""; 1040 data_content_key = "checkcouponcode"; 1041 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 1042 } 1043 html += `<paragraph-v1 class="elCouponCodeError"></paragraph-v1><div class="elCheckoutCouponApplied" hidden="true"><span class="elCheckoutCouponChip"><i class="fas fa-tag elCheckoutCouponChipIcon"></i><span class="elCheckoutCouponChipCode"></span><button type="button" class="elCheckoutCouponChipRemove" aria-label="${summaryTexts?.coupon?.remove ?? "Remove c
1043oupon"}"><i class="fas fa-times"></i></button></span></div></div>`; 1044 } 1045 html += `<hr class="elCartOrderSummaryDivider"/><div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.subtotal}</div><div class="elOrderSummaryRowRight">`; 1046 if (summary?.subtotal) { 1047 html += `${summary?.subtotal?.formatted}`; 1048 } else { 1049 html += `--`; 1050 } 1051 html += `</div></div>`; 1052 if (summary?.discount && summary?.discount?.amount > 0 && summary?.discounts?.length > 0) { 1053 const c12 = summary.discounts; 1054 const fl13 = new CF2ForloopDrop(c12.length); 1055 for (const discount of c12) { 1056 const forloop = fl13; 1057 html += `<div class="elOrderSummaryRow elOrderSummaryDiscountRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.discount} `; 1058 if (discount?.code) { 1059 html += `(`; 1060 html += `${discount?.code})`; 1061 } 1062 html += `<span class="elOrderSummaryCouponClear">X</span></div><div class="elOrderSummaryRowRight">${summary?.discount?.formatted}</div></div>`; 1063 forloop.next(); 1064 } 1065 } 1066 if (hasPhysicalProducts2) { 1067 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.shipping}</div><div class="elOrderSummaryRowRight">`; 1068 if (CF2Blank(summary) || CF2Blank(summary?.shipping) || CF2Blank(summary?.shipping?.amount)) { 1069 html += `${summaryTexts?.waitingForAddress}`; 1070 } else if (summary?.shipping?.amount > 0) { 1071 html += `${summary?.shipping?.formatted}`; 1072 } else { 1073 html += `${summaryTexts?.free}`; 1074 } 1075 html += `</div></div>`; 1076 } 1077 html += `<hr class="elCartOrderSummaryDivider"/><div class="elOrderSummaryRow"><div class="elCartOrderSummaryRowLeftTextContainer"><div class="elCartOrderSummarySubRow elCartOrderSummarySubRowTotalText">${summaryTexts?.total}</div>`; 1078 if (summary?.tax && summary?.tax?.amount > 0) { 1079 html += `<div class="elCartOrderSummarySubRow elCartOrderSummarySubRowTaxesText">${summaryTexts?.including} ${summary?.tax?.formatted} ${summaryTexts?.inTaxes}</div>`; 1080 } 1081 html += `</div><div class="elCartOrderSummaryRowRight"><span class="elCartOrderSummarySubRowTotalPrice">`; 1082 if (summary?.interim) { 1083 html += `${summary?.interim?.formatted}`; 1084 } else { 1085 if (summary?.total) { 1086 html += `${summary?.total?.formatted}`; 1087 } else { 1088 html += `--`; 1089 } 1090 } 1091 html += `</span></div></div>`; 1092 if (summary?.recurring && summary?.recurring?.showThen) { 1093 html += `<div class="elOrderSummaryRow elOrderSummaryRecurringRow"><div class="elCartOrderSummaryRowLeftTextContainer"><div class="elCartOrderSummarySubRow">${summaryTexts?.then}</div></div><div class="elCartOrderSummaryRowRight">`; 1094 if (summary?.recurring?.discount?.amount > 0) { 1095 html += `<span class="elOrderSummaryRecurringStrikethrough">${summary?.recurring?.before_formatted}</span>`; 1096 } 1097 html += `${summary?.recurring?.total?.formatted}${summary?.recurring?.interval}</div></div>`; 1098 } 1099 html += `</div></div>`; 1100 } else { 1101 html += `<div class="elOrderSummaryHead"><div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft"><i class="fa fa-shopping-basket"></i><span class="elOrderSummaryHeadText">${summaryTexts?.title}</span></div><div class="elOrderSummaryRowRight">`; 1102 if (state == "waiting") { 1103 html += `<span> ${summaryTexts?.details} <i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span>`; 1104 } else if (state == "calculating") { 1105 html += `<span> ${summaryTexts?.calculating} <i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span>`; 1106 } else if (state == "error") { 1107 html += `<span> ${summaryTexts?.error} <i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span>`;
1108 } 1109 if (open) { 1110 html += `<i class="fas fa-chevron-up elOrderSummaryToggleable"></i>`; 1111 } else { 1112 if (state == "ok") { 1113 html += `<span class="elOrderSummaryTotalPrice">`; 1114 if (summary?.interim) { 1115 html += `${summary?.interim?.formatted}`; 1116 } else { 1117 html += `${summary?.total?.formatted}`; 1118 } 1119 html += `</span>`; 1120 } 1121 html += `<i class="fas fa-chevron-down elOrderSummaryToggleable"></i>`; 1122 } 1123 html += `</div></div></div>`; 1124 if (open) { 1125 if (couponFieldEnabled && couponFieldEnabled != "false") { 1126 html += `<div data-page-element="CheckoutCouponForm/V1" class="elCheckoutCouponFormContainer id-CheckoutCouponForm/V1" data-liquid-replace="item">`; 1127 const is_checkout_page2 = globalResourceData?.resourceName == "checkout"; 1128 if (is_checkout_page2) { 1129 html += `<div class="elCheckoutCartCouponFormWrapper">`; 1130 const inputText = summaryTexts?.coupon?.input ?? "Discount Code"; 1131 const buttonText = summaryTexts?.coupon?.button ?? "Add"; 1132 html += `<div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCartCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCartCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCartCouponCodeButton id-Button/V1" data-liquid-replace="item">`; 1133 const label_key = "checkcouponcode"; 1134 const label_key_slice = "checkc"; 1135 let data_content_key = ""; 1136 data_content_key = "checkcouponcode"; 1137 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 1138 } else { 1139 html += `<div class="elCheckoutCouponFormWrapper">`; 1140 const inputText = summaryTexts?.coupon?.input ?? "Enter Coupon"; 1141 const buttonText = summaryTexts?.coupon?.button ?? "Apply"; 1142 html += `<i data-page-element="IconNode" class="fa-fw fa_icon fa_prepended elCheckoutCouponTagIcon fa fa-tag id-IconNode"></i><div data-page-element="Input/V1" class="elFormItemWrapper elInputWrapper de-input-block elCheckoutCouponCodeInput id-Input/V1 labelInside" data-content="" type="coupon_codes" data-liquid-replace="item"><input class="elFormItem elInput inputHolder " value="" type="text" name="coupon_codes" pattern="" autocomplete="" inputtype="" data-prevent-submit="" data-prevent-garlic="true" placeholder="${inputText}" maxlength=""/><div class="elLabel"><div class="borderHolder"></div><div class="borderHolder labelText"><label>${inputText}</label></div><div class="borderHolder"></div></div><div class="inputHolder" data-input-status-type="true" data-error-container="true"></div><div class="input-icon"><i class="fas fa-exclamation"></i></div></div><div class="elCheckoutCouponCodeButtonWrapper"><div data-page-element="Button/V1" class="elBTN elCheckoutCouponCodeButton i
1142d-Button/V1" data-liquid-replace="item">`; 1143 const label_key = "checkcouponcode"; 1144 const label_key_slice = "checkc"; 1145 let data_content_key = ""; 1146 data_content_key = "checkcouponcode"; 1147 html += `<a target="_self" href="#check-coupon-code" class="elButton" aria-label="" data-disabled="false" data-show-button-ids="" data-hide-button-ids="" data-on-submit-go-to="" data-param-submittingText="Submitting..." data-content="" data-style-guide-button="" rel="noopener"><span class="elButtonMain"><i class="fas fa-spinner fa-spin elButtonSpinner elButtonText"></i><span class="elButtonMainText elButtonText">${buttonText}</span></span><span class="elButtonSub"></span></a></div><span class="elCheckoutCouponCodeButtonLoading"><i style="margin:0px 10px;" class="fas fa-spinner fa-spin"></i></span></div></div>`; 1148 } 1149 html += `<paragraph-v1 class="elCouponCodeError"></paragraph-v1><div class="elCheckoutCouponApplied" hidden="true"><span class="elCheckoutCouponChip"><i class="fas fa-tag elCheckoutCouponChipIcon"></i><span class="elCheckoutCouponChipCode"></span><button type="button" class="elCheckoutCouponChipRemove" aria-label="${summaryTexts?.coupon?.remove ?? "Remove c
1149oupon"}"><i class="fas fa-times"></i></button></span></div></div>`; 1150 } 1151 html += `<div class="elOrderSummaryBody">`; 1152 const c14 = items; 1153 const fl15 = new CF2ForloopDrop(c14.length); 1154 for (const item of c14) { 1155 const forloop = fl15; 1156 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${item?.productName}</div><div class="elOrderSummaryRowRight">`; 1157 if (item?.quantity && item?.quantity > 1) { 1158 html += `<span class="elOrderSummaryQuantity">${summaryTexts?.qty} ${item?.quantity}</span>`; 1159 } 1160 html += `<span>${item?.priceName}</span></div></div>`; 1161 forloop.next(); 1162 } 1163 if (state == "ok") { 1164 if (summary?.upcoming_invoice && summary?.upcoming_invoice?.line_items?.length) { 1165 html += `<hr class="elOrderSummaryDivider"/>`; 1166 const c16 = summary.upcoming_invoice.line_items; 1167 const fl17 = new CF2ForloopDrop(c16.length); 1168 for (const item of c16) { 1169 const forloop = fl17; 1170 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${item?.variant_name}</div><div class="elOrderSummaryRowRight">`; 1171 if (item?.quantity && item?.quantity > 1) { 1172 html += `<span class="elOrderSummaryQuantity">${summaryTexts?.qty} ${item?.quantity}</span>`; 1173 } 1174 html += `<span>${item?.formatted}</span></div></div>`; 1175 forloop.next(); 1176 } 1177 } 1178 html += `<hr class="elOrderSummaryDivider"/>`; 1179 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.taxes}</div><div class="elOrderSummaryRowRight">`; 1180 if (summary?.tax?.formatted && summary?.shipping?.amount >= 0) { 1181 html += `${summary?.tax?.formatted}`; 1182 } else { 1183 html += ` -- `; 1184 } 1185 html += `</div></div>`; 1186 if (summary?.discount?.amount > 0 && summary?.discounts?.length > 0) { 1187 const c18 = summary.discounts; 1188 const fl19 = new CF2ForloopDrop(c18.length); 1189 for (const discount of c18) { 1190 const forloop = fl19; 1191 html += `<div class="elOrderSummaryRow elOrderSummaryDiscountRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.discount} `; 1192 if (discount?.code) { 1193 html += `(`; 1194 html += `${discount?.code})`; 1195 } 1196 html += `<span class="elOrderSummaryCouponClear">X</span></div><div class="elOrderSummaryRowRight">${summary?.discount?.formatted}</div></div>`; 1197 forloop.next(); 1198 } 1199 } 1200 if (hasPhysicalProducts2) { 1201 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.shipping}</div><div class="elOrderSummaryRowRight">`; 1202 if (summary?.shipping?.amount > 0) { 1203 html += `${summary?.shipping?.formatted}`; 1204 } else if (summary?.shipping?.amount <= 0) { 1205 html += `${summaryTexts?.free}`; 1206 } else { 1207 html += ` -- `; 1208 } 1209 html += `</div></div>`; 1210 } 1211 html += `<hr class="elOrderSummaryDivider"/>`; 1212 html += `<div class="elOrderSummaryRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.total}`; 1213 if (summary?.next_invoice_date) { 1214 html += ` - `; 1215 html += `<span class="elOrderSummaryNextInvoice"> ${summaryTexts?.dueOn} ${summary?.next_invoice_date}</span>`; 1216 } 1217 html += `</div><div class="elOrderSummaryRowRight"><span class="elOrderSummaryTotalPrice">`; 1218 if (summary?.interim) { 1219 html += `${summary?.interim?.formatted}`; 1220 } else { 1221 html += `${summary?.total?.formatted}`; 1222 } 1223 html += `</span></div></div>`; 1224 if (summary?.recurring && summary?.recurring?.showThen) { 1225 html += `<div class="elOrderSummaryRow elOrderSummaryRecurringRow"><div class="elOrderSummaryRowLeft">${summaryTexts?.then}</div><div class="elOrderSummaryRowRight">`; 1226 if (summary?.recurring?.discount?.amount > 0) { 1227 html += `<span class="elOrderSummaryRecurringStrikethrough">${summary?.recurring?.before_formatted}</span>`;
1228 } 1229 html += `${summary?.recurring?.total?.formatted}${summary?.recurring?.interval}</div></div>`; 1230 } 1231 } 1232 html += `</div>`; 1233 } 1234 } 1235 html += `</div>`; 1236 } 1237 } 1238 this.replaceContent(html); 1239 if (initializeChildrenInstances) { 1240 const scopeToYggRender = this.element.querySelectorAll("[ygg-render]").length > 0; 1241 const options = { scopeToYggRender }; 1242 CF2Component.hydrateTree(this.element, options); 1243 } 1244 } 1245}; 1246registerComponent("CheckoutOrderSummary/V1", CheckoutOrderSummaryV1); 1247window["CheckoutOrderSummaryV1"] = CheckoutOrderSummaryV1; 1248
1249// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-product-card-v2.ts 1250init_define_process(); 1251init_radio_v1(); 1252init_checkbox_v1(); 1253init_runtime(); 1254var CheckoutProductCardV2 = class extends CF2Component { 1255 constructor(el, runtimeSel) { 1256 super(el, runtimeSel); 1257 } 1258 mount() { 1259 this.can_purchase_again = !new URLSearchParams(window.location.search).get("manage_order_id"); 1260 this.variantValues = Object.entries(this.product.property_values_variant_mapping ?? {}).reduce((acc, entries) => { 1261 const values = entries[0].split(",").map((value) => parseInt(value)); 1262 acc[entries[1]] = values; 1263 return acc; 1264 }, {}) ?? {}; 1265 this.valuesPositions = this.product.sorted_property_values?.reduce((acc, property) => { 1266 property.value_ids.forEach((value, index) => { 1267 acc[value] = index; 1268 }); 1269 return acc; 1270 }, {}) ?? {}; 1271 } 1272 remove() { 1273 this.element.innerHTML = ""; 1274 } 1275 render(initializeChildrenInstances = false) { 1276 const is_server = true; 1277 const layout = this.layout ?? null; 1278 const featured = this.featured ?? null; 1279 const highlight_text = this.highlight_text ?? null; 1280 const selectType = this.selectType ?? null; 1281 const showImage = this.showImage ?? null; 1282 const showDescription = this.showDescription ?? null; 1283 const showCompareAtPrice = this.showCompareAtPrice ?? null; 1284 const isChecked = this.isChecked ?? null; 1285 const product = this.product ?? null; 1286 const variantDisplay = this.variantDisplay ?? null; 1287 const individualVariantId = this.individualVariantId ?? null; 1288 const variant = this.variant ?? null; 1289 const selected_price = this.selected_price ?? null; 1290 const quantity = this.quantity ?? null; 1291 const otherTexts = this.otherTexts ?? null; 1292 const can_purchase_again = this.can_purchase_again ?? true; 1293 const renderType = this.renderType ?? null; 1294 const selectedOrderIndex = this.selectedOrderIndex ?? null; 1295 const selectedUpdatableCartItemIndex = this.selectedUpdatableCartItemIndex ?? null; 1296 const updatableOrders = this.updatableOrders ?? null; 1297 const individualDirection = this.individualDirection ?? null; 1298 let html = ""; 1299 { 1300 const is_not_server = false; 1301 let priceDisplayType = "multiple"; 1302 let newOrder = selectedOrderIndex == -1; 1303 let showProductVariantSelection = true; 1304 let currentRenderType = renderType; 1305 const showUpgradeDowngrade = currentRenderType == "upgradeDowngrade"; 1306 const showReactivate = currentRenderType == "reactivate"; 1307 const showManageOrders = showUpgradeDowngrade || showReactivate; 1308 if (showManageOrders) { 1309 showProductVariantSelection = false; 1310 if (showUpgradeDowngrade) { 1311 priceDisplayType = "hide"; 1312 if (newOrder && variant?.prices?.length == 1) { 1313 priceDisplayType = "single"; 1314 } 1315 } 1316 if (showReactivate && variant?.prices?.length > 1) { 1317 priceDisplayType = "single"; 1318 } 1319 } 1320 const customVariants = product?.variants.filter((value) => value["default_variant"] == false); 1321 if (layout == "modern") { 1322 html += `<div class="elProductLayoutBackground"></div>`; 1323 html += `<div class="elProductModernItem"> `; 1324 if (selectType == "quantity") { 1325 html += `<div class="elProductInputWrapper elProductCardQuantityContainer"><div class="elProductInputControls"><button class="elProductCardInput">-</button><input class="elProductCardInput elProductCardShortInput" name="product" value="${quantity ?? 0}" min="0" type="number"/><button class="elProductCardInput">+</button></div></div>`; 1326 } else if (selectType == "quantity-forced") { 1327 html += `<div class="elProductInputWrapper elSelectWrapper elForcedQuantityWrapper"><select name="product" class="elProductCardInput elProductInputControls">`; 1328 const step = product?.step ?? 2; 1329 const min = product?.min ?? 0; 1330 const max = product?.max ?? 5; 1331 const item_count_step_1 = max - min; 1332 const item_count_step_2 = item_count_step_1 / step; 1333 const item_count_step_3 = item_count_step_2 | 0; 1334 const range = Array.apply(0, Array(item_count_step_3)).map((element, index) => index + 0); 1335 ; 1336 const c0 = range; 1337 const fl1 = new CF2ForloopDrop(c0.length); 1338 for (const i of c0) { 1339 const forloop = fl1; 1340 const value = i * step + min; 1341 html += `<option value="${value}">${value}</option>`; 1342 forloop.next(); 1343 } 1344 html += `</select><div class="elSelectArrow elForcedQuantitySelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1345 } 1346 const isClassic = layout == "classic"; 1347 const isQuantityType = selectType == "quantity"; 1348 html += `<div class="elProductCardSelectInput`; 1349 if (isClassic == false || isQuantityType == true) { 1350 html += ` hide`; 1351 } 1352 html += `">`; 1353 if (selectType == "single") { 1354 if (isChecked) { 1355 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="true" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="product" checked class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 1356 } else { 1357 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="product" class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 1358 } 1359 } else if (selectType == "multiple" || selectType == "quantity") { 1360 if (isChecked) { 1361 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked="true"><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}
1361" name="product" checked data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 1362 } else { 1363 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked=""><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 1364 } 1365 } 1366 html += `</div>`; 1367 if (showImage) { 1368 const imageUrl = variant?.image ?? product.image; 1369 if (imageUrl && imageUrl != "") { 1370 html += `<div class="elProductCardImage"><div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 1371 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 1372 html += ` forceHide`; 1373 } 1374 html += `" data-liquid-replace="item">`; 1375 if (imageUrl || !CF2Blank(null)) { 1376 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 1377 } else if (false) { 1378 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 1379 } 1380 html += `</div></div>`; 1381 } 1382 } 1383 html += `<div class="elProductCardNameContainer">`; 1384 if (featured && highlight_text) { 1385 html += `<div class="elProductCardHighlight">${highlight_text}</div>`; 1386 } 1387 if (variantDisplay == "individual") { 1388 html += `<span class="elProductCardInfoName">${variant?.name}</span>`; 1389 } else if (customVariants?.length > 1) { 1390 html += `<span class="elProductCardInfoName">${product?.default_variant?.name}</span>`; 1391 } else { 1392 html += `<span class="elProductCardInfoName">${variant?.name}</span>`; 1393 } 1394 if (showDescription) { 1395 html += `<span class="elProductCardInfoDescription">${(product?.description_override ?? variant.description ?? product.default_variant.description ?? "").replaceAll(` 1396`, "<br>")}</span>`; 1397 } 1398 html += `</div><div class="elProductCardPriceContainer">`; 1399 if (priceDisplayType == "multiple") { 1400 if (variant?.prices?.length == 1) { 1401 html += `<div class="elProductCardInfoPrice">`; 1402 if (showCompareAtPrice) { 1403 const compare_at_amount = selected_price?.compare_at_amount; 1404 if (compare_at_amount) { 1405 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`; 1406 } 1407 } 1408 html += `<span class="elProductCardFinalPrice">
1408${selected_price?.name}</span></div>`; 1409 } else { 1410 html += `<div class="elSelectWrapper"><select name="variant_price">`; 1411 const c2 = variant.prices; 1412 const fl3 = new CF2ForloopDrop(c2.length); 1413 for (const price of c2) { 1414 const forloop = fl3; 1415 html += `<option `; 1416 if (selected_price?.id == price?.id) { 1417 html += `selected`; 1418 } 1419 html += ` value="${price?.id}">${price?.name}</option>`; 1420 forloop.next(); 1421 } 1422 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1423 } 1424 } else if (priceDisplayType == "single") { 1425 html += `<div class="elProductCardInfoPrice">`; 1426 if (showCompareAtPrice) { 1427 const compare_at_amount = selected_price?.compare_at_amount; 1428 if (compare_at_amount) { 1429 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`; 1430 } 1431 } 1432 html += `<span class="elProductCardFinalPrice">
1432${selected_price?.name}</span></div>`; 1433 } 1434 html += `</div>`; 1435 if (showProductVariantSelection && variantDisplay != "individual") { 1436 if (customVariants?.length > 1) { 1437 html += `<div class="elProductSelectSelectorsWrapper">`; 1438 const c4 = product.sorted_property_values; 1439 const fl5 = new CF2ForloopDrop(c4.length); 1440 for (const property_values of c4) { 1441 const forloop = fl5; 1442 const property_id = property_values?.property_id; 1443 const select_index = forloop?.index0; 1444 html += ` `; 1445 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 1446 const c6 = property_values.value_ids; 1447 const fl7 = new CF2ForloopDrop(c6.length); 1448 for (const value_id of c6) { 1449 const forloop2 = fl7; 1450 html += `<option `; 1451 if (variant?.property_value_ids?.[select_index] == value_id) { 1452 html += `selected`; 1453 } 1454 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 1455 forloop2.next(); 1456 } 1457 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1458 forloop.next(); 1459 } 1460 html += `</div>`; 1461 } 1462 } 1463 if (showManageOrders) { 1464 const amount_of_orders = updatableOrders?.length; 1465 if (amount_of_orders && amount_of_orders > 0) { 1466 if (variantDisplay == "individual") { 1467 const isCurrentPlan = individualDirection == "current"; 1468 if (isCurrentPlan) { 1469 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i><span>Current plan</span>`; 1470 if (can_purchase_again) { 1471 html += `<span class="elProductCardCurrentPlanSeparator">-</span>`; 1472 html += `<div class="elProductCardNewOrder elProductCardPurchaseAgainInline"><span>Purchase Again</span></div>`; 1473 } 1474 html += `</div>`; 1475 } else { 1476 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i><span>${individualDirection}</span></div>`; 1477 html += `<div class="elProductCardManageOrders`; 1478 if (CF2Blank(isChecked)) { 1479 html += ` elHide`; 1480 } 1481 html += `"><div class="elProductCardOrdersWrapper"><div class="elProductCardTitle"><span>${individualDirection} </span><div></div></div><div class="elProductCardOrders">`; 1482 const c8 = updatableOrders; 1483 const fl9 = new CF2ForloopDrop(c8.length); 1484 for (const order of c8) { 1485 const forloop = fl9; 1486 const orderIndex = forloop?.index0; 1487 html += `<div class="elProductCardOrder`; 1488 if (selectedOrderIndex == orderIndex) { 1489 html += ` elProductCardOrderSelected`; 1490 } 1491 html += `" data-order-index="${orderIndex}"><div class="elProductCardOrderDetails"><div class="elProductCardOrderDetailsNumber"><i class="fas fa-receipt"></i><span>${otherTexts?.upgradesDowngradesReactivations?.order} ${order?.number}</span></div><span class="elProductCardOrderDetailsManage">${individualDirection}</span></div>`; 1492 if (selectedOrderIndex == orderIndex) { 1493 html += `<div class="elProductCardOrderActions"><a data-page-element="LinkNode" class="elTypographyLink elProductCardShowOrderDetailsLink id-LinkNode" href="#show-selected-order-details" target="_self" data-show-button-ids="" data-hide-button-ids="" data-selected="${false}" data-liquid-replace="item"><span>${otherTexts?.upgradesDowngradesReactivations?.viewOrderDetails}</span></a><span class="elProductCardDirectionBadge">${individualDirection} ${variant?.name}
1493 - ${selected_price?.name}</span></div>`; 1494 } 1495 html += `</div>`; 1496 forloop.next(); 1497 } 1498 html += `</div></div>`; 1499 if (can_purchase_again) { 1500 html += `<div class="elProductCardNewOrderWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.purchaseAgain}</span><div></div></div><div class="elProductCardNewOrder`; 1501 if (newOrder == true) { 1502 html += ` elProductCardOrderSelected`; 1503 } 1504 html += `"><div class="elProductCardNewOrderTitle"><i class="fas fa-plus-circle"></i><span>${otherTexts?.upgradesDowngradesReactivations?.newOrder}</span></div>`; 1505 if (newOrder == true) { 1506 html += `<div class="elProductCardOrderActions">`; 1507 if (variantDisplay != "individual") { 1508 if (customVariants?.length > 1) { 1509 html += `<div class="elProductSelectSelectorsWrapper">`; 1510 const c10 = product.sorted_property_values; 1511 const fl11 = new CF2ForloopDrop(c10.length); 1512 for (const property_values of c10) { 1513 const forloop = fl11; 1514 const property_id = property_values?.property_id; 1515 const select_index = forloop?.index0; 1516 html += ` `; 1517 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 1518 const c12 = property_values.value_ids; 1519 const fl13 = new CF2ForloopDrop(c12.length); 1520 for (const value_id of c12) { 1521 const forloop2 = fl13; 1522 html += `<option `; 1523 if (variant?.property_value_ids?.[select_index] == value_id) { 1524 html += `selected`; 1525 } 1526 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 1527 forloop2.next(); 1528 } 1529 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1530 forloop.next(); 1531 } 1532 html += `</div>`; 1533 } 1534 } 1535 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 1536 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 1537 const c14 = variant.prices; 1538 const fl15 = new CF2ForloopDrop(c14.length); 1539 for (const price of c14) { 1540 const forloop = fl15; 1541 html += `<option `; 1542 if (selected_price?.id == price?.id) { 1543 html += `selected`; 1544 } 1545 html += ` value="${price?.id}">${price?.name}</option>`; 1546 forloop.next(); 1547 } 1548 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 1549 } 1550 html += `</div>`; 1551 } 1552 html += `</div></div>`; 1553 } 1554 html += `</div>`; 1555 } 1556 } else { 1557 let active_order = false; 1558 let canceled_order = false; 1559 const amount_of_orders2 = updatableOrders?.length; 1560 const c16 = updatableOrders; 1561 const fl17 = new CF2ForloopDrop(c16.length); 1562 for (const order of c16) { 1563 const forloop = fl17; 1564 if (order?.type == "reactivate") { 1565 canceled_order = true; 1566 } else { 1567 active_order = true; 1568 } 1569 forloop.next(); 1570 } 1571 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i>`; 1572 if (active_order && canceled_order) { 1573 if (amount_of_orders2 > 1) { 1574 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.multipleExistingSubscriptions}</span>`;
1575 } else { 1576 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.singleExistingSubscription}</span>`; 1577 } 1578 } else if (canceled_order) { 1579 if (amount_of_orders2 > 1) { 1580 html += `<span>${amount_of_orders2} </span>`; 1581 } else { 1582 html += `<span>${amount_of_orders2} </span>`; 1583 } 1584 } else { 1585 if (amount_of_orders2 > 1) { 1586 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.multipleActiveSubscriptions}</span>`; 1587 } else { 1588 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.singleActiveSubscription}</span>`; 1589 } 1590 } 1591 html += `</div>`; 1592 html += `<div class="elProductCardManageOrders`; 1593 if (CF2Blank(isChecked)) { 1594 html += ` elHide`; 1595 } 1596 html += `"><div class="elProductCardOrdersWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.manageSubscriptions}</span><div></div></div><div class="elProductCardOrders">`; 1597 const c18 = updatableOrders; 1598 const fl19 = new CF2ForloopDrop(c18.length); 1599 for (const order of c18) { 1600 const forloop = fl19; 1601 const orderIndex = forloop?.index0; 1602 html += `<div class="elProductCardOrder`; 1603 if (selectedOrderIndex == orderIndex) { 1604 html += ` elProductCardOrderSelected`; 1605 } 1606 html += `" data-order-index="${orderIndex}"><div class="elProductCardOrderDetails"><div class="elProductCardOrderDetailsNumber"><i class="fas fa-receipt"></i><span>${otherTexts?.upgradesDowngradesReactivations?.order} ${order?.number}</span></div>`; 1607 if (order?.type == "reactivate") { 1608 html += `<span class="elProductCardOrderDetailsReactivate"></span>`; 1609 } else { 1610 html += `<span class="elProductCardOrderDetailsManage">${otherTexts?.upgradesDowngradesReactivations?.manage}</span>`; 1611 } 1612 html += `</div>`; 1613 if (selectedOrderIndex == orderIndex) { 1614 html += `<div class="elProductCardOrderActions"><a data-page-element="LinkNode" class="elTypographyLink elProductCardShowOrderDetailsLink id-LinkNode" href="#show-selected-order-details" target="_self" data-show-button-ids="" data-hide-button-ids="" data-selected="${false}" data-liquid-replace="item"><span>${otherTexts?.upgradesDowngradesReactivations?.viewOrderDetails}</span></a>`; 1615 if (order?.type == "upgradeDowngrade") { 1616 const updatableItem = order?.updatableItems?.[selectedUpdatableCartItemIndex]; 1617 html += `<div class="elCustomSelect"><div class="elCustomSelectPreview"><span class="elCustomSelectPreviewText"><span class="elCustomSelectPreviewDirection" data-direction="${updatableItem?.direction}">${updatableItem?.direction} </span><span class="elCustomSelectPreviewInfo">${updatableItem?.variantName} - ${updatableItem?.priceName}</span></span><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div><select name="upgradeDowngrade">`; 1618 const c20 = order.updatableItems; 1619 const fl21 = new CF2ForloopDrop(c20.length); 1620 for (const updatableItem2 of c20) { 1621 const forloop2 = fl21; 1622 const index = forloop2?.index0; 1623 html += `<option `; 1624 if (index == selectedUpdatableCartItemIndex) { 1625 html += `selected`; 1626 } 1627 html += ` value="${index}">${updatableItem2?.direction} ${updatableItem2?.variantName} - ${updatableItem2?.priceName}</option>`; 1628 forloop2.next(); 1629 } 1630 html += `</select></div>`; 1631 } else { 1632 if (customVariants?.length > 1) { 1633 html += `<div class="elCustomSelect"><div class="elCustomSelectPreview"><span class="elCustomSelectPreviewText"><span class="elCustomSelectPreviewDirection" data-direction="Reactivate"></span><span class="elCustomSelectPreviewInfo">${variant?.name}</span></span><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div><select class="elVariantSelector">`; 1634 const c22 = product.variants; 1635 const fl23 = new CF2ForloopDrop(c22.length); 1636 for (const product_variant of c22) { 1637 const forloop2 = fl23; 1638 let combined_variant_name = ""; 1639 const c24 = product.sorted_property_values; 1640 const fl25 = new CF2ForloopDrop(c24.length); 1641 for (const property_values of c24) { 1642 const forloop3 = fl25; 1643 const index0 = forloop3?.index0; 1644 const property_id = property_values?.property_id; 1645 const property_value_id = product_variant?.property_value_ids?.[index0]; 1646 if (combined_variant_name != "") { 1647 combined_variant_name = combined_variant_name.toString().concat(", "); 1648 } 1649 combined_variant_name = combined_variant_name.toString().concat(product.all_properties[property_id]); 1650 combined_variant_name = combined_variant_name.toString().concat(": "); 1651 combined_variant_name = combined_variant_name.toString().concat(product.all_properties_values[property_value_id]); 1652 forloop3.next(); 1653 } 1654 html += `<option value="${product_variant?.property_value_ids}" `; 1655 if (product_variant?.id == variant?.id) { 1656 html += `selected`; 1657 } 1658 html += `>${combined_variant_name}</option>`; 1659 forloop2.next(); 1660 } 1661 html += `</select></div>`; 1662 } 1663 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 1664 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 1665 const c26 = variant.prices; 1666 const fl27 = new CF2ForloopDrop(c26.length); 1667 for (const price of c26) { 1668 const forloop2 = fl27; 1669 html += `<option `; 1670 if (selected_price?.id == price?.id) { 1671 html += `selected`; 1672 } 1673 html += ` value="${price?.id}">${price?.name}</option>`; 1674 forloop2.next(); 1675 } 1676 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 1677 } 1678 } 1679 html += `</div>`; 1680 } 1681 html += `</div>`; 1682 forloop.next(); 1683 } 1684 html += `</div></div>`; 1685 if (can_purchase_again) { 1686 html += `<div class="elProductCardNewOrderWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.purchaseAgain}</span><div></div></div><div class="elProductCardNewOrder`; 1687 if (newOrder == true) { 1688 html += ` elProductCardOrderSelected`; 1689 } 1690 html += `"><div class="elProductCardNewOrderTitle"><i class="fas fa-plus-circle"></i><span>${otherTexts?.upgradesDowngradesReactivations?.newOrder}</span></div>`; 1691 if (newOrder == true) { 1692 html += `<div class="elProductCardOrderActions">`; 1693 if (variantDisplay != "individual") { 1694 if (customVariants?.length > 1) { 1695 html += `<div class="elProductSelectSelectorsWrapper">`; 1696 const c28 = product.sorted_property_values; 1697 const fl29 = new CF2ForloopDrop(c28.length); 1698 for (const property_values of c28) { 1699 const forloop = fl29; 1700 const property_id = property_values?.property_id; 1701 const select_index = forloop?.index0; 1702 html += ` `; 1703 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 1704 const c30 = property_values.value_ids; 1705 const fl31 = new CF2ForloopDrop(c30.length); 1706 for (const value_id of c30) { 1707 const forloop2 = fl31; 1708 html += `<option `; 1709 if (variant?.property_value_ids?.[select_index] == value_id) { 1710 html += `selected`; 1711 } 1712 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 1713 forloop2.next(); 1714 } 1715 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1716 forloop.next(); 1717 } 1718 html += `</div>`; 1719 } 1720 } 1721 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 1722 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 1723 const c32 = variant.prices; 1724 const fl33 = new CF2ForloopDrop(c32.length); 1725 for (const price of c32) { 1726 const forloop = fl33; 1727 html += `<option `; 1728 if (selected_price?.id == price?.id) { 1729 html += `selected`; 1730 } 1731 html += ` value="${price?.id}">${price?.name}</option>`; 1732 forloop.next(); 1733 } 1734 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 1735 } 1736 html += `</div>`; 1737 } 1738 html += `</div></div>`; 1739 } 1740 html += `</div>`; 1741 } 1742 } 1743 } 1744 html += `</div>`; 1745 } else if (layout == "grid") {
1746 html += `<div class="elProductLayoutBackground"></div>`; 1747 html += `<div class="elProductGridItem">`; 1748 if (selectType == "quantity") { 1749 html += `<div class="elProductInputWrapper elProductCardQuantityContainer"><div class="elProductInputControls"><button class="elProductCardInput">-</button><input class="elProductCardInput elProductCardShortInput" name="product" value="${quantity ?? 0}" min="0" type="number"/><button class="elProductCardInput">+</button></div></div>`; 1750 } else if (selectType == "quantity-forced") { 1751 html += `<div class="elProductInputWrapper elSelectWrapper elForcedQuantityWrapper"><select name="product" class="elProductCardInput elProductInputControls">`; 1752 const step = product?.step ?? 2; 1753 const min = product?.min ?? 0; 1754 const max = product?.max ?? 5; 1755 const item_count_step_1 = max - min; 1756 const item_count_step_2 = item_count_step_1 / step; 1757 const item_count_step_3 = item_count_step_2 | 0; 1758 const range = Array.apply(0, Array(item_count_step_3)).map((element, index) => index + 0); 1759 ; 1760 const c34 = range; 1761 const fl35 = new CF2ForloopDrop(c34.length); 1762 for (const i of c34) { 1763 const forloop = fl35; 1764 const value = i * step + min; 1765 html += `<option value="${value}">${value}</option>`; 1766 forloop.next(); 1767 } 1768 html += `</select><div class="elSelectArrow elForcedQuantitySelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1769 } 1770 const isClassic = layout == "classic"; 1771 const isQuantityType = selectType == "quantity"; 1772 html += `<div class="elProductCardSelectInput`; 1773 if (isClassic == false || isQuantityType == true) { 1774 html += ` hide`; 1775 } 1776 html += `">`; 1777 if (selectType == "single") { 1778 if (isChecked) { 1779 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="true" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="product" checked class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 1780 } else { 1781 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="product" class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 1782 } 1783 } else if (selectType == "multiple" || selectType == "quantity") { 1784 if (isChecked) { 1785 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked="true"><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" checked data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 1786 } else { 1787 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked=""><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 1788 } 1789 } 1790 html += `</div>`; 1791 if (showImage) { 1792 const imageUrl = variant?.image ?? product.image; 1793 if (imageUrl && imageUrl != "") { 1794 html += `<div class="elProductCardImage"><div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 1795 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 1796 html += ` forceHide`; 1797 } 1798 html += `" data-liquid-replace="item">`; 1799 if (imageUrl || !CF2Blank(null)) { 1800 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 1801 } else if (false) { 1802 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 1803 } 1804 html += `</div></div>`; 1805 } 1806 } 1807 html += `<div class="elProductCardNamePriceWrapper"><div class="elProductCardNameContainer">`; 1808 if (featured && highlight_text) { 1809 html += `<div class="elProductCardHighlight">${highlight_text}</div>`; 1810 } 1811 if (variantDisplay == "individual") { 1812 html += `<span class="elProductCardInfoName">${variant?.name}</span>`;
1813 } else if (customVariants?.length > 1) { 1814 html += `<span class="elProductCardInfoName">${product?.default_variant?.name}</span>`; 1815 } else { 1816 html += `<span class="elProductCardInfoName">${variant?.name}</span>`; 1817 } 1818 if (showDescription) { 1819 html += `<span class="elProductCardInfoDescription">${(product?.description_override ?? variant.description ?? product.default_variant.description ?? "").replaceAll(` 1820`, "<br>")}</span>`; 1821 } 1822 html += `</div><div class="elProductCardPriceContainer">`; 1823 if (priceDisplayType == "multiple") { 1824 if (variant?.prices?.length == 1) { 1825 html += `<div class="elProductCardInfoPrice">`; 1826 if (showCompareAtPrice) { 1827 const compare_at_amount = selected_price?.compare_at_amount; 1828 if (compare_at_amount) { 1829 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`; 1830 } 1831 } 1832 html += `<span class="elProductCardFinalPrice">
1832${selected_price?.name}</span></div>`; 1833 } else { 1834 html += `<div class="elSelectWrapper"><select name="variant_price">`; 1835 const c36 = variant.prices; 1836 const fl37 = new CF2ForloopDrop(c36.length); 1837 for (const price of c36) { 1838 const forloop = fl37; 1839 html += `<option `; 1840 if (selected_price?.id == price?.id) { 1841 html += `selected`; 1842 } 1843 html += ` value="${price?.id}">${price?.name}</option>`; 1844 forloop.next(); 1845 } 1846 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1847 } 1848 } else if (priceDisplayType == "single") { 1849 html += `<div class="elProductCardInfoPrice">`; 1850 if (showCompareAtPrice) { 1851 const compare_at_amount = selected_price?.compare_at_amount; 1852 if (compare_at_amount) { 1853 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`;
1854 } 1855 } 1856 html += `<span class="elProductCardFinalPrice">${selected_price?.name}</span></div>`; 1857 } 1858 html += `</div></div></div>`; 1859 if (showProductVariantSelection && variantDisplay != "individual") { 1860 if (customVariants?.length > 1) { 1861 html += `<div class="elProductSelectSelectorsWrapper">`; 1862 const c38 = product.sorted_property_values; 1863 const fl39 = new CF2ForloopDrop(c38.length); 1864 for (const property_values of c38) { 1865 const forloop = fl39; 1866 const property_id = property_values?.property_id; 1867 const select_index = forloop?.index0; 1868 html += ` `; 1869 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 1870 const c40 = property_values.value_ids; 1871 const fl41 = new CF2ForloopDrop(c40.length); 1872 for (const value_id of c40) { 1873 const forloop2 = fl41; 1874 html += `<option `; 1875 if (variant?.property_value_ids?.[select_index] == value_id) { 1876 html += `selected`; 1877 } 1878 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 1879 forloop2.next(); 1880 } 1881 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1882 forloop.next(); 1883 } 1884 html += `</div>`; 1885 } 1886 } 1887 if (showManageOrders) { 1888 const amount_of_orders = updatableOrders?.length; 1889 if (amount_of_orders && amount_of_orders > 0) { 1890 if (variantDisplay == "individual") { 1891 const isCurrentPlan = individualDirection == "current"; 1892 if (isCurrentPlan) { 1893 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i><span>Current plan</span>`; 1894 if (can_purchase_again) { 1895 html += `<span class="elProductCardCurrentPlanSeparator">-</span>`; 1896 html += `<div class="elProductCardNewOrder elProductCardPurchaseAgainInline"><span>Purchase Again</span></div>`; 1897 } 1898 html += `</div>`; 1899 } else { 1900 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i><span>${individualDirection}</span></div>`; 1901 html += `<div class="elProductCardManageOrders`; 1902 if (CF2Blank(isChecked)) { 1903 html += ` elHide`; 1904 } 1905 html += `"><div class="elProductCardOrdersWrapper"><div class="elProductCardTitle"><span>${individualDirection} </span><div></div></div><div class="elProductCardOrders">`; 1906 const c42 = updatableOrders; 1907 const fl43 = new CF2ForloopDrop(c42.length); 1908 for (const order of c42) { 1909 const forloop = fl43; 1910 const orderIndex = forloop?.index0; 1911 html += `<div class="elProductCardOrder`; 1912 if (selectedOrderIndex == orderIndex) { 1913 html += ` elProductCardOrderSelected`; 1914 } 1915 html += `" data-order-index="${orderIndex}"><div class="elProductCardOrderDetails"><div class="elProductCardOrderDetailsNumber"><i class="fas fa-receipt"></i><span>${otherTexts?.upgradesDowngradesReactivations?.order} ${order?.number}</span></div><span class="elProductCardOrderDetailsManage">${individualDirection}</span></div>`; 1916 if (selectedOrderIndex == orderIndex) { 1917 html += `<div class="elProductCardOrderActions"><a data-page-element="LinkNode" class="elTypographyLink elProductCardShowOrderDetailsLink id-LinkNode" href="#show-selected-order-details" target="_self" data-show-button-ids="" data-hide-button-ids="" data-selected="${false}" data-liquid-replace="item"><span>${otherTexts?.upgradesDowngradesReactivations?.viewOrderDetails}</span></a><span class="elProductCardDirectionBadge">${individualDirection} ${variant?.name}
1917 - ${selected_price?.name}</span></div>`; 1918 } 1919 html += `</div>`; 1920 forloop.next(); 1921 } 1922 html += `</div></div>`; 1923 if (can_purchase_again) { 1924 html += `<div class="elProductCardNewOrderWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.purchaseAgain}</span><div></div></div><div class="elProductCardNewOrder`; 1925 if (newOrder == true) { 1926 html += ` elProductCardOrderSelected`; 1927 } 1928 html += `"><div class="elProductCardNewOrderTitle"><i class="fas fa-plus-circle"></i><span>${otherTexts?.upgradesDowngradesReactivations?.newOrder}</span></div>`; 1929 if (newOrder == true) { 1930 html += `<div class="elProductCardOrderActions">`; 1931 if (variantDisplay != "individual") { 1932 if (customVariants?.length > 1) { 1933 html += `<div class="elProductSelectSelectorsWrapper">`; 1934 const c44 = product.sorted_property_values; 1935 const fl45 = new CF2ForloopDrop(c44.length); 1936 for (const property_values of c44) { 1937 const forloop = fl45; 1938 const property_id = property_values?.property_id; 1939 const select_index = forloop?.index0; 1940 html += ` `; 1941 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 1942 const c46 = property_values.value_ids; 1943 const fl47 = new CF2ForloopDrop(c46.length); 1944 for (const value_id of c46) { 1945 const forloop2 = fl47; 1946 html += `<option `; 1947 if (variant?.property_value_ids?.[select_index] == value_id) { 1948 html += `selected`; 1949 } 1950 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 1951 forloop2.next(); 1952 } 1953 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 1954 forloop.next(); 1955 } 1956 html += `</div>`; 1957 } 1958 } 1959 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 1960 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 1961 const c48 = variant.prices; 1962 const fl49 = new CF2ForloopDrop(c48.length); 1963 for (const price of c48) { 1964 const forloop = fl49; 1965 html += `<option `; 1966 if (selected_price?.id == price?.id) { 1967 html += `selected`; 1968 } 1969 html += ` value="${price?.id}">${price?.name}</option>`; 1970 forloop.next(); 1971 } 1972 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 1973 } 1974 html += `</div>`; 1975 } 1976 html += `</div></div>`; 1977 } 1978 html += `</div>`; 1979 } 1980 } else { 1981 let active_order = false; 1982 let canceled_order = false; 1983 const amount_of_orders2 = updatableOrders?.length; 1984 const c50 = updatableOrders; 1985 const fl51 = new CF2ForloopDrop(c50.length); 1986 for (const order of c50) { 1987 const forloop = fl51; 1988 if (order?.type == "reactivate") { 1989 canceled_order = true; 1990 } else { 1991 active_order = true; 1992 } 1993 forloop.next(); 1994 } 1995 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i>`; 1996 if (active_order && canceled_order) { 1997 if (amount_of_orders2 > 1) { 1998 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.multipleExistingSubscriptions}</span>`;
1999 } else { 2000 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.singleExistingSubscription}</span>`; 2001 } 2002 } else if (canceled_order) { 2003 if (amount_of_orders2 > 1) { 2004 html += `<span>${amount_of_orders2} </span>`; 2005 } else { 2006 html += `<span>${amount_of_orders2} </span>`; 2007 } 2008 } else { 2009 if (amount_of_orders2 > 1) { 2010 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.multipleActiveSubscriptions}</span>`; 2011 } else { 2012 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.singleActiveSubscription}</span>`; 2013 } 2014 } 2015 html += `</div>`; 2016 html += `<div class="elProductCardManageOrders`; 2017 if (CF2Blank(isChecked)) { 2018 html += ` elHide`; 2019 } 2020 html += `"><div class="elProductCardOrdersWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.manageSubscriptions}</span><div></div></div><div class="elProductCardOrders">`; 2021 const c52 = updatableOrders; 2022 const fl53 = new CF2ForloopDrop(c52.length); 2023 for (const order of c52) { 2024 const forloop = fl53; 2025 const orderIndex = forloop?.index0; 2026 html += `<div class="elProductCardOrder`; 2027 if (selectedOrderIndex == orderIndex) { 2028 html += ` elProductCardOrderSelected`; 2029 } 2030 html += `" data-order-index="${orderIndex}"><div class="elProductCardOrderDetails"><div class="elProductCardOrderDetailsNumber"><i class="fas fa-receipt"></i><span>${otherTexts?.upgradesDowngradesReactivations?.order} ${order?.number}</span></div>`; 2031 if (order?.type == "reactivate") { 2032 html += `<span class="elProductCardOrderDetailsReactivate"></span>`; 2033 } else { 2034 html += `<span class="elProductCardOrderDetailsManage">${otherTexts?.upgradesDowngradesReactivations?.manage}</span>`; 2035 } 2036 html += `</div>`; 2037 if (selectedOrderIndex == orderIndex) { 2038 html += `<div class="elProductCardOrderActions"><a data-page-element="LinkNode" class="elTypographyLink elProductCardShowOrderDetailsLink id-LinkNode" href="#show-selected-order-details" target="_self" data-show-button-ids="" data-hide-button-ids="" data-selected="${false}" data-liquid-replace="item"><span>${otherTexts?.upgradesDowngradesReactivations?.viewOrderDetails}</span></a>`; 2039 if (order?.type == "upgradeDowngrade") { 2040 const updatableItem = order?.updatableItems?.[selectedUpdatableCartItemIndex]; 2041 html += `<div class="elCustomSelect"><div class="elCustomSelectPreview"><span class="elCustomSelectPreviewText"><span class="elCustomSelectPreviewDirection" data-direction="${updatableItem?.direction}">${updatableItem?.direction} </span><span class="elCustomSelectPreviewInfo">${updatableItem?.variantName} - ${updatableItem?.priceName}</span></span><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div><select name="upgradeDowngrade">`; 2042 const c54 = order.updatableItems; 2043 const fl55 = new CF2ForloopDrop(c54.length); 2044 for (const updatableItem2 of c54) { 2045 const forloop2 = fl55; 2046 const index = forloop2?.index0; 2047 html += `<option `; 2048 if (index == selectedUpdatableCartItemIndex) { 2049 html += `selected`; 2050 } 2051 html += ` value="${index}">${updatableItem2?.direction} ${updatableItem2?.variantName} - ${updatableItem2?.priceName}</option>`; 2052 forloop2.next(); 2053 } 2054 html += `</select></div>`; 2055 } else { 2056 if (customVariants?.length > 1) { 2057 html += `<div class="elCustomSelect"><div class="elCustomSelectPreview"><span class="elCustomSelectPreviewText"><span class="elCustomSelectPreviewDirection" data-direction="Reactivate"></span><span class="elCustomSelectPreviewInfo">${variant?.name}</span></span><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div><select class="elVariantSelector">`; 2058 const c56 = product.variants; 2059 const fl57 = new CF2ForloopDrop(c56.length); 2060 for (const product_variant of c56) { 2061 const forloop2 = fl57; 2062 let combined_variant_name = ""; 2063 const c58 = product.sorted_property_values; 2064 const fl59 = new CF2ForloopDrop(c58.length); 2065 for (const property_values of c58) { 2066 const forloop3 = fl59; 2067 const index0 = forloop3?.index0; 2068 const property_id = property_values?.property_id; 2069 const property_value_id = product_variant?.property_value_ids?.[index0]; 2070 if (combined_variant_name != "") { 2071 combined_variant_name = combined_variant_name.toString().concat(", "); 2072 } 2073 combined_variant_name = combined_variant_name.toString().concat(product.all_properties[property_id]); 2074 combined_variant_name = combined_variant_name.toString().concat(": "); 2075 combined_variant_name = combined_variant_name.toString().concat(product.all_properties_values[property_value_id]); 2076 forloop3.next(); 2077 } 2078 html += `<option value="${product_variant?.property_value_ids}" `; 2079 if (product_variant?.id == variant?.id) { 2080 html += `selected`; 2081 } 2082 html += `>${combined_variant_name}</option>`; 2083 forloop2.next(); 2084 } 2085 html += `</select></div>`; 2086 } 2087 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 2088 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 2089 const c60 = variant.prices; 2090 const fl61 = new CF2ForloopDrop(c60.length); 2091 for (const price of c60) {
2092 const forloop2 = fl61; 2093 html += `<option `; 2094 if (selected_price?.id == price?.id) { 2095 html += `selected`; 2096 } 2097 html += ` value="${price?.id}">${price?.name}</option>`; 2098 forloop2.next(); 2099 } 2100 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 2101 } 2102 } 2103 html += `</div>`; 2104 } 2105 html += `</div>`; 2106 forloop.next(); 2107 } 2108 html += `</div></div>`; 2109 if (can_purchase_again) { 2110 html += `<div class="elProductCardNewOrderWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.purchaseAgain}</span><div></div></div><div class="elProductCardNewOrder`; 2111 if (newOrder == true) { 2112 html += ` elProductCardOrderSelected`; 2113 } 2114 html += `"><div class="elProductCardNewOrderTitle"><i class="fas fa-plus-circle"></i><span>${otherTexts?.upgradesDowngradesReactivations?.newOrder}</span></div>`; 2115 if (newOrder == true) { 2116 html += `<div class="elProductCardOrderActions">`; 2117 if (variantDisplay != "individual") { 2118 if (customVariants?.length > 1) { 2119 html += `<div class="elProductSelectSelectorsWrapper">`; 2120 const c62 = product.sorted_property_values; 2121 const fl63 = new CF2ForloopDrop(c62.length); 2122 for (const property_values of c62) { 2123 const forloop = fl63; 2124 const property_id = property_values?.property_id; 2125 const select_index = forloop?.index0; 2126 html += ` `; 2127 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 2128 const c64 = property_values.value_ids; 2129 const fl65 = new CF2ForloopDrop(c64.length); 2130 for (const value_id of c64) { 2131 const forloop2 = fl65; 2132 html += `<option `; 2133 if (variant?.property_value_ids?.[select_index] == value_id) { 2134 html += `selected`; 2135 } 2136 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 2137 forloop2.next(); 2138 } 2139 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 2140 forloop.next(); 2141 } 2142 html += `</div>`; 2143 } 2144 } 2145 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 2146 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 2147 const c66 = variant.prices; 2148 const fl67 = new CF2ForloopDrop(c66.length); 2149 for (const price of c66) { 2150 const forloop = fl67; 2151 html += `<option `; 2152 if (selected_price?.id == price?.id) { 2153 html += `selected`; 2154 } 2155 html += ` value="${price?.id}">${price?.name}</option>`; 2156 forloop.next(); 2157 } 2158 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 2159 } 2160 html += `</div>`; 2161 } 2162 html += `</div></div>`; 2163 } 2164 html += `</div>`; 2165 } 2166 } 2167 } 2168 } else {
2169 html += `<div class="elProductLayoutBackground"></div>`; 2170 if (selectType == "quantity") { 2171 html += `<div class="elProductInputWrapper elProductCardQuantityContainer"><div class="elProductInputControls"><button class="elProductCardInput">-</button><input class="elProductCardInput elProductCardShortInput" name="product" value="${quantity ?? 0}" min="0" type="number"/><button class="elProductCardInput">+</button></div></div>`; 2172 } else if (selectType == "quantity-forced") { 2173 html += `<div class="elProductInputWrapper elSelectWrapper elForcedQuantityWrapper"><select name="product" class="elProductCardInput elProductInputControls">`; 2174 const step = product?.step ?? 2; 2175 const min = product?.min ?? 0; 2176 const max = product?.max ?? 5; 2177 const item_count_step_1 = max - min; 2178 const item_count_step_2 = item_count_step_1 / step; 2179 const item_count_step_3 = item_count_step_2 | 0; 2180 const range = Array.apply(0, Array(item_count_step_3)).map((element, index) => index + 0); 2181 ; 2182 const c68 = range; 2183 const fl69 = new CF2ForloopDrop(c68.length); 2184 for (const i of c68) { 2185 const forloop = fl69; 2186 const value = i * step + min; 2187 html += `<option value="${value}">${value}</option>`; 2188 forloop.next(); 2189 } 2190 html += `</select><div class="elSelectArrow elForcedQuantitySelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 2191 } 2192 const isClassic = layout == "classic"; 2193 const isQuantityType = selectType == "quantity"; 2194 html += `<div class="elProductCardSelectInput`; 2195 if (isClassic == false || isQuantityType == true) { 2196 html += ` hide`; 2197 } 2198 html += `">`; 2199 if (selectType == "single") { 2200 if (isChecked) { 2201 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="true" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="product" checked class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 2202 } else { 2203 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="product" class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 2204 } 2205 } else if (selectType == "multiple" || selectType == "quantity") { 2206 if (isChecked) { 2207 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked="true"><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" checked data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 2208 } else { 2209 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked=""><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 2210 } 2211 } 2212 html += `</div>`; 2213 if (showImage) { 2214 const imageUrl = variant?.image ?? product.image; 2215 if (imageUrl && imageUrl != "") { 2216 html += `<div class="elProductCardImage"><div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 2217 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 2218 html += ` forceHide`; 2219 } 2220 html += `" data-liquid-replace="item">`; 2221 if (imageUrl || !CF2Blank(null)) { 2222 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 2223 } else if (false) { 2224 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 2225 } 2226 html += `</div></div>`; 2227 } 2228 } 2229 html += `<div class="elProductCardNameContainer">`; 2230 if (featured && highlight_text) { 2231 html += `<div class="elProductCardHighlight">${highlight_text}</div>`; 2232 } 2233 if (variantDisplay == "individual") { 2234 html += `<span class="elProductCardInfoName">${variant?.name}</span>`;
2235 } else if (customVariants?.length > 1) { 2236 html += `<span class="elProductCardInfoName">${product?.default_variant?.name}</span>`; 2237 } else { 2238 html += `<span class="elProductCardInfoName">${variant?.name}</span>`; 2239 } 2240 if (showDescription) { 2241 html += `<span class="elProductCardInfoDescription">${(product?.description_override ?? variant.description ?? product.default_variant.description ?? "").replaceAll(` 2242`, "<br>")}</span>`; 2243 } 2244 html += `</div>`; 2245 html += `<div class="elProductCardPriceContainer">`; 2246 if (priceDisplayType == "multiple") { 2247 if (variant?.prices?.length == 1) { 2248 html += `<div class="elProductCardInfoPrice">`; 2249 if (showCompareAtPrice) { 2250 const compare_at_amount = selected_price?.compare_at_amount; 2251 if (compare_at_amount) { 2252 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`; 2253 } 2254 } 2255 html += `<span class="elProductCardFinalPrice">
2255${selected_price?.name}</span></div>`; 2256 } else { 2257 html += `<div class="elSelectWrapper"><select name="variant_price">`; 2258 const c70 = variant.prices; 2259 const fl71 = new CF2ForloopDrop(c70.length); 2260 for (const price of c70) { 2261 const forloop = fl71; 2262 html += `<option `; 2263 if (selected_price?.id == price?.id) { 2264 html += `selected`; 2265 } 2266 html += ` value="${price?.id}">${price?.name}</option>`; 2267 forloop.next(); 2268 } 2269 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 2270 } 2271 } else if (priceDisplayType == "single") { 2272 html += `<div class="elProductCardInfoPrice">`; 2273 if (showCompareAtPrice) { 2274 const compare_at_amount = selected_price?.compare_at_amount; 2275 if (compare_at_amount) { 2276 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`;
2277 } 2278 } 2279 html += `<span class="elProductCardFinalPrice">${selected_price?.name}</span></div>`; 2280 } 2281 html += `</div>`; 2282 if (showProductVariantSelection && variantDisplay != "individual") { 2283 if (customVariants?.length > 1) { 2284 html += `<div class="elProductSelectSelectorsWrapper">`; 2285 const c72 = product.sorted_property_values; 2286 const fl73 = new CF2ForloopDrop(c72.length); 2287 for (const property_values of c72) { 2288 const forloop = fl73; 2289 const property_id = property_values?.property_id; 2290 const select_index = forloop?.index0; 2291 html += ` `; 2292 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 2293 const c74 = property_values.value_ids; 2294 const fl75 = new CF2ForloopDrop(c74.length); 2295 for (const value_id of c74) { 2296 const forloop2 = fl75; 2297 html += `<option `; 2298 if (variant?.property_value_ids?.[select_index] == value_id) { 2299 html += `selected`; 2300 } 2301 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 2302 forloop2.next(); 2303 } 2304 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 2305 forloop.next(); 2306 } 2307 html += `</div>`; 2308 } 2309 } 2310 if (showManageOrders) { 2311 const amount_of_orders = updatableOrders?.length; 2312 if (amount_of_orders && amount_of_orders > 0) { 2313 if (variantDisplay == "individual") { 2314 const isCurrentPlan = individualDirection == "current"; 2315 if (isCurrentPlan) { 2316 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i><span>Current plan</span>`; 2317 if (can_purchase_again) { 2318 html += `<span class="elProductCardCurrentPlanSeparator">-</span>`; 2319 html += `<div class="elProductCardNewOrder elProductCardPurchaseAgainInline"><span>Purchase Again</span></div>`; 2320 } 2321 html += `</div>`; 2322 } else { 2323 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i><span>${individualDirection}</span></div>`; 2324 html += `<div class="elProductCardManageOrders`; 2325 if (CF2Blank(isChecked)) { 2326 html += ` elHide`; 2327 } 2328 html += `"><div class="elProductCardOrdersWrapper"><div class="elProductCardTitle"><span>${individualDirection} </span><div></div></div><div class="elProductCardOrders">`; 2329 const c76 = updatableOrders; 2330 const fl77 = new CF2ForloopDrop(c76.length); 2331 for (const order of c76) { 2332 const forloop = fl77; 2333 const orderIndex = forloop?.index0; 2334 html += `<div class="elProductCardOrder`; 2335 if (selectedOrderIndex == orderIndex) { 2336 html += ` elProductCardOrderSelected`; 2337 } 2338 html += `" data-order-index="${orderIndex}"><div class="elProductCardOrderDetails"><div class="elProductCardOrderDetailsNumber"><i class="fas fa-receipt"></i><span>${otherTexts?.upgradesDowngradesReactivations?.order} ${order?.number}</span></div><span class="elProductCardOrderDetailsManage">${individualDirection}</span></div>`; 2339 if (selectedOrderIndex == orderIndex) { 2340 html += `<div class="elProductCardOrderActions"><a data-page-element="LinkNode" class="elTypographyLink elProductCardShowOrderDetailsLink id-LinkNode" href="#show-selected-order-details" target="_self" data-show-button-ids="" data-hide-button-ids="" data-selected="${false}" data-liquid-replace="item"><span>${otherTexts?.upgradesDowngradesReactivations?.viewOrderDetails}</span></a><span class="elProductCardDirectionBadge">${individualDirection} ${variant?.name}
2340 - ${selected_price?.name}</span></div>`; 2341 } 2342 html += `</div>`; 2343 forloop.next(); 2344 } 2345 html += `</div></div>`; 2346 if (can_purchase_again) { 2347 html += `<div class="elProductCardNewOrderWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.purchaseAgain}</span><div></div></div><div class="elProductCardNewOrder`; 2348 if (newOrder == true) { 2349 html += ` elProductCardOrderSelected`; 2350 } 2351 html += `"><div class="elProductCardNewOrderTitle"><i class="fas fa-plus-circle"></i><span>${otherTexts?.upgradesDowngradesReactivations?.newOrder}</span></div>`; 2352 if (newOrder == true) { 2353 html += `<div class="elProductCardOrderActions">`; 2354 if (variantDisplay != "individual") { 2355 if (customVariants?.length > 1) { 2356 html += `<div class="elProductSelectSelectorsWrapper">`; 2357 const c78 = product.sorted_property_values; 2358 const fl79 = new CF2ForloopDrop(c78.length); 2359 for (const property_values of c78) { 2360 const forloop = fl79; 2361 const property_id = property_values?.property_id; 2362 const select_index = forloop?.index0; 2363 html += ` `; 2364 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 2365 const c80 = property_values.value_ids; 2366 const fl81 = new CF2ForloopDrop(c80.length); 2367 for (const value_id of c80) { 2368 const forloop2 = fl81; 2369 html += `<option `; 2370 if (variant?.property_value_ids?.[select_index] == value_id) { 2371 html += `selected`; 2372 } 2373 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 2374 forloop2.next(); 2375 } 2376 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 2377 forloop.next(); 2378 } 2379 html += `</div>`; 2380 } 2381 } 2382 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 2383 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 2384 const c82 = variant.prices; 2385 const fl83 = new CF2ForloopDrop(c82.length); 2386 for (const price of c82) { 2387 const forloop = fl83; 2388 html += `<option `; 2389 if (selected_price?.id == price?.id) { 2390 html += `selected`; 2391 } 2392 html += ` value="${price?.id}">${price?.name}</option>`; 2393 forloop.next(); 2394 } 2395 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 2396 } 2397 html += `</div>`; 2398 } 2399 html += `</div></div>`; 2400 } 2401 html += `</div>`; 2402 } 2403 } else { 2404 let active_order = false; 2405 let canceled_order = false; 2406 const amount_of_orders2 = updatableOrders?.length; 2407 const c84 = updatableOrders; 2408 const fl85 = new CF2ForloopDrop(c84.length); 2409 for (const order of c84) { 2410 const forloop = fl85; 2411 if (order?.type == "reactivate") { 2412 canceled_order = true; 2413 } else { 2414 active_order = true; 2415 } 2416 forloop.next(); 2417 } 2418 html += `<div class="elProductCardSubscriptionsBanner"><i class="fas fa-sync-alt"></i>`; 2419 if (active_order && canceled_order) { 2420 if (amount_of_orders2 > 1) { 2421 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.multipleExistingSubscriptions}</span>`;
2422 } else { 2423 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.singleExistingSubscription}</span>`; 2424 } 2425 } else if (canceled_order) { 2426 if (amount_of_orders2 > 1) { 2427 html += `<span>${amount_of_orders2} </span>`; 2428 } else { 2429 html += `<span>${amount_of_orders2} </span>`; 2430 } 2431 } else { 2432 if (amount_of_orders2 > 1) { 2433 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.multipleActiveSubscriptions}</span>`; 2434 } else { 2435 html += `<span>${amount_of_orders2} ${otherTexts?.upgradesDowngradesReactivations?.singleActiveSubscription}</span>`; 2436 } 2437 } 2438 html += `</div>`; 2439 html += `<div class="elProductCardManageOrders`; 2440 if (CF2Blank(isChecked)) { 2441 html += ` elHide`; 2442 } 2443 html += `"><div class="elProductCardOrdersWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.manageSubscriptions}</span><div></div></div><div class="elProductCardOrders">`; 2444 const c86 = updatableOrders; 2445 const fl87 = new CF2ForloopDrop(c86.length); 2446 for (const order of c86) { 2447 const forloop = fl87; 2448 const orderIndex = forloop?.index0; 2449 html += `<div class="elProductCardOrder`; 2450 if (selectedOrderIndex == orderIndex) { 2451 html += ` elProductCardOrderSelected`; 2452 } 2453 html += `" data-order-index="${orderIndex}"><div class="elProductCardOrderDetails"><div class="elProductCardOrderDetailsNumber"><i class="fas fa-receipt"></i><span>${otherTexts?.upgradesDowngradesReactivations?.order} ${order?.number}</span></div>`; 2454 if (order?.type == "reactivate") { 2455 html += `<span class="elProductCardOrderDetailsReactivate"></span>`; 2456 } else { 2457 html += `<span class="elProductCardOrderDetailsManage">${otherTexts?.upgradesDowngradesReactivations?.manage}</span>`; 2458 } 2459 html += `</div>`; 2460 if (selectedOrderIndex == orderIndex) { 2461 html += `<div class="elProductCardOrderActions"><a data-page-element="LinkNode" class="elTypographyLink elProductCardShowOrderDetailsLink id-LinkNode" href="#show-selected-order-details" target="_self" data-show-button-ids="" data-hide-button-ids="" data-selected="${false}" data-liquid-replace="item"><span>${otherTexts?.upgradesDowngradesReactivations?.viewOrderDetails}</span></a>`; 2462 if (order?.type == "upgradeDowngrade") { 2463 const updatableItem = order?.updatableItems?.[selectedUpdatableCartItemIndex]; 2464 html += `<div class="elCustomSelect"><div class="elCustomSelectPreview"><span class="elCustomSelectPreviewText"><span class="elCustomSelectPreviewDirection" data-direction="${updatableItem?.direction}">${updatableItem?.direction} </span><span class="elCustomSelectPreviewInfo">${updatableItem?.variantName} - ${updatableItem?.priceName}</span></span><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div><select name="upgradeDowngrade">`; 2465 const c88 = order.updatableItems; 2466 const fl89 = new CF2ForloopDrop(c88.length); 2467 for (const updatableItem2 of c88) { 2468 const forloop2 = fl89; 2469 const index = forloop2?.index0; 2470 html += `<option `; 2471 if (index == selectedUpdatableCartItemIndex) { 2472 html += `selected`; 2473 } 2474 html += ` value="${index}">${updatableItem2?.direction} ${updatableItem2?.variantName} - ${updatableItem2?.priceName}</option>`; 2475 forloop2.next(); 2476 } 2477 html += `</select></div>`; 2478 } else { 2479 if (customVariants?.length > 1) { 2480 html += `<div class="elCustomSelect"><div class="elCustomSelectPreview"><span class="elCustomSelectPreviewText"><span class="elCustomSelectPreviewDirection" data-direction="Reactivate"></span><span class="elCustomSelectPreviewInfo">${variant?.name}</span></span><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div><select class="elVariantSelector">`; 2481 const c90 = product.variants; 2482 const fl91 = new CF2ForloopDrop(c90.length); 2483 for (const product_variant of c90) { 2484 const forloop2 = fl91; 2485 let combined_variant_name = ""; 2486 const c92 = product.sorted_property_values; 2487 const fl93 = new CF2ForloopDrop(c92.length); 2488 for (const property_values of c92) { 2489 const forloop3 = fl93; 2490 const index0 = forloop3?.index0; 2491 const property_id = property_values?.property_id; 2492 const property_value_id = product_variant?.property_value_ids?.[index0]; 2493 if (combined_variant_name != "") { 2494 combined_variant_name = combined_variant_name.toString().concat(", "); 2495 } 2496 combined_variant_name = combined_variant_name.toString().concat(product.all_properties[property_id]); 2497 combined_variant_name = combined_variant_name.toString().concat(": "); 2498 combined_variant_name = combined_variant_name.toString().concat(product.all_properties_values[property_value_id]); 2499 forloop3.next(); 2500 } 2501 html += `<option value="${product_variant?.property_value_ids}" `; 2502 if (product_variant?.id == variant?.id) { 2503 html += `selected`; 2504 } 2505 html += `>${combined_variant_name}</option>`; 2506 forloop2.next(); 2507 } 2508 html += `</select></div>`; 2509 } 2510 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 2511 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 2512 const c94 = variant.prices; 2513 const fl95 = new CF2ForloopDrop(c94.length); 2514 for (const price of c94) { 2515 const forloop2 = fl95; 2516 html += `<option `; 2517 if (selected_price?.id == price?.id) { 2518 html += `selected`; 2519 } 2520 html += ` value="${price?.id}">${price?.name}</option>`; 2521 forloop2.next(); 2522 } 2523 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 2524 } 2525 } 2526 html += `</div>`; 2527 } 2528 html += `</div>`; 2529 forloop.next(); 2530 } 2531 html += `</div></div>`; 2532 if (can_purchase_again) { 2533 html += `<div class="elProductCardNewOrderWrapper"><div class="elProductCardTitle"><span>${otherTexts?.upgradesDowngradesReactivations?.purchaseAgain}</span><div></div></div><div class="elProductCardNewOrder`; 2534 if (newOrder == true) { 2535 html += ` elProductCardOrderSelected`; 2536 } 2537 html += `"><div class="elProductCardNewOrderTitle"><i class="fas fa-plus-circle"></i><span>${otherTexts?.upgradesDowngradesReactivations?.newOrder}</span></div>`; 2538 if (newOrder == true) { 2539 html += `<div class="elProductCardOrderActions">`; 2540 if (variantDisplay != "individual") { 2541 if (customVariants?.length > 1) { 2542 html += `<div class="elProductSelectSelectorsWrapper">`; 2543 const c96 = product.sorted_property_values; 2544 const fl97 = new CF2ForloopDrop(c96.length); 2545 for (const property_values of c96) { 2546 const forloop = fl97; 2547 const property_id = property_values?.property_id; 2548 const select_index = forloop?.index0; 2549 html += ` `; 2550 html += `<div class="elSelectWrapper"><select class="elVariantSelector" name="property_${property_id}">`; 2551 const c98 = property_values.value_ids; 2552 const fl99 = new CF2ForloopDrop(c98.length); 2553 for (const value_id of c98) { 2554 const forloop2 = fl99; 2555 html += `<option `; 2556 if (variant?.property_value_ids?.[select_index] == value_id) { 2557 html += `selected`; 2558 } 2559 html += ` value="${value_id}">${product?.all_properties_values?.[value_id]}</option>`; 2560 forloop2.next(); 2561 } 2562 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 2563 forloop.next(); 2564 } 2565 html += `</div>`; 2566 } 2567 } 2568 if (priceDisplayType == "single" && variant?.prices?.length > 1) { 2569 html += `<div class="elProductSelectSelectorsWrapper"><div class="elSelectWrapper"><select name="variant_price">`; 2570 const c100 = variant.prices; 2571 const fl101 = new CF2ForloopDrop(c100.length); 2572 for (const price of c100) { 2573 const forloop = fl101; 2574 html += `<option `; 2575 if (selected_price?.id == price?.id) { 2576 html += `selected`; 2577 } 2578 html += ` value="${price?.id}">${price?.name}</option>`; 2579 forloop.next(); 2580 } 2581 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div></div>`; 2582 } 2583 html += `</div>`; 2584 } 2585 html += `</div></div>`; 2586 } 2587 html += `</div>`; 2588 } 2589 } 2590 } 2591 } 2592 } 2593 this.replaceContent(html); 2594 if (initializeChildrenInstances) { 2595 const scopeToYggRender = this.element.querySelectorAll("[ygg-render]").length > 0; 2596 const options = { scopeToYggRender }; 2597 CF2Component.hydrateTree(this.element, options); 2598 } 2599 } 2600}; 2601registerComponent("CheckoutProductCard/V2", CheckoutProductCardV2); 2602window["CheckoutProductCardV2"] = CheckoutProductCardV2; 2603
2604// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-product-select-v2.ts 2605init_define_process(); 2606
2607// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/CheckoutProductSelect/V2/checkoutProductSelect.ts 2608init_define_process(); 2609init_general(); 2610init_nanostores(); 2611init_addToCart(); 2612
2613// projects/lib/packages/yggdrasil-liquidjs/src/shared/index.ts 2614init_define_process(); 2615
2616// projects/lib/packages/yggdrasil-liquidjs/src/shared/product.ts 2617init_define_process(); 2618function get_available_variant(product) { 2619 if (product?.sorted_property_values?.length) { 2620 const allOrderedVariantCombinations = product.sorted_property_values.map((p) => p.value_ids).reduce((a, b) => a.reduce((r, v) => r.concat(b.map((w) => [].concat(v, w))), [])); 2621 const availableCombination = allOrderedVariantCombinations?.find((combination) => { 2622 const availableCombinationIdentifier = Array.isArray(combination) ? combination.join(",") : combination; 2623 return product.property_values_variant_mapping[availableCombinationIdentifier]; 2624 }); 2625 const variantId = product.property_values_variant_mapping[availableCombination]; 2626 return product.variants.find((v) => v.id === String(variantId)) ?? product.variants?.[0]; 2627 } 2628 return product?.variants?.[0]; 2629} 2630
2631// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/CheckoutProductSelect/V2/checkoutProductSelect.ts 2632var registerProductEventListeners = (pcc) => { 2633 registerUpdatableOrders(pcc); 2634 registerVariantEventListeners(pcc); 2635}; 2636var updateCardByProductIdState = (key, data) => { 2637 const oldState = productCardByProductId.get()[key]; 2638 const newState = cleanEmptyObjectKeys({ ...oldState, ...data }); 2639 productCardByProductId.setKey(key, newState); 2640 const productId = key.includes(":") ? key.split(":")[0] : key; 2641 updateProductCarousel(productId, newState.variantId); 2642}; 2643var unselectAllProducts = () => { 2644 for (const [productId, oldState] of Object.entries(productCardByProductId.get())) { 2645 const newState = cleanEmptyObjectKeys({ ...oldState, quantity: 0 }); 2646 productCardByProductId.setKey(productId, newState); 2647 } 2648}; 2649var updateProductCarousel = (productId, variantId) => { 2650 document.dispatchEvent( 2651 new CustomEvent("ProductCarousel:Update", { 2652 detail: { 2653 productId, 2654 variantId 2655 } 2656 }) 2657 ); 2658}; 2659var getCompositeKeysForProduct = (productId) => { 2660 const state = productCardByProductId.get(); 2661 return Object.keys(state).filter((k) => k.startsWith(`${productId}:`)); 2662}; 2663var getCardStateKey = (pcc) => { 2664 if (pcc.individualVariantId) { 2665 return `${pcc.product.id}:${pcc.individualVariantId}`; 2666 } 2667 return pcc.product.id; 2668}; 2669var initIndividualVariantState = () => { 2670 const currentState = productCardByProductId.get(); 2671 const products = globalThis.globalResourceData.products?.filter((p) => !p.bump) ?? []; 2672 for (const product of products) { 2673 const customVariants = product.variants.filter((v) => !v.default_variant); 2674 if (customVariants.length <= 1) continue; 2675 const firstCompositeKey = `${product.id}:${customVariants[0].id}`; 2676 if (currentState[firstCompositeKey] !== void 0) continue; 2677 const existingEntry = currentState[product.id]; 2678 for (const variant of customVariants) { 2679 const compositeKey = `${product.id}:${variant.id}`; 2680 const isSelected = existingEntry?.variantId == variant.id; 2681 productCardByProductId.setKey(compositeKey, { 2682 variantId: variant.id, 2683 priceId: variant.prices[0]?.id, 2684 quantity: isSelected ? existingEntry.quantity : 0 2685 }); 2686 } 2687 productCardByProductId.setKey(product.id, { 2688 variantId: existingEntry?.variantId, 2689 priceId: existingEntry?.priceId, 2690 quantity: 0 2691 }); 2692 } 2693}; 2694var selectFeaturedProduct = (productCardComponents) => { 2695 const featuredPcc = productCardComponents.find((pcc) => pcc.featured); 2696 if (!featuredPcc) return; 2697 const { product, individualVariantId } = featuredPcc; 2698 const variant = individualVariantId ? product.variants.find((v) => v.id == individualVariantId) : get_available_variant(product); 2699 const defaultVariant = globalThis.globalResourceData.productVariantWithNoBump; 2700 if (!variant || variant.id == defaultVariant?.id) return; 2701 const defaultEntry = productCardByProductId.get()[defaultVariant?.product_id]; 2702 if (defaultEntry) { 2703 productCardByProductId.setKey(defaultVariant.product_id, { ...defaultEntry, quantity: 0 }); 2704 } 2705 productCardByProductId.setKey(product.id, { 2706 ...productCardByProductId.get()[product.id], 2707 variantId: variant.id, 2708 priceId: variant.prices[0]?.id, 2709 quantity: 1 2710 }); 2711 globalThis.globalResourceData.productVariantWithNoBump = variant; 2712}; 2713var getProductCardByProductId = () => { 2714 const productCardByProductId2 = globalThis.globalResourceData.products?.reduce((acc, product) => { 2715 const variant = get_available_variant(product); 2716 const price = variant.prices[0]; 2717 acc[product.id] = { 2718 variantId: variant.id, 2719 priceId: price.id, 2720 quantity: 0 2721 }; 2722 return acc; 2723 }, {}); 2724 const productVariantWithNoBump = globalThis.globalResourceData.productVariantWithNoBump; 2725 let selectedVariantId, selectedPriceId, selectedProductId; 2726 if (productVariantWithNoBump) { 2727 selectedProductId = productVariantWithNoBump.product_id; 2728 selectedVariantId = productVariantWithNoBump.id; 2729 selectedPriceId = productVariantWithNoBump.prices?.[0].id; 2730 } 2731 const productCardItem = productCardByProductId2[selectedProductId]; 2732 if (productCardItem) { 2733 const product = globalThis.globalResourceData.products?.find((p) => p.id === selectedProductId); 2734 const variant = product?.variants?.find((variant2) => variant2.id === selectedVariantId); 2735 if (variant) { 2736 const price = variant?.prices?.find((price2) => price2.id === selectedPriceId); 2737 if (price) { 2738 productCardByProductId2[selectedProductId] = { 2739 variantId: variant.id, 2740 priceId: price.id, 2741 quantity: 1 2742 }; 2743 } 2744 } 2745 } 2746 return productCardByProductId2; 2747}; 2748var productCardByProductId = map(getProductCardByProductId()); 2749var sameItem = (v1, v2) => v1.type == v2.type && v1.line_item_id == v2.line_item_id && v1.product_id == v2.product_id && v1.variant_id == v2.variant_id && v1.price_id == v2.price_id && v1.quantity == v2.quantity; 2750var calculateCart = (prevCart, productCardByProductId2) => { 2751 if (globalThis.globalResourceData.cart) return structuredClone(globalThis.globalResourceData.cart); 2752 let order_id; 2753 const items = Object.entries(productCardByProductId2).filter(([, v]) => v && v.quantity > 0).map(([key, v]) => { 2754 order_id = order_id ?? v.cartItemOrderId; 2755 const productId = key.includes(":") ? key.split(":")[0] : key; 2756 return { 2757 type: v.cartItemRenderType, 2758 line_item_id: v.cartItemLineItemId, 2759 product_id: productId, 2760 variant_id: v.variantId, 2761 price_id: v.priceId, 2762 quantity: v.quantity 2763 }; 2764 }); 2765 const nextCart = { 2766 order_id, 2767 items 2768 }; 2769 const isEqual2 = prevCart.cart && prevCart.cart.order_id == nextCart.order_id && prevCart.cart.items.length == nextCart.items.length && prevCart.cart.items.every((oldItem, idx) => sameItem(oldItem, nextCart.items[idx])); 2770 if (!isEqual2) { 2771 prevCart.cart = nextCart; 2772 } 2773 return prevCart.cart; 2774}; 2775var buildProductSelectComputed = () => { 2776 const prevCart = { cart: null }; 2777 return computed( 2778 productCardByProductId, 2779 (productCardByProductId2) => calculateCart(prevCart, productCardByProductId2) 2780 ); 2781}; 2782var buildProductSelectBatched = () => { 2783 const prevCart = { cart: null }; 2784 return batched( 2785 productCardByProductId, 2786 (productCardByProductId2) => calculateCart(prevCart, productCardByProductId2) 2787 ); 2788};
2789var anyUpdatableOrders = () => { 2790 return Object.values(productCardByProductId.get()).some((v) => v.updatableOrders); 2791}; 2792var registerOneTimeCardElementListeners = (productCardComponents, onMountCallback) => { 2793 productCardComponents.forEach((pcc) => { 2794 renderPcc(pcc, onMountCallback); 2795 }); 2796 productCardByProductId.listen(() => { 2797 productCardComponents.forEach((pcc) => { 2798 renderPcc(pcc, onMountCallback); 2799 }); 2800 }); 2801 productCardComponents.forEach((pcc) => { 2802 const element = pcc.element; 2803 element.addEventListener("click", (evt) => { 2804 if (pcc.selectType == "quantity") return; 2805 const button = evt.target.closest("a"); 2806 if (button && !button.closest(".elProductCardModernButton")) return; 2807 const cardKey = getCardStateKey(pcc); 2808 if (pcc.selectType == "single") { 2809 for (const otherPcc of productCardComponents) { 2810 if (otherPcc == pcc || !otherPcc.isChecked) continue; 2811 updateCardByProductIdState(getCardStateKey(otherPcc), { quantity: 0 }); 2812 } 2813 if (pcc.id.includes("Bump")) { 2814 if (pcc.isChecked) { 2815 updateCardByProductIdState(cardKey, { quantity: 0 }); 2816 } else { 2817 updateCardByProductIdState(cardKey, { quantity: 1 }); 2818 } 2819 } else { 2820 updateCardByProductIdState(cardKey, { quantity: 1 }); 2821 } 2822 } else if (pcc.selectType == "multiple") { 2823 if (pcc.isChecked) { 2824 updateCardByProductIdState(cardKey, { quantity: 0 }); 2825 } else { 2826 updateCardByProductIdState(cardKey, { quantity: 1 }); 2827 } 2828 } 2829 }); 2830 }); 2831}; 2832var registerEventListeners = (pcc, onMountCallback) => { 2833 registerPriceEventListeners(pcc); 2834 if (onMountCallback) onMountCallback(pcc); 2835 if (pcc.selectType == "quantity") { 2836 registerQuantityEventListeners(pcc); 2837 } 2838}; 2839var registerVariantEventListeners = (pcc) => { 2840 const element = pcc.element; 2841 const variantSelects = element.querySelectorAll(".elVariantSelector"); 2842 variantSelects.forEach((select, index) => { 2843 select.addEventListener("click", (evt) => { 2844 evt.stopImmediatePropagation(); 2845 evt.stopPropagation(); 2846 evt.preventDefault(); 2847 }); 2848 select.addEventListener("change", (evt) => { 2849 evt.stopImmediatePropagation(); 2850 evt.stopPropagation(); 2851 evt.preventDefault(); 2852 const newValues = [...variantSelects].map((e) => e.value); 2853 const selectedVariantId = getSelectedVariant(pcc, index, newValues); 2854 const newVariant = pcc.product.variants.find((v) => v.id == String(selectedVariantId)); 2855 const newPrice = newVariant.prices[0]; 2856 updateCardByProductIdState(getCardStateKey(pcc), { 2857 variantId: newVariant.id, 2858 priceId: newPrice.id 2859 }); 2860 }); 2861 }); 2862}; 2863var registerUpdatableOrders = (pcc) => { 2864 const element = pcc.element; 2865 const previousOrders = element.querySelectorAll(".elProductCardOrder"); 2866 const newOrder = element.querySelector(".elProductCardNewOrder"); 2867 previousOrders?.forEach((orderElement) => { 2868 const showOrderDetailsLink = orderElement.querySelector(".elProductCardShowOrderDetailsLink"); 2869 const upgradeAndDowngradeSelector = orderElement.querySelector('[name="upgradeDowngrade"]'); 2870 const orderIndex = Number(orderElement.getAttribute("data-order-index")); 2871 const order = pcc.updatableOrders[orderIndex]; 2872 orderElement.addEventListener("click", (evt) => { 2873 evt.stopImmediatePropagation(); 2874 evt.stopPropagation(); 2875 evt.preventDefault(); 2876 const cardKey = getCardStateKey(pcc); 2877 const renderType = order.type; 2878 const cardDetails = pcc.updatableOrders[orderIndex].updatableItems[0].cardDetails; 2879 const updateCardNewState = { 2880 selectedOrderIndex: orderIndex, 2881 selectedUpdatableCartItemIndex: 0, 2882 renderType, 2883 variantId: cardDetails.variantId, 2884 priceId: cardDetails.priceId, 2885 cartItemRenderType: renderType, 2886 cartItemOrderId: cardDetails.orderId, 2887 cartItemLineItemId: cardDetails.lineItemId 2888 }; 2889 updateCardByProductIdState(cardKey, updateCardNewState); 2890 }); 2891 showOrderDetailsLink?.addEventListener("click", (evt) => { 2892 evt.stopImmediatePropagation(); 2893 evt.stopPropagation(); 2894 evt.preventDefault(); 2895 globalThis.Checkout.store.selectedOrderDetailId.set(order.id); 2896 }); 2897 upgradeAndDowngradeSelector?.addEventListener("click", (evt) => { 2898 evt.preventDefault(); 2899 evt.stopImmediatePropagation(); 2900 evt.stopPropagation(); 2901 }); 2902 upgradeAndDowngradeSelector?.addEventListener("change", (evt) => { 2903 evt.stopImmediatePropagation(); 2904 evt.stopPropagation(); 2905 evt.preventDefault(); 2906 const updatableItemIndex = Number(evt.target.value);
2907 const cardDetails = order.updatableItems[updatableItemIndex].cardDetails; 2908 const updateCardNewState = { 2909 selectedUpdatableCartItemIndex: updatableItemIndex, 2910 variantId: cardDetails.variantId, 2911 priceId: cardDetails.priceId, 2912 cartItemOrderId: cardDetails.orderId, 2913 cartItemLineItemId: cardDetails.lineItemId 2914 }; 2915 updateCardByProductIdState(getCardStateKey(pcc), updateCardNewState); 2916 }); 2917 }); 2918 newOrder?.addEventListener("click", () => { 2919 const variant = pcc.individualVariantId ? pcc.product.variants.find((v) => v.id == pcc.individualVariantId) ?? pcc.product.variants[0] : pcc.product.variants[0]; 2920 const variantId = variant.id; 2921 const priceId = variant.prices[0].id; 2922 const updateCardNewState = { 2923 variantId, 2924 priceId, 2925 selectedOrderIndex: -1, 2926 selectedUpdatableCartItemIndex: 0, 2927 cartItemRenderType: void 0, 2928 cartItemOrderId: void 0, 2929 cartItemLineItemId: void 0 2930 }; 2931 updateCardByProductIdState(getCardStateKey(pcc), updateCardNewState); 2932 }); 2933}; 2934var registerPriceEventListeners = (pcc) => { 2935 const element = pcc.element; 2936 const variantPriceSelector = element.querySelector('[name="variant_price"]'); 2937 variantPriceSelector?.addEventListener("click", (evt) => { 2938 evt.preventDefault(); 2939 evt.stopImmediatePropagation(); 2940 evt.stopPropagation(); 2941 }); 2942 variantPriceSelector?.addEventListener("change", (evt) => { 2943 evt.stopImmediatePropagation(); 2944 evt.stopPropagation(); 2945 evt.preventDefault(); 2946 const newPriceId = Number(evt.target.value); 2947 updateCardByProductIdState(getCardStateKey(pcc), { priceId: newPriceId }); 2948 }); 2949}; 2950var registerQuantityEventListeners = (pcc) => { 2951 const element = pcc.element; 2952 const [minusButton, plusButton] = element.querySelectorAll(".elProductInputControls button"); 2953 const input = element.querySelector(".elProductInputControls input"); 2954 minusButton.addEventListener("click", (evt) => { 2955 evt.preventDefault(); 2956 if (pcc.quantity === 0) return; 2957 const newQuantity = pcc.quantity - 1; 2958 updateCardByProductIdState(getCardStateKey(pcc), { quantity: newQuantity }); 2959 }); 2960 plusButton.addEventListener("click", (evt) => { 2961 evt.preventDefault(); 2962 const newQuantity = pcc.quantity + 1; 2963 updateCardByProductIdState(getCardStateKey(pcc), { quantity: newQuantity }); 2964 }); 2965 input.addEventListener("blur", (evt) => { 2966 const newQuantity = parseInt(evt.target.value); 2967 if (newQuantity == 0 || isNaN(newQuantity)) { 2968 updateCardByProductIdState(getCardStateKey(pcc), { quantity: 0 }); 2969 } else { 2970 updateCardByProductIdState(getCardStateKey(pcc), { quantity: newQuantity }); 2971 } 2972 }); 2973}; 2974var renderAndMount = (pcc, onMountCallback) => { 2975 if (pcc.id.includes("Bump")) { 2976 pcc.renderAndMount(); 2977 registerPriceEventListeners(pcc); 2978 } else { 2979 pcc.render(); 2980 } 2981 if (pcc.skipMountOnRender) return; 2982 registerEventListeners(pcc, onMountCallback); 2983}; 2984var renderPcc = (pcc, onMountCallback) => { 2985 const stateKey = getCardStateKey(pcc); 2986 const updates = productCardByProductId.get()[stateKey]; 2987 if (!updates) return; 2988 let newSelectType; 2989 if (anyUpdatableOrders()) { 2990 newSelectType = "single"; 2991 } else if (!pcc.product.bump) { 2992 newSelectType = globalThis.globalResourceData.product_quantity_type ?? "single"; 2993 } else { 2994 newSelectType = pcc.selectType; 2995 } 2996 if (pcc.renderType == updates.renderType && pcc.variant.id == updates.variantId && pcc.selected_price.id == updates.priceId && pcc.quantity == updates.quantity && pcc.selectType == newSelectType && pcc.selectedOrderIndex == updates.selectedOrderIndex && pcc.selectedUpdatableCartItemIndex == updates.selectedUpdatableCartItemIndex && pcc.updatableOrders == updates.updatableOrders && pcc.individualDirection == updates.individualDirection) 2997 return; 2998 pcc.renderType = updates.renderType; 2999 pcc.variant = globalThis.globalResourceData.variantsById[updates.variantId]; 3000 pcc.selected_price = globalThis.globalResourceData.pricesById[updates.priceId]; 3001 pcc.quantity = updates.quantity; 3002 pcc.selectType = newSelectType; 3003 pcc.selectedOrderIndex = updates.selectedOrderIndex; 3004 pcc.selectedUpdatableCartItemIndex = updates.selectedUpdatableCartItemIndex; 3005 pcc.updatableOrders = updates.updatableOrders; 3006 pcc.individualDirection = updates.individualDirection; 3007 pcc.isChecked = updates.quantity > 0; 3008 if (pcc.isChecked) { 3009 pcc.element.classList.add("elProductSelected"); 3010 } else { 3011 pcc.element.classList.remove("elProductSelected"); 3012 } 3013 renderAndMount(pcc, onMountCallback); 3014}; 3015
3016// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-product-select-v2.ts 3017init_runtime(); 3018var CheckoutProductSelectV2 = class extends CF2Component { 3019 constructor(el, runtimeSel) { 3020 super(el, runtimeSel); 3021 } 3022 mount() { 3023 const productCardComponents = this.getComponents("CheckoutProductCard/V2"); 3024 selectFeaturedProduct(productCardComponents); 3025 registerOneTimeCardElementListeners(productCardComponents, (pcc) => { 3026 registerProductEventListeners(pcc); 3027 }); 3028 productCardComponents.forEach((pcc) => { 3029 registerEventListeners(pcc, (pcc2) => { 3030 registerProductEventListeners(pcc2); 3031 }); 3032 }); 3033 } 3034}; 3035registerComponent("CheckoutProductSelect/V2", CheckoutProductSelectV2); 3036window["CheckoutProductSelectV2"] = CheckoutProductSelectV2; 3037
3038// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-product-card-bump-v2.ts 3039init_define_process(); 3040init_checkbox_v1(); 3041init_runtime(); 3042var CheckoutProductCardBumpV2 = class extends CF2Component { 3043 constructor(el, runtimeSel) { 3044 super(el, runtimeSel); 3045 __publicField(this, "skipMountOnRender", true); 3046 } 3047 mount() { 3048 } 3049 renderAndMount() { 3050 const checkBox = this.getComponent("Checkbox/V1"); 3051 checkBox.setChecked(this.isChecked); 3052 const arrow = this.element.querySelector(".elProductBumpHeadlineArrow"); 3053 const modernButtonText = this.element.querySelector(".elProductCardModernButton > span"); 3054 if (this.isChecked) { 3055 this.element.classList.add("elProductSelected"); 3056 if (arrow) arrow.classList.add("elHide"); 3057 if (modernButtonText) modernButtonText.innerText = this.checkoutProductCardBumpTexts.unselect; 3058 } else { 3059 this.element.classList.remove("elProductSelected"); 3060 if (arrow) arrow.classList.remove("elHide"); 3061 if (modernButtonText) modernButtonText.innerText = this.checkoutProductCardBumpTexts.add; 3062 } 3063 if (this.selectType === "quantity") { 3064 const quantityInput = this.element.querySelector(".elProductCardShortInput"); 3065 if (quantityInput) quantityInput.value = this.quantity; 3066 } 3067 this.render(); 3068 } 3069 remove() { 3070 this.element.innerHTML = ""; 3071 } 3072 render(initializeChildrenInstances = false) { 3073 const is_server = true; 3074 const selectType = this.selectType ?? null; 3075 const isChecked = this.isChecked ?? false; 3076 const showImage = this.showImage ?? null; 3077 const layout = this.layout ?? null; 3078 const product = this.product ?? null; 3079 const variant = this.variant ?? null; 3080 const selected_price = this.selected_price ?? null; 3081 const quantity = this.quantity ?? 0; 3082 const arrow = this.arrow ?? null; 3083 const checkoutProductCardBumpTexts = this.checkoutProductCardBumpTexts ?? null; 3084 const showDescription = this.element.getAttribute("data-param-showDescription"); 3085 const showCompareAtPrice = this.element.getAttribute("data-param-showCompareAtPrice"); 3086 let html = ""; 3087 { 3088 html += `<div class="elProductLayoutBorder"></div><div class="elProductLayoutBackground"></div>`; 3089 const customVariants = product?.variants.filter((value) => value["default_variant"] == false); 3090 const product_name = "product_bump"; 3091 if (layout == "classic") { 3092 html += `<div class="elProductCardImage" ygg-render="1">`; 3093 const imageUrl = variant?.image ?? product.image; 3094 if (showImage && imageUrl && imageUrl != "") { 3095 html += `<div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 3096 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 3097 html += ` forceHide`; 3098 } 3099 html += `" data-liquid-replace="item">`; 3100 if (imageUrl || !CF2Blank(null)) { 3101 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 3102 } else if (false) { 3103 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 3104 } 3105 html += `</div>`; 3106 } 3107 html += `</div>`; 3108 html += `<div class="elProductCardInfoContainer"><div class="elProductCardInputAndTitle">`; 3109 const isClassic = layout == "classic"; 3110 if (arrow?.icon != "none" && isChecked != true) { 3111 if (arrow?.animation) { 3112 html += `<span data-animation-type="${arrow?.animation}" data-animation-delay="600" data-animation-loop="true" class="elProductBumpHeadlineArrow"><i class="${arrow?.icon}"></i></span>`; 3113 } else { 3114 html += `<span class="elProductBumpHeadlineArrow"><i class="${arrow?.icon}"></i></span>`; 3115 } 3116 } 3117 html += `<div class="elProductCardSelectInput`; 3118 if (isClassic == false || selectType == "quantity") { 3119 html += ` elHide`; 3120 } 3121 html += `">`; 3122 if (isChecked) { 3123 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked="true"><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}
3123" name="product" checked data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 3124 } else { 3125 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked=""><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 3126 } 3127 html += `</div>`; 3128 const base_date = "1760652000"; 3129 if (product?.headline) { 3130 html += `${product?.headline}`; 3131 } else if (customVariants?.length > 1) { 3132 if (product?.bump_preheadline && product?.updated_at_timestamp && product?.updated_at_timestamp > "1760652000") { 3133 html += `${product?.bump_preheadline}<br/>`; 3134 } 3135 html += `${product?.default_variant?.name ?? "One time offer:"}`; 3136 } else { 3137 if (product?.bump_preheadline && product?.updated_at_timestamp && product?.updated_at_timestamp > "1760652000") { 3138 html += `${product?.bump_preheadline}<br/>`; 3139 } 3140 html += `${variant?.name ?? "One time offer:"}`; 3141 } 3142 html += `</div><div class="elProductCardPriceContainer" ygg-render="2">`; 3143 if (variant?.prices?.length > 1) { 3144 html += `<div class="elSelectWrapper"><select name="variant_price">`; 3145 const c0 = variant.prices; 3146 const fl1 = new CF2ForloopDrop(c0.length); 3147 for (const price of c0) { 3148 const forloop = fl1; 3149 html += `<option `; 3150 if (selected_price?.id == price?.id) { 3151 html += `selected`; 3152 } 3153 html += ` value="${price?.id}">${price?.name}</option>`; 3154 forloop.next(); 3155 } 3156 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 3157 } 3158 if (variant?.prices?.length == 1) { 3159 html += `<div class="elProductCardInfoPrice">`; 3160 if (showCompareAtPrice) { 3161 const compare_at_amount = selected_price?.compare_at_amount; 3162 if (compare_at_amount) { 3163 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`; 3164 } 3165 } 3166 html += `<span class="elProductCardFinalPrice">
3166${selected_price?.name}</span></div>`; 3167 } 3168 html += `</div>`; 3169 const desc = (product?.description_override ?? variant.description ?? product.default_variant.description ?? "").replaceAll(` 3170`, "<br>"); 3171 if (desc != "") { 3172 html += `<div class="elProductCardDescription"><span class="elProductBumpText">${desc}</span></div>`; 3173 } 3174 if (customVariants?.length > 1) { 3175 html += `<div class="elProductSelectSelectorsWrapper">`; 3176 if (customVariants?.length > 1) { 3177 html += `<div class="elSelectWrapper"><select class="elBumpVariantSelector">`; 3178 const c2 = product.variants; 3179 const fl3 = new CF2ForloopDrop(c2.length); 3180 for (const product_variant of c2) { 3181 const forloop = fl3; 3182 const variant_index = forloop?.index0; 3183 let combined_variant_name = ""; 3184 const c4 = product.sorted_property_values; 3185 const fl5 = new CF2ForloopDrop(c4.length); 3186 for (const property_values of c4) { 3187 const forloop2 = fl5; 3188 const index0 = forloop2?.index0; 3189 const property_id = property_values?.property_id; 3190 const property_value_id = product_variant?.property_value_ids?.[index0]; 3191 if (combined_variant_name != "") { 3192 combined_variant_name = combined_variant_name.toString().concat(", "); 3193 } 3194 combined_variant_name = combined_variant_name.toString().concat(product.all_properties[property_id]); 3195 combined_variant_name = combined_variant_name.toString().concat(": "); 3196 combined_variant_name = combined_variant_name.toString().concat(product.all_properties_values[property_value_id]); 3197 forloop2.next(); 3198 } 3199 html += `<option value="${product_variant?.property_value_ids}" `; 3200 if (product_variant?.id == variant?.id) { 3201 html += `selected`; 3202 } 3203 html += `>${combined_variant_name}</option>`; 3204 forloop.next(); 3205 } 3206 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 3207 } 3208 html += `</div>`; 3209 } 3210 if (selectType == "quantity") { 3211 html += `<div class="elProductInputWrapper elProductCardQuantityContainer"><span>${checkoutProductCardBumpTexts?.quantity}</span><div class="elProductInputControls"><button class="elProductCardInput">-</button><input class="elProductCardInput elProductCardShortInput" name="product" value="${quantity ?? 0}" min="0" type="number"/><button class="elProductCardInput">+</button></div></div>`; 3212 } else if (selectType == "quantity-forced") { 3213 html += `<div class="elProductInputWrapper elSelectWrapper elForcedQuantityWrapper"><span>${checkoutProductCardBumpTexts?.quantity}</span><select name="product" class="elProductCardInput elProductInputControls">`; 3214 const step = product?.step ?? 2; 3215 const min = product?.min ?? 0; 3216 const max = product?.max ?? 5; 3217 const item_count_step_1 = max - min; 3218 const item_count_step_2 = item_count_step_1 / step; 3219 const item_count_step_3 = item_count_step_2 | 0; 3220 const range = Array.apply(0, Array(item_count_step_3)).map((element, index) => index + 0); 3221 ; 3222 const c6 = range; 3223 const fl7 = new CF2ForloopDrop(c6.length); 3224 for (const i of c6) { 3225 const forloop = fl7; 3226 const value = i * step + min; 3227 html += `<option value="${value}">${value}</option>`; 3228 forloop.next(); 3229 } 3230 html += `</select><div class="elSelectArrow elForcedQuantitySelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 3231 } 3232 html += `</div>`; 3233 } else { 3234 html += `<div class="elProductCardImage" ygg-render="1">`; 3235 const imageUrl = variant?.image ?? product.image; 3236 if (showImage && imageUrl && imageUrl != "") { 3237 html += `<div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 3238 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 3239 html += ` forceHide`; 3240 } 3241 html += `" data-liquid-replace="item">`; 3242 if (imageUrl || !CF2Blank(null)) { 3243 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 3244 } else if (false) { 3245 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 3246 } 3247 html += `</div>`; 3248 } 3249 html += `</div>`; 3250 html += `<div class="elProductCardInfoContainer"><div class="elProductCardInputAndTitle">`; 3251 const isClassic = layout == "classic"; 3252 if (arrow?.icon != "none" && isChecked != true) { 3253 if (arrow?.animation) { 3254 html += `<span data-animation-type="${arrow?.animation}" data-animation-delay="600" data-animation-loop="true" class="elProductBumpHeadlineArrow"><i class="${arrow?.icon}"></i></span>`;
3255 } else { 3256 html += `<span class="elProductBumpHeadlineArrow"><i class="${arrow?.icon}"></i></span>`; 3257 } 3258 } 3259 html += `<div class="elProductCardSelectInput`; 3260 if (isClassic == false || selectType == "quantity") { 3261 html += ` elHide`; 3262 } 3263 html += `">`; 3264 if (isChecked) { 3265 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked="true"><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" checked data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 3266 } else { 3267 html += `<div data-page-element="Checkbox/V1" type="custom_type" class="elCheckboxWrapper elFormItemWrapper de-input-block id-Checkbox/V1" data-content="" data-liquid-replace="item" data-prevent-click-on-label="false" data-trigger-click-on-wrapper="false" data-checked=""><label class="elCheckboxLabel"><input type="checkbox" value="${product?.id}" name="product" data-prevent-garlic="false" class="elCheckboxInput inputHolder"/><div class="elCheckbox"><div class="elCheckboxIcon"><div class="elCheckboxIconSquare hide"></div><i class="elCheckboxIconCheck fas fa-check"></i></div></div><span class="elCheckboxText"></span></label><div data-input-status-type="true" data-error-container="true"></div></div>`; 3268 } 3269 html += `</div>`; 3270 const base_date = "1760652000"; 3271 if (product?.headline) { 3272 html += `${product?.headline}`; 3273 } else if (customVariants?.length > 1) { 3274 if (product?.bump_preheadline && product?.updated_at_timestamp && product?.updated_at_timestamp > "1760652000") { 3275 html += `${product?.bump_preheadline}<br/>`; 3276 } 3277 html += `${product?.default_variant?.name ?? "One time offer:"}`; 3278 } else { 3279 if (product?.bump_preheadline && product?.updated_at_timestamp && product?.updated_at_timestamp > "1760652000") { 3280 html += `${product?.bump_preheadline}<br/>`; 3281 } 3282 html += `${variant?.name ?? "One time offer:"}`; 3283 } 3284 html += `</div><div class="elProductCardPriceContainer" ygg-render="2">`; 3285 if (variant?.prices?.length > 1) { 3286 html += `<div class="elSelectWrapper"><select name="variant_price">`; 3287 const c8 = variant.prices; 3288 const fl9 = new CF2ForloopDrop(c8.length); 3289 for (const price of c8) { 3290 const forloop = fl9; 3291 html += `<option `; 3292 if (selected_price?.id == price?.id) { 3293 html += `selected`; 3294 } 3295 html += ` value="${price?.id}">${price?.name}</option>`; 3296 forloop.next(); 3297 } 3298 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 3299 } 3300 if (variant?.prices?.length == 1) { 3301 html += `<div class="elProductCardInfoPrice">`; 3302 if (showCompareAtPrice) { 3303 const compare_at_amount = selected_price?.compare_at_amount; 3304 if (compare_at_amount) { 3305 html += `<span class="elProductCardAnchorPrice">${compare_at_amount}</span>`; 3306 } 3307 } 3308 html += `<span class="elProductCardFinalPrice">
3308${selected_price?.name}</span></div>`; 3309 } 3310 html += `</div>`; 3311 const desc = (product?.description_override ?? variant.description ?? product.default_variant.description ?? "").replaceAll(` 3312`, "<br>"); 3313 if (desc != "") { 3314 html += `<div class="elProductCardDescription"><span class="elProductBumpText">${desc}</span></div>`; 3315 } 3316 if (customVariants?.length > 1) { 3317 html += `<div class="elProductSelectSelectorsWrapper">`; 3318 if (customVariants?.length > 1) { 3319 html += `<div class="elSelectWrapper"><select class="elBumpVariantSelector">`; 3320 const c10 = product.variants; 3321 const fl11 = new CF2ForloopDrop(c10.length); 3322 for (const product_variant of c10) { 3323 const forloop = fl11; 3324 const variant_index = forloop?.index0; 3325 let combined_variant_name = ""; 3326 const c12 = product.sorted_property_values; 3327 const fl13 = new CF2ForloopDrop(c12.length); 3328 for (const property_values of c12) { 3329 const forloop2 = fl13; 3330 const index0 = forloop2?.index0; 3331 const property_id = property_values?.property_id; 3332 const property_value_id = product_variant?.property_value_ids?.[index0]; 3333 if (combined_variant_name != "") { 3334 combined_variant_name = combined_variant_name.toString().concat(", "); 3335 } 3336 combined_variant_name = combined_variant_name.toString().concat(product.all_properties[property_id]); 3337 combined_variant_name = combined_variant_name.toString().concat(": "); 3338 combined_variant_name = combined_variant_name.toString().concat(product.all_properties_values[property_value_id]); 3339 forloop2.next(); 3340 } 3341 html += `<option value="${product_variant?.property_value_ids}" `; 3342 if (product_variant?.id == variant?.id) { 3343 html += `selected`; 3344 } 3345 html += `>${combined_variant_name}</option>`; 3346 forloop.next(); 3347 } 3348 html += `</select><div class="elSelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 3349 } 3350 html += `</div>`; 3351 } 3352 if (selectType == "quantity") { 3353 html += `<div class="elProductInputWrapper elProductCardQuantityContainer"><span>${checkoutProductCardBumpTexts?.quantity}</span><div class="elProductInputControls"><button class="elProductCardInput">-</button><input class="elProductCardInput elProductCardShortInput" name="product" value="${quantity ?? 0}" min="0" type="number"/><button class="elProductCardInput">+</button></div></div>`; 3354 } else if (selectType == "quantity-forced") { 3355 html += `<div class="elProductInputWrapper elSelectWrapper elForcedQuantityWrapper"><span>${checkoutProductCardBumpTexts?.quantity}</span><select name="product" class="elProductCardInput elProductInputControls">`; 3356 const step = product?.step ?? 2; 3357 const min = product?.min ?? 0; 3358 const max = product?.max ?? 5; 3359 const item_count_step_1 = max - min; 3360 const item_count_step_2 = item_count_step_1 / step; 3361 const item_count_step_3 = item_count_step_2 | 0; 3362 const range = Array.apply(0, Array(item_count_step_3)).map((element, index) => index + 0); 3363 ; 3364 const c14 = range; 3365 const fl15 = new CF2ForloopDrop(c14.length); 3366 for (const i of c14) { 3367 const forloop = fl15; 3368 const value = i * step + min; 3369 html += `<option value="${value}">${value}</option>`; 3370 forloop.next(); 3371 } 3372 html += `</select><div class="elSelectArrow elForcedQuantitySelectArrow"><i class="fas fa-chevron-down"></i></div></div>`; 3373 } 3374 html += `</div>`; 3375 if (selectType != "quantity") { 3376 html += `<div class="elProductCardModernButton">`; 3377 if (isChecked) { 3378 html += `<span>${checkoutProductCardBumpTexts?.unselect}</span>`;
3379 } else { 3380 html += `<span>${checkoutProductCardBumpTexts?.add}</span>`; 3381 } 3382 html += `</div>`; 3383 } 3384 } 3385 } 3386 this.replaceContent(html); 3387 if (initializeChildrenInstances) { 3388 const scopeToYggRender = this.element.querySelectorAll("[ygg-render]").length > 0; 3389 const options = { scopeToYggRender }; 3390 CF2Component.hydrateTree(this.element, options); 3391 } 3392 } 3393}; 3394registerComponent("CheckoutProductCardBump/V2", CheckoutProductCardBumpV2); 3395window["CheckoutProductCardBumpV2"] = CheckoutProductCardBumpV2; 3396
3397// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-product-select-bump-v2.ts 3398init_define_process(); 3399init_runtime(); 3400var CheckoutProductSelectBumpV2 = class extends CF2Component { 3401 constructor(el, runtimeSel) { 3402 super(el, runtimeSel); 3403 } 3404 mount() { 3405 const productCardComponents = this.getComponents("CheckoutProductCardBump/V2"); 3406 registerOneTimeCardElementListeners(productCardComponents); 3407 productCardComponents.forEach((pcc) => { 3408 registerEventListeners(pcc); 3409 this.registerBumpVariantEventListeners(pcc); 3410 }); 3411 } 3412 registerBumpVariantEventListeners(pcc) { 3413 const element = pcc.element; 3414 const variantSelects = element.querySelectorAll(".elBumpVariantSelector"); 3415 variantSelects.forEach((select, index) => { 3416 select.addEventListener("click", (evt) => { 3417 evt.stopImmediatePropagation(); 3418 evt.stopPropagation(); 3419 evt.preventDefault(); 3420 }); 3421 select.addEventListener("change", (evt) => { 3422 evt.stopImmediatePropagation(); 3423 evt.stopPropagation(); 3424 evt.preventDefault(); 3425 const newValues = [...variantSelects].map((e) => e.value); 3426 const selectedVariantId = pcc.product.property_values_variant_mapping[newValues]; 3427 const oldCartItem = { product_id: pcc.product.id, variant_id: pcc.variant.id, price_id: pcc.selected_price.id }; 3428 const newVariant = pcc.product.variants.find((v) => v.id == String(selectedVariantId)); 3429 const newPrice = newVariant.prices[0]; 3430 const newCartItem = { product_id: pcc.product.id, variant_id: newVariant.id, price_id: newPrice.id }; 3431 updateCardByProductIdState(pcc.product.id, { variantId: newVariant.id, priceId: newPrice.id }); 3432 pcc.renderAndMount(); 3433 registerPriceEventListeners(pcc); 3434 }); 3435 }); 3436 } 3437}; 3438registerComponent("CheckoutProductSelectBump/V2", CheckoutProductSelectBumpV2); 3439window["CheckoutProductSelectBumpV2"] = CheckoutProductSelectBumpV2; 3440
3441// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-shipping-profile-select-v1.ts 3442init_define_process(); 3443init_radio_v1(); 3444init_cf_utils(); 3445init_cfLodash(); 3446init_runtime(); 3447var CheckoutShippingProfileSelectV1 = class extends CF2Component { 3448 constructor(el, runtimeSel) { 3449 super(el, runtimeSel); 3450 __publicField(this, "loadingShipping"); 3451 __publicField(this, "shippingOptions"); 3452 __publicField(this, "shippingOption"); 3453 } 3454 onSelectOption(option) { 3455 } 3456 mount() { 3457 this.element.addEventListener("click", (evt) => { 3458 const shippingProfileCards = this.element.querySelectorAll(".elShippingProfile"); 3459 for (const card of shippingProfileCards) { 3460 if (isEventInside(evt, card)) { 3461 evt.preventDefault(); 3462 const key = card.getAttribute("data-shipping-option"); 3463 if (key) { 3464 const option = this.shippingOptions.find(({ description }) => description === key); 3465 this.onSelectOption(option.value); 3466 } 3467 break; 3468 } 3469 } 3470 }); 3471 } 3472 show() { 3473 this.element.classList.remove("forceHide"); 3474 } 3475 hide() { 3476 this.element.classList.add("forceHide"); 3477 } 3478 setOption(option) { 3479 this.shippingOption = option; 3480 const radio = this.shippingOption && this.element.querySelector(`[data-shipping-option="${this.shippingOption.description}"] .elRadioInput`); 3481 if (radio) { 3482 radio.checked = true; 3483 } 3484 } 3485 isEqualState(newState) { 3486 const updatableKeys = ["hasValidShippingAddress", "loadingShipping", "summaryHasError", "shippingOption", "shippingOptions"]; 3487 const currentState = updatableKeys.reduce((acc, key) => { 3488 acc[key] = this[key]; 3489 return acc; 3490 }, {}); 3491 return isEqual(newState, currentState); 3492 } 3493 updateState(data) { 3494 const newState = { 3495 hasValidShippingAddress: false, 3496 loadingShipping: false, 3497 summaryHasError: false, 3498 shippingOption: null, 3499 shippingOptions: [], 3500 ...data 3501 }; 3502 if (this.isEqualState(newState)) return false; 3503 Object.assign(this, newState); 3504 this.render(); 3505 return true; 3506 } 3507 setLoading() { 3508 this.updateState({ 3509 loadingShipping: true, 3510 hasValidShippingAddress: true 3511 }); 3512 } 3513 setInvalidAddress() { 3514 this.updateState({ 3515 hasValidShippingAddress: false 3516 }); 3517 } 3518 setSummaryError() { 3519 this.updateState({ 3520 summaryHasError: true 3521 }); 3522 } 3523 setShippingOptions(shippingOptions, shippingOption) { 3524 const result = this.updateState({ 3525 shippingOption, 3526 shippingOptions: this.formatShippingOptions(shippingOptions), 3527 hasValidShippingAddress: true 3528 }); 3529 if (result) this.setOption(this.shippingOption); 3530 } 3531 formatShippingOptions(shippingOptions) { 3532 return shippingOptions.map((option) => { 3533 const { description, amount: { amount, currency }, amount_formatted } = option; 3534 return { 3535 key: JSON.stringify(option), 3536 value: option, 3537 description, 3538 priceLabel: amount_formatted 3539 }; 3540 }); 3541 } 3542 update({ shippingOptions, ...state }) { 3543 Object.assign(this, state); 3544 if (shippingOptions) { 3545 this.shippingOptions = shippingOptions?.map((option) => { 3546 const { description, amount: { amount, currency }, amount_formatted } = option; 3547 return { 3548 key: JSON.stringify(option), 3549 value: option, 3550 description, 3551 priceLabel: amount_formatted 3552 }; 3553 }); 3554 } 3555 this.render(); 3556 this.setOption(this.shippingOption); 3557 } 3558 remove() { 3559 this.element.innerHTML = ""; 3560 } 3561 render(initializeChildrenInstances = false) { 3562 const is_server = true; 3563 const title = this.title ?? null; 3564 const titleEnabled = this.titleEnabled ?? null; 3565 const otherTexts = this.otherTexts ?? null; 3566 const shippingOptions = this.shippingOptions ?? []; 3567 const shippingOption = this.shippingOption ?? void 0; 3568 const hasValidShippingAddress = this.hasValidShippingAddress ?? false; 3569 const loadingShipping = this.loadingShipping ?? false; 3570 const summaryHasError = this.summaryHasError ?? false; 3571 let html = ""; 3572 { 3573 if (titleEnabled) { 3574 html += `<div class="elCheckoutFormLabelContainer"><div class="elCheckoutFormLabel">${title}</div> <hr class="elCheckoutFormLabelDivider"/></div>`; 3575 } 3576 html += `<div class="elShippingProfileList" ygg-render="replace">`; 3577 if (summaryHasError) { 3578 html += `<div class="elShippingProfileCardWrapper elShippingProfilesEmpty"> <div class="elShippingProfile elShippingProfileLayout">
3578<div class="elShippingProfileLayoutBackground"></div><div><p></p></div></div></div>`; 3579 } else if (hasValidShippingAddress || false) { 3580 if (loadingShipping) { 3581 html += `<div class="elShippingProfileCardWrapper elShippingProfilesEmpty"> <div class="elShippingProfile elShippingProfileLayout"><div class="elShippingProfileLayoutBackground"></div><div><div><i class="fa fa-spinner fa-spin"></i></div></div></div></div>`; 3582 } else if (shippingOptions && shippingOptions?.length > 0) { 3583 const c0 = shippingOptions; 3584 const fl1 = new CF2ForloopDrop(c0.length); 3585 for (const shippingProfile of c0) { 3586 const forloop = fl1; 3587 const currentIndex = forloop?.index0; 3588 const isDefaultValue = currentIndex == 0; 3589 const hasValue = shippingOption; 3590 const isSelected = shippingOption == shippingProfile?.key; 3591 html += ` `; 3592 const isChecked = hasValue && isSelected || isDefaultValue; 3593 html += ` `; 3594 html += `<div class="elShippingProfileCardWrapper"><div class="elShippingProfile elShippingProfileLayout`; 3595 if (isChecked) { 3596 html += ` elShippingProfileSelected`; 3597 } 3598 html += ` elShippingProfileClickable" data-shipping-option="${shippingProfile?.description}"><div class="elShippingProfileLayoutBackground"></div><div class="elShippingProfileSelectInput">`; 3599 if (isChecked) { 3600 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="true" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="shipping_profile" checked class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 3601 } else { 3602 html += `<div data-page-element="Radio/V1" class="elRadioWrapper id-Radio/V1" data-liquid-replace="item" data-checked="" data-trigger-click-on-wrapper="false"><label class="elRadioLabel"><input type="radio" value="" name="shipping_profile" class="elRadioInput"/><div class="elRadio"><div class="elRadioIcon"></div></div><span class="elRadioText"></span></label></div>`; 3603 } 3604 html += `</div> <div class="elShippingProfileCardNameContainer"><div class="elShippingProfileCardInfoName">${shippingProfile?.description}</div></div> <div class="elShippingProfileCardPriceContainer"><span class="elShippingProfileInfoPrice elShippingProfileFinalPrice">${shippingProfile?.priceLabel}</span></div></div></div>`; 3605 forloop.next(); 3606 } 3607 } else if (shippingOptions && shippingOptions?.length == 0) { 3608 html += `<div class="elShippingProfileCardWrapper elShippingProfilesEmpty"> <div class="elShippingProfile elShippingProfileLayout"><div class="elShippingProfileLayoutBackground"></div><div><div><i class="fa fa-truck"></i></div><p></p></div></div></div>`; 3609 } 3610 } else { 3611 html += `<div class="elShippingProfileCardWrapper elShippingProfilesEmpty"> <div class="elShippingProfile elShippingProfileLayout"><div class="elShippingProfileLayoutBackground"></div><div><div><i class="fa fa-truck"></i></div><p>${otherTexts?.shippingOptionsPlaceholder}</p></div></div></div>`; 3612 } 3613 html += `</div>`; 3614 } 3615 this.replaceContent(html); 3616 if (initializeChildrenInstances) { 3617 const scopeToYggRender = this.element.querySelectorAll("[ygg-render]").length > 0; 3618 const options = { scopeToYggRender }; 3619 CF2Component.hydrateTree(this.element, options); 3620 } 3621 } 3622}; 3623registerComponent("CheckoutShippingProfileSelect/V1", CheckoutShippingProfileSelectV1); 3624window["CheckoutShippingProfileSelectV1"] = CheckoutShippingProfileSelectV1; 3625
3626// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-loading-v1.ts 3627init_define_process(); 3628init_runtime(); 3629var CheckoutLoadingV1 = class extends CF2Component { 3630 constructor(el, runtimeSel) { 3631 super(el, runtimeSel); 3632 } 3633 mount() { 3634 } 3635 show() { 3636 this.element.classList.remove("elHide"); 3637 } 3638 showWaitingOnQueueText(text) { 3639 this.element.querySelector(".elCheckoutLoadingWaitingOnQueue").classList.remove("elHide"); 3640 this.element.querySelector(".elCheckoutLoadingWaitingOnQueue").innerHTML = text; 3641 } 3642 hideWaitingOnQueueText() { 3643 this.element.querySelector(".elCheckoutLoadingWaitingOnQueue").classList.add("elHide"); 3644 } 3645 hide() { 3646 this.element.classList.add("elHide"); 3647 } 3648}; 3649registerComponent("CheckoutLoading/V1", CheckoutLoadingV1); 3650window["CheckoutLoadingV1"] = CheckoutLoadingV1; 3651
3652// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-submit-notification-v1.ts 3653init_define_process(); 3654init_runtime(); 3655var CheckoutSubmitNotificationV1 = class extends CF2Component { 3656 constructor(el, runtimeSel) { 3657 super(el, runtimeSel); 3658 } 3659 mount() { 3660 } 3661 setStatus(text, subtext, extratext = "") { 3662 if (text) { 3663 this.element.querySelector(".mainText").classList.remove("elHide"); 3664 this.element.querySelector(".mainText").textContent = text; 3665 } else { 3666 this.element.querySelector(".mainText").classList.add("elHide"); 3667 } 3668 if (subtext) { 3669 this.element.querySelector(".subText").classList.remove("elHide"); 3670 this.element.querySelector(".subText").textContent = subtext; 3671 } else { 3672 this.element.querySelector(".subText").classList.add("elHide"); 3673 } 3674 if (extratext) { 3675 this.element.querySelector(".extraText").classList.remove("elHide"); 3676 this.element.querySelector(".extraText").textContent = extratext; 3677 } else { 3678 this.element.querySelector(".extraText").classList.add("elHide"); 3679 } 3680 } 3681}; 3682registerComponent("CheckoutSubmitNotification/V1", CheckoutSubmitNotificationV1); 3683window["CheckoutSubmitNotificationV1"] = CheckoutSubmitNotificationV1; 3684
3685// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-apple-pay-button-v1.ts 3686init_define_process(); 3687
3688// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-submit.ts 3689init_define_process(); 3690
3691// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Utils/checkout-path.ts 3692init_define_process(); 3693var renderedPath = () => { 3694 const renderedPage = document.querySelector('meta[name="rendered-page-url"]')?.getAttribute("content"); 3695 return renderedPage ?? window.location.pathname; 3696}; 3697var renderedHref = (extraPath) => { 3698 const url = new URL(window.location.href); 3699 url.pathname = renderedPath() + (extraPath ?? ""); 3700 return url.toString(); 3701}; 3702
3703// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Utils/checkout-address.ts 3704init_define_process(); 3705init_general(); 3706var STATES_WITH_POSTAL_CODE = /* @__PURE__ */ new Set(["US", "GB", "CA", "FI", "FR", "IT", "ES"]); 3707var backfillAddressId = (address) => { 3708 if (address.id) return address; 3709 let addressId = "no-id#"; 3710 addressId += [address.country, address.state, address.city, address.zip, address.address, address.address_2].filter(Boolean).join(":"); 3711 return { ...address, id: addressId }; 3712}; 3713var backfillAddressesId = (addresses) => { 3714 return addresses.map((address) => backfillAddressId(address)); 3715}; 3716var isSavedAddress = (address) => { 3717 return address.id && !String(address.id).includes("no-id#"); 3718}; 3719var fieldsForCountry = (fields, country) => { 3720 const fieldsLength = Object.keys(fields).length; 3721 if (fieldsLength > 0 && fieldsLength <= 2) { 3722 const hasPostalCode = STATES_WITH_POSTAL_CODE.has(country); 3723 if (hasPostalCode) { 3724 return ["country", "zip"]; 3725 } else { 3726 return ["country"]; 3727 } 3728 } 3729 return fields; 3730}; 3731var addressToString = (address) => { 3732 let str = ""; 3733 if (address.address) { 3734 str = address.address; 3735 if (address.address2) { 3736 str += `, ${address.address2}`; 3737 } 3738 if (address.city) { 3739 str += `. ${address.city}`; 3740 } 3741 if (address.state) { 3742 str += `, ${address.state}`; 3743 } 3744 if (address.zip) { 3745 str += ` ${address.zip}`; 3746 } 3747 if (address.country) { 3748 str += `, ${address.country}`; 3749 } 3750 } else { 3751 if (address.zip) { 3752 str += `${address.zip}, `; 3753 } 3754 if (address.country) { 3755 str += `${address.country}`; 3756 } 3757 } 3758 return str; 3759}; 3760var parseAddressByFields = (address, fields, shouldBackfill = true) => { 3761 const addressByFields = fields.reduce((acc, field) => { 3762 acc[field] = address[field] ?? (shouldBackfill ? globalThis.Checkout.contactLocale[field] : null); 3763 return acc; 3764 }, {}); 3765 return cleanEmptyObjectKeys({ ...addressByFields, id: address.id }); 3766}; 3767
3768// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-submit.ts 3769init_general(); 3770init_nonce(); 3771init_cf_utils(); 3772
3773// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-error-classification.ts 3774init_define_process(); 3775function isServerCheckoutErrorEnvelope(payload) { 3776 return typeof payload?.error === "string" || payload?.error_details != null; 3777} 3778function normalizeServerCheckoutError(body) { 3779 const payload = body ?? {}; 3780 const raw = payload.error_details; 3781 const details = Array.isArray(raw) ? raw : raw ? [{ source: "payment_gateway", ...raw }] : []; 3782 return { 3783 code: details[0]?.code, 3784 // `?? message` makes this a fixpoint: normalising an already-normalised object must not lose 3785 // the text, or a second defensive pass would strip the decline that mounts the card field. 3786 message: payload.error ?? payload.message, 3787 error_details: isServerCheckoutErrorEnvelope(payload) ? details : void 0 3788 }; 3789} 3790function serverCheckoutErrorMessage(body) { 3791 if (!body || typeof body !== "object") return null; 3792 const payload = body; 3793 if (!isServerCheckoutErrorEnvelope(payload)) return null; 3794 const details = normalizeServerCheckoutError(payload).error_details ?? []; 3795 if (details.length) { 3796 const joined = details.map((detail) => detail?.graceful_message ?? detail?.message).filter(Boolean).join(" "); 3797 if (joined) return joined; 3798 } 3799 return payload.error || payload.message || null; 3800} 3801function isActionableCheckoutError(body) { 3802 const payload = body; 3803 const details = normalizeServerCheckoutError(payload).error_details ?? []; 3804 if (details.some((detail) => detail?.source === "payment_gateway")) { 3805 return true; 3806 } 3807 return !isServerCheckoutErrorEnvelope(payload); 3808} 3809
3810// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-store.ts 3811init_define_process(); 3812
3813// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-critical-errors.ts 3814init_define_process(); 3815init_error_with_cause(); 3816init_fetcher(); 3817var CheckoutCriticalError = class extends CFErrorWithCause { 3818 constructor(message, options) { 3819 super(message, options); 3820 __publicField(this, "name"); 3821 __publicField(this, "context"); 3822 this.name = "CheckoutCriticalError"; 3823 } 3824}; 3825var ERROR_CODES = { 3826 EMPTY_PRODUCTS_ERROR: "EMPTY_PRODUCTS_ERROR", 3827 EMPTY_PAYMENT_METHODS_ERROR: "EMPTY_PAYMENT_METHODS_ERROR", 3828 UNEXPECTED_INITIALIZATION_ERROR: "UNEXPECTED_INITIALIZATION_ERROR", 3829 FETCH_FEATURE_FLAGS_ERROR: "FETCH_FEATURE_FLAGS_ERROR", 3830 FETCH_COUNTRIES_STATES_ERROR: "FETCH_COUNTRIES_STATES_ERROR", 3831 FETCH_STRIPE_ADDRESS_FIELD_COUNTRIES_ERROR: "FETCH_STRIPE_ADDRESS_FIELD_COUNTRIES_ERROR", 3832 PAI_INITIALIZATION_SCRIPT_ERROR: "PAI_INITIALIZATION_SCRIPT_ERROR", 3833 PAI_INITIALIZATION_TIMEOUT_ERROR: "PAI_INITIALIZATION_TIMEOUT_ERROR", 3834 PAI_INITIALIZATION_READY_TIMEOUT_ERROR: "PAI_INITIALIZATION_READY_TIMEOUT_ERROR", 3835 PAI_INITIALIZATION_CONFIG_ERROR: "PAI_INITIALIZATION_CONFIG_ERROR", 3836 READY_TO_PAY_UPDATE_ERROR: "READY_TO_PAY_UPDATE_ERROR", 3837 FETCH_EXISTING_ORDERS_ERROR: "FETCH_EXISTING_ORDERS_ERROR", 3838 FETCH_PHONE_UTILS_ERROR: "FETCH_PHONE_UTILS_ERROR", 3839 ORDER_RECURRING_INTERVAL_MISMATCH: "ORDER_RECURRING_INTERVAL_MISMATCH", 3840 ERROR_PROCESSING_STRIPE_PAYMENT: "ERROR_PROCESSING_STRIPE_PAYMENT", 3841 ERROR_STRIPE_3DS_DECLINED: "ERROR_STRIPE_3DS_DECLINED", 3842 ERROR_STRIPE_CARD_DECLINED: "ERROR_STRIPE_CARD_DECLINED", 3843 MULTIPLE_CHECKOUT_PRESENT: "MULTIPLE_CHECKOUT_PRESENT" 3844}; 3845var displayAndLogCriticalError = (checkoutCriticalError, extraContext) => { 3846 const criticalErrors = globalThis.Checkout.store.criticalErrors.get(); 3847 const originalError = checkoutCriticalError.cause; 3848 if (originalError instanceof CFFetcherError) { 3849 const fetchError = originalError; 3850 globalThis.Checkout.store.criticalErrors.set([ 3851 ...criticalErrors, 3852 { code: checkoutCriticalError.message, fetchErrorType: fetchError.type } 3853 ]); 3854 } else { 3855 globalThis.Checkout.store.criticalErrors.set([...criticalErrors, { code: checkoutCriticalError.message }]); 3856 } 3857 console.error(CFstackWithCauses(checkoutCriticalError)); 3858 const context = { ...checkoutCriticalError.context ?? {}, ...extraContext ?? {} }; 3859 if (Object.keys(context).length > 0) { 3860 globalThis.Honeybadger?.notify(checkoutCriticalError, { context }); 3861 } else { 3862 globalThis.Honeybadger?.notify(checkoutCriticalError); 3863 } 3864}; 3865
3866// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-store.ts 3867init_nanostores(); 3868
3869// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-payment-types.ts 3870init_define_process(); 3871var STORE_PAYMENT_TYPES = ["payment-card", "paypal", "apple-pay", "Klarna"]; 3872var SPLITIT = "splitit"; 3873var toStoreType = (type) => type === SPLITIT ? "payment-card" : type; 3874var hasStoreBucket = (type) => STORE_PAYMENT_TYPES.includes(type); 3875var resolveInitialPaymentType = (savedPaymentType, enabledPayments) => { 3876 const collectable = (enabledPayments ?? []).map(toStoreType).filter(hasStoreBucket); 3877 const saved = toStoreType(savedPaymentType); 3878 if (collectable.length) return collectable.find((type) => type === saved) ?? collectable[0]; 3879 return hasStoreBucket(saved) ? saved : "payment-card"; 3880}; 3881
3882// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/RebillyCheckout/checkout-globals.ts 3883init_define_process(); 3884
3885// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-data-loader.ts 3886init_define_process(); 3887init_general(); 3888var getSSRGlobalResourceData = () => { 3889 const productSelectType = globalThis.globalResourceData.product_quantity_type ?? "single"; 3890 const { checkout_v2_state, contact } = globalThis?.sessionData ?? {}; 3891 const initialContactData = checkout_v2_state === "guest" ? {} : cleanEmptyObjectKeys({ 3892 first_name: contact?.first_name ?? "", 3893 last_name: contact?.last_name ?? "", 3894 email: contact?.email ?? "", 3895 phone_number: contact?.phone_number ?? "" 3896 }); 3897 const { products, productsById, variantsById, pricesById } = globalThis.globalResourceData; 3898 const savedPaymentMethods = contact?.payment_methods ?? []; 3899 return { 3900 productSelectType, 3901 products, 3902 productsById, 3903 variantsById, 3904 pricesById, 3905 savedPaymentMethods, 3906 initialContactData 3907 }; 3908}; 3909
3910// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-states.ts 3911init_define_process(); 3912var PaypalStates = { 3913 IDLE: "idle", 3914 INITIALIZED: "initialized", 3915 ERROR: "error", 3916 ADDING_PAYMENT_METHOD: "adding-payment-method", 3917 PAYMENT_METHOD_APPROVED: "payment-method-approved" 3918}; 3919var ErrorTypes = { 3920 REBILLY_ERROR: "rebilly-error", 3921 SERVER_ERROR: "server-error", 3922 UNHANDLED_SERVER_RESPONSE: "unhandled-server-response", 3923 THREEDS_DECLINED_ERROR: "3ds-declined-error", 3924 THREEDS_DECLINED_CUSTOM_ERROR: "3ds-declined-custom-error", 3925 PAYPAL_DECLINED_ERROR: "paypal-declined-error", 3926 PAYPAL_CUSTOM_ERROR: "paypal-custom-error" 3927}; 3928
3929// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/StripeCheckout/utils.ts 3930init_define_process(); 3931function hasRecurringPrice(cart) { 3932 return cart.items.some(({ price_id }) => { 3933 const price = globalThis.globalResourceData.pricesById[price_id]; 3934 return price.is_recurring; 3935 }); 3936} 3937function hasPhysicalProductsWithParams(cart) { 3938 return cart.items.some(({ product_id, variant_id }) => { 3939 const product = globalThis.Checkout.productsById[product_id]; 3940 const variant = globalThis.Checkout.variantsById[variant_id]; 3941 let productType = variant?.product_type; 3942 productType = productType || product?.product_type; 3943 return productType == "physical"; 3944 }); 3945} 3946function hasUpgradeDowngradeItems(cart) { 3947 return cart.items.some((item) => item.type === "upgradeDowngrade"); 3948} 3949function getStripeMode(cart, amount) { 3950 if (amount == 0) return "setup"; 3951 return hasRecurringPrice(cart) ? "subscription" : "payment"; 3952} 3953function getCartEstimatedTotal(cart) { 3954 const estimatedAmount = cart.items.reduce((acc, { price_id }) => { 3955 const price = globalThis.globalResourceData.pricesById[price_id]; 3956 return acc + price.initial_price_cents; 3957 }, 0); 3958 return estimatedAmount; 3959} 3960function convertToStripeAddress(address) { 3961 return { 3962 line1: address.address_one, 3963 line2: address.address_two, 3964 city: address.city, 3965 state: address.state, 3966 postal_code: address.postal_code, 3967 country: address.country 3968 }; 3969} 3970function convertAddressFromStripe(address) { 3971 return { 3972 address_one: address.line1, 3973 address_two: address.line2, 3974 city: address.city, 3975 state: address.state, 3976 country: address.country, 3977 postal_code: address.postal_code 3978 }; 3979} 3980function convertAddressFromSession(address) { 3981 return { 3982 address_one: address.address, 3983 address_two: address.address_2, 3984 city: address.city, 3985 state: address.state, 3986 country: address.country, 3987 postal_code: address.zip 3988 }; 3989} 3990function calculateStripeLineItems(lineItems, totalAmountCents, shippingOption, discountAmount) { 3991 if (!lineItems?.length || totalAmountCents == null) return void 0; 3992 const allLineItems = lineItems.map(({ priceCents, description }) => { 3993 return { 3994 name: description, 3995 amount: priceCents 3996 }; 3997 }); 3998 if (shippingOption) { 3999 allLineItems.push({ 4000 name: shippingOption.description, 4001 amount: shippingOption.amount_cents 4002 }); 4003 } 4004 if (discountAmount) { 4005 allLineItems.push({ 4006 name: "Discount", 4007 amount: -discountAmount 4008 }); 4009 } 4010 const remainder = totalAmountCents - allLineItems.reduce((sum, { amount }) => sum + amount, 0); 4011 if (remainder > 0) allLineItems.push({ name: "Taxes", amount: remainder }); 4012 if (remainder < 0) return void 0; 4013 return allLineItems; 4014} 4015var STRIPE_SKIP_SHIPPING_ID = "skip it"; 4016function calculateStripeChangeResolveDetails(lineItems, quotesResponse, shippingOption, totalAmountCents, discountAmount) { 4017 const stripeLineItems = calculateStripeLineItems(lineItems, totalAmountCents, shippingOption, discountAmount); 4018 return { 4019 ...stripeLineItems ? { lineItems: stripeLineItems } : {}, 4020 shippingRates: quotesResponse?.map((option) => { 4021 const { description, amount_cents } = option; 4022 return { 4023 id: JSON.stringify(option), 4024 amount: amount_cents, 4025 displayName: description 4026 }; 4027 }) ?? [ 4028 { 4029 id: STRIPE_SKIP_SHIPPING_ID, 4030 amount: 0, 4031 displayName: "Free" 4032 } 4033 ] 4034 }; 4035} 4036function calculateStripeClickResolveDetails({ 4037 needsAddress, 4038 phoneNumberRequired, 4039 lineItems, 4040 totalAmountCents, 4041 shippingOption, 4042 discountAmountCents 4043}) { 4044 const stripeLineItems = calculateStripeLineItems(lineItems, totalAmountCents, shippingOption, discountAmountCents); 4045 return { 4046 emailRequired: true, 4047 phoneNumberRequired, 4048 shippingAddressRequired: needsAddress, 4049 ...needsAddress ? ( 4050 // Stripe only accepts shipping rates alongside a shipping address, and the real ones are 4051 // not known until the address round trip answers. 4052 { shippingRates: [{ id: "calculating", amount: 0, displayName: "Calculating..." }] } 4053 ) : ( 4054 // A field on the wallet sheet rather than a step of its own. Without the address round 4055 // trip it is the only address the order will get. 4056 { billingAddressRequired: true } 4057 ), 4058 ...stripeLineItems ? { lineItems: stripeLineItems } : {} 4059 }; 4060} 4061function parseCssVars(element, obj) { 4062 Object.keys(obj ?? {}
4062).forEach((key) => { 4063 const value = obj[key]; 4064 if (typeof value === "object") { 4065 obj[key] = parseCssVars(element, value); 4066 } else { 4067 if (typeof value === "string" && value.includes("--")) { 4068 obj[key] = getComputedStyle(element).getPropertyValue(value); 4069 } 4070 } 4071 }); 4072 return obj; 4073} 4074
4075// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/RebillyCheckout/checkout-globals.ts 4076var CheckoutStates = { 4077 OTO: "oto", 4078 GUEST: "guest", 4079 SAVED: "saved", 4080 UPGRADE_DOWNGRADE: "upgradeDowngrade", 4081 REACTIVATE: "reactivate" 4082}; 4083var StoreStates = { 4084 START: "start", 4085 INITIALIZING: "initializing", 4086 INITIALIZED: "initialized", 4087 FILLING_FORM: "filling-form", 4088 SUBMITTING: "submitting", 4089 SUBMITTED: "submitted" 4090}; 4091var SummaryStates = { 4092 WAITING: "waiting", 4093 CALCULATING: "calculating", 4094 ERROR: "error", 4095 OK: "ok" 4096}; 4097var CouponStates = { 4098 READY: "ready", 4099 APPLYING: "applying", 4100 APPLIED: "applied", 4101 ERROR: "error" 4102}; 4103var PaymentStates = { 4104 START: "start", 4105 INITIALIZING: "initializing", 4106 LOADING: "loading", 4107 INITIALIZED: "initialized" 4108}; 4109var SubmittingStates = { 4110 IDLE: "idle", 4111 START: "start", 4112 WAITING_ON_QUEUE: "waiting-on-queue", 4113 ERROR: "error", 4114 DONE: "done" 4115}; 4116var states = { 4117 StoreStates, 4118 SummaryStates, 4119 PaymentStates, 4120 SubmittingStates, 4121 PaypalStates, 4122 CouponStates, 4123 ErrorTypes, 4124 CheckoutStates 4125}; 4126var globals = getSSRGlobalResourceData(); 4127var ssrDynamicData = globalThis.getSSRDynamicStoreData(globals.products); 4128globalThis.Checkout = { 4129 ...states, 4130 ...globals, 4131 ssrDynamicData, 4132 utils: buildUtils() 4133}; 4134window.addEventListener( 4135 "keydown", 4136 function(e) { 4137 if (e.key == "Enter") { 4138 if (globalThis.Checkout.store?.payment.type.get() == "apple-pay") { 4139 e.preventDefault(); 4140 return false; 4141 } 4142 } 4143 }, 4144 true 4145); 4146var cleanupEmptyErrors = (errors) => { 4147 if (errors.globalErrors.length == 0) delete errors.globalErrors; 4148 if (Object.keys(errors.fields).length == 0) delete errors.fields; 4149 if (Object.keys(errors).length == 0) return null; 4150 return errors; 4151}; 4152function hasErrors(errors) { 4153 return (errors?.globalErrors ?? []).length != 0 || Object.keys(errors?.fields ?? {}).length != 0; 4154} 4155function productErrors(cart, showAllErrors) { 4156 const errors = { 4157 globalErrors: [], 4158 fields: {} 4159 }; 4160 if (showAllErrors) { 4161 const hasProducts = cart.items.filter((p) => !globalThis.Checkout.productsById[p.product_id].bump).some((item) => item.quantity > 0); 4162 if (!hasProducts) { 4163 errors.globalErrors.push({ message: "At least one product should be selected" }); 4164 } 4165 } 4166 return cleanupEmptyErrors(errors); 4167} 4168function shippingOptionErrors(loadingShipping, cart, shippingOptions, shippingOption, showAllErrors, paymentType) { 4169 const errors = { 4170 globalErrors: [], 4171 fields: {} 4172 }; 4173 if (!showAllErrors || loadingShipping || !hasPhysicalProductsWithParams(cart) || paymentType == "apple-pay") { 4174 return null; 4175 } 4176 const shippingOptionIsValid = shippingOption && shippingOptions?.length > 0; 4177 if (!shippingOptionIsValid) { 4178 const error = { message: "Shipping is not available for this location" }; 4179 errors.fields.shippingOption = error; 4180 errors.globalErrors.push(error); 4181 } 4182 return cleanupEmptyErrors(errors); 4183} 4184function tosErrors(accepted, present, showTosErrors) { 4185 if (present && showTosErrors && !accepted) { 4186 return { globalErrors: [{ message: "You must accept the terms of service" }] }; 4187 } else { 4188 return {}; 4189 } 4190} 4191function summaryErrors(summary) { 4192 const errors = { 4193 globalErrors: [], 4194 fields: {} 4195 }; 4196 if (summary.state == SummaryStates.ERROR) { 4197 if (summary.error) { 4198 errors.globalErrors.push({ message: summary.error.message }); 4199 } else { 4200 errors.globalErrors.push({ message: "There was an error calculating your order total" }); 4201 } 4202 } 4203 return cleanupEmptyErrors(errors); 4204} 4205function addressErrors(address, showAllErrors, fields) { 4206 const errors = { 4207 globalErrors: [], 4208 fields: {} 4209 }; 4210 fields.forEach((field) => { 4211 const value = address[field]; 4212 if (value == void 0 && !showAllErrors) return; 4213 const { valid, message } = validateValue(field, value); 4214 if (!valid) { 4215 errors.fields[field] = { message }; 4216 } 4217 }); 4218 return cleanupEmptyErrors(errors); 4219} 4220function contactErrors(contact, fields, showAllErrors) { 4221 showAllErrors = showAllErrors ?? true; 4222 const errors = { 4223 globalErrors: [], 4224 fields: {} 4225 }; 4226 fields.forEach((field) => { 4227 const value = contact[field]; 4228 if (value == void 0 && !showAllErrors) return; 4229 const { valid, message } = validateValue(field, value); 4230 if (!valid) { 4231 errors.fields[field] = { message }; 4232 } 4233 }); 4234 return cleanupEmptyErrors(errors); 4235} 4236function buildUtils() { 4237 const billingErrors = (billing, billingSameAsShipping, showAllErrors, cart, mode, billingFields, billingApiErrorsByField, paymentType, paymentId) => { 4238 if (hasPhysicalProductsWithParams(cart) && billingSameAsShipping || mode == CheckoutStates.UPGRADE_DOWNGRADE || mode == CheckoutStates.OTO && !paymentId || paymentType == "apple-pay") { 4239 return null; 4240 } else if (billingApiErrorsByField) { 4241 return { 4242 fields: billingApiErrorsByField 4243 }; 4244 } else if (mode == globalThis.Checkout.CheckoutStates.REACTIVATE || mode == globalThis.Checkout.CheckoutStates.SAVED) { 4245 const savedBillingAddresses = globalThis.Checkout.store.billing_addresses.get(); 4246 const isActiveAddressSaved = savedBillingAddresses.find((addr) => addr.id == billing.id); 4247 if (!isActiveAddressSaved) { 4248 return addressErrors(billing, showAllErrors, billingFields); 4249 } 4250 return null; 4251 } else if (mode == CheckoutStates.OTO && paymentId) { 4252 return null; 4253 } else { 4254 return addressErrors(billing, showAllErrors, billingFields); 4255 } 4256 }; 4257 const shippingErrors = (shipping, showAllErrors, cart, mode, shippingFields, paymentType) => { 4258 if (!hasPhysicalProductsWithParams(cart) || paymentType == "apple-pay") { 4259 return null; 4260 } 4261 return addressErrors(shipping, showAllErrors, shippingFields); 4262 }; 4263 return { 4264 productErrors, 4265 billingErrors, 4266 shippingErrors, 4267 addressErrors, 4268 cleanupEmptyErrors, 4269 hasErrors, 4270 hasPhysicalProductsWithParams, 4271 skipBillingAddress: (store) => { 4272 const isNotDigitalWalletPayment = store.payment.type.get() != "apple-pay"; 4273 return isNotDigitalWalletPayment && store.billingFields.get().length == 0; 4274 }, 4275 hasPhysicalProducts: () => { 4276 const cart = globalThis.Checkout.computed.checkoutCart.get(); 4277 return hasPhysicalProductsWithParams(cart); 4278 }, 4279 hasValidDataForOrderPreview: (options) => { 4280 const mode = globalThis.Checkout.store.checkout.mode.get(); 4281 const cart = globalThis.Checkout.computed.checkoutCart.get(); 4282 const billing = globalThis.Checkout.store.billing.get(); 4283 const shipping = globalThis.Checkout.store.shipping.get(); 4284 const billingSameAsShipping = globalThis.Checkout.store.billingSameAsShipping.get(); 4285 const billingApiErrorsByField = globalThis.Checkout.store.billingApiErrorsByField.get(); 4286 const paymentType = globalThis.Checkout.store.payment.type.get(); 4287 const paymentId = globalThis.Checkout.store.payment.id.get(); 4288 const showAllBillingErrors = true; 4289 const showAllShippingErrors = true; 4290 const showAllProductErrors = true; 4291 const pErrors = productErrors(cart, showAllProductErrors); 4292 const bErrors = billingErrors( 4293 billing, 4294 billingSameAsShipping, 4295 showAllBillingErrors, 4296 cart, 4297 mode, 4298 options.billingFields, 4299 billingApiErrorsByField, 4300 paymentType, 4301 paymentId 4302 ); 4303 const sErrors = shippingErrors(shipping, showAllShippingErrors, cart, mode, options.shippingFields, paymentType); 4304 return !hasErrors(pErrors) && !hasErrors(bErrors) && !hasErrors(sErrors); 4305 }, 4306 hasValidDataForShippingOptions: (options) => { 4307 const mode = globalThis.Checkout.store.checkout.mode.get(); 4308 const cart = globalThis.Checkout.computed.checkoutCart.get(); 4309 const shipping = globalThis.Checkout.store.shipping.get(); 4310 const paymentType = globalThis.Checkout.store.payment.type.get(); 4311 const showAllShippingErrors = true; 4312 const sErrors = shippingErrors(shipping, showAllShippingErrors, cart, mode, options.shippingFields, paymentType); 4313 return !hasErrors(sErrors); 4314 }, 4315 hasValidDataForTaxes: (options) => { 4316 const mode = globalThis.Checkout.store.checkout.mode.get(); 4317 const cart = globalThis.Checkout.computed.checkoutCart.get(); 4318 const billing = globalThis.Checkout.store.billing.get(); 4319 const billingSameAsShipping = globalThis.Checkout.store.billingSameAsShipping.get(); 4320 const billingApiErrorsByField = globalThis.Checkout.store.billingApiErrorsByField.get(); 4321 const paymentType = globalThis.Checkout.store.payment.type.get(); 4322 const paymentId = globalThis.Checkout.store.payment.id.get(); 4323 const showAllBillingErrors = true; 4324 const bErrors = billingErrors( 4325 billing, 4326 billingSameAsShipping, 4327 showAllBillingErrors, 4328 cart, 4329 mode, 4330 options.billingFields, 4331 billingApiErrorsByField, 4332 paymentType, 4333 paymentId 4334 ); 4335 return !hasErrors(bErrors); 4336 }, 4337 canSubmit: () => { 4338 const state = globalThis.Checkout.store.state.get(); 4339 const summary = globalThis.Checkout.store.summary.get(); 4340 return state == globalThis.Checkout.StoreStates.FILLING_FORM && summary.state == globalThis.Checkout.SummaryStates.OK; 4341 } 4342 }; 4343} 4344
4345// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-store.ts 4346var encodeVirtualInstallmentId = (duration, type) => { 4347 return `${duration}-${type}`; 4348}; 4349var decodeVirtualInstallmentId = (virtualId) => { 4350 if (!virtualId) return null; 4351 const parts = virtualId.split("-"); 4352 if (parts.length !== 2) return null; 4353 const duration = parseInt(parts[0], 10); 4354 const type = parts[1]; 4355 if (isNaN(duration)) return null; 4356 return { duration, type }; 4357}; 4358var getInitialCriticalErrors = (enabledPayments, enabledExpressPayments) => { 4359 const initialCriticalErrors = []; 4360 if ((enabledPayments ?? []).length == 0 && (enabledExpressPayments ?? []).length == 0) { 4361 initialCriticalErrors.push({ code: ERROR_CODES.EMPTY_PAYMENT_METHODS_ERROR }); 4362 } 4363 if (!globalThis.globalResourceData.productVariantWithNoBump?.id) { 4364 initialCriticalErrors.push({ code: ERROR_CODES.EMPTY_PRODUCTS_ERROR }); 4365 } 4366 return initialCriticalErrors; 4367}; 4368var buildPaymentBucket = (type) => { 4369 switch (type) { 4370 case "payment-card": 4371 return { events: map({}), token: atom(null) }; 4372 case "paypal": 4373 return { state: atom({ state: globalThis.Checkout.PaypalStates.IDLE }), token: atom(null) }; 4374 default: 4375 return { token: atom(null) }; 4376 } 4377}; 4378var buildPaymentBuckets = () => STORE_PAYMENT_TYPES.reduce( 4379 (buckets, type) => ({ ...buckets, [type]: buildPaymentBucket(type) }), 4380 {} 4381); 4382var create = (billingFields, shippingFields, enabledPayments, enabledExpressPayments) => { 4383 const paymentMethods = typeof globalThis.Checkout.savedPaymentMethods === "string" ? JSON.parse(globalThis.Checkout.savedPaymentMethods) : globalThis.Checkout.savedPaymentMethods; 4384 const paymentDataId = paymentMethods?.[0]?.id ?? null; 4385 const initialPaymentMethod = resolveInitialPaymentType(paymentMethods?.[0]?.type, enabledPayments); 4386 const { 4387 mode, 4388 contact, 4389 shipping, 4390 billing, 4391 billingSameAsShipping, 4392 billing_addresses, 4393 shipping_addresses 4394 } = globalThis.Checkout.ssrDynamicData; 4395 return { 4396 state: atom(globalThis.Checkout.StoreStates.START), 4397 checkout: { 4398 mode: atom(mode), 4399 lastModeIndependentOfCartItems: atom(mode), 4400 step: atom(0) 4401 }, 4402 contact: map(contact), 4403 contact_pending_auth: map({ authenticated: false }), 4404 shipping: map(shipping), 4405 shipping_addresses: atom(shipping_addresses ?? []), 4406 loadingShipping: atom(false), 4407 shippingOptions: atom([]), 4408 isUpdatingRebilly: atom(true), 4409 shippingOption: atom(), 4410 billingFields: atom(billingFields), 4411 shippingFields: atom(shippingFields), 4412 payment: { 4413 state: atom(globalThis.Checkout.PaymentStates.START), 4414 id: atom(paymentDataId), 4415 type: atom(initialPaymentMethod), 4416 virtualInstallmentId: atom(null), 4417 ...buildPaymentBuckets() 4418 }, 4419 paymentMethods: atom(paymentMethods ?? []), 4420 billing: map(billing), 4421 billingApiErrorsByField: atom(null), 4422 billing_addresses: atom(billing_addresses ?? []), 4423 billingSameAsShipping: atom(billingSameAsShipping), 4424 coupons: { 4425 appliedCode: atom(""), 4426 currentCode: atom(""), 4427 errorMessage: atom(""), 4428 state: atom(globalThis.Checkout.CouponStates.READY) 4429 }, 4430 summary: atom({ 4431 state: globalThis.Checkout.SummaryStates.WAITING, 4432 data: {} 4433 }), 4434 tos: { 4435 accepted: atom(false), 4436 present: atom(false) 4437 }, 4438 criticalErrors: atom(getInitialCriticalErrors(enabledPayments, enabledExpressPayments)), 4439 showAllErrors: { 4440 contact: atom(false), 4441 shipping: atom(false), 4442 billing: atom(false), 4443 shippingOption: atom(false), 4444 payment: atom(false), 4445 products: atom(false), 4446 tos: atom(false), 4447 summary: atom(false) 4448 }, 4449 submitting: atom({ 4450 state: globalThis.Checkout.SubmittingStates.IDLE 4451 }), 4452 incrScrollToFirstVisibleError: atom(0), 4453 threeds: map({ 4454 show: false, 4455 approvalUrl: null 4456 }), 4457 featureFlags: { 4458 isShippingEnabled: atom(false) 4459 }, 4460 selectedOrderDetailId: atom(null), 4461 phoneNumberInitialized: atom(false) 4462 }; 4463}; 4464var buildComputed = (store, contactFields, shippingFields, totalSteps) => { 4465 const computedModeLeaveEnterEvent = atom({}); 4466 onMount(computedModeLeaveEnterEvent, () => { 4467 let previousMode; 4468 return store.checkout.mode.subscribe((mode) => { 4469 if (previousMode) {
4470 computedModeLeaveEnterEvent.set({ 4471 leave: previousMode, 4472 next: mode 4473 }); 4474 } 4475 computedModeLeaveEnterEvent.set({ 4476 enter: mode, 4477 previous: previousMode 4478 }); 4479 previousMode = mode; 4480 }); 4481 }); 4482 const computedContactErrors = computed( 4483 [store.checkout.mode, store.contact, store.showAllErrors.contact], 4484 (mode, contact, showAllErrors) => { 4485 if (mode != globalThis.Checkout.CheckoutStates.GUEST) return null; 4486 return contactErrors(contact, contactFields, showAllErrors); 4487 } 4488 ); 4489 const computedCheckoutCart = buildProductSelectComputed(); 4490 const computedBillingErrors = computed( 4491 [ 4492 store.billing, 4493 store.billingSameAsShipping, 4494 store.showAllErrors.billing, 4495 computedCheckoutCart, 4496 store.checkout.mode, 4497 store.payment.type, 4498 store.payment.id, 4499 store.billingApiErrorsByField, 4500 store.billingFields 4501 ], 4502 (billing, billingSameAsShipping, showAllErrors, cart, mode, paymentType, paymentId, billingApiErrorsByField, billingFields) => { 4503 return globalThis.Checkout.utils.billingErrors( 4504 billing, 4505 billingSameAsShipping, 4506 showAllErrors, 4507 cart, 4508 mode, 4509 billingFields, 4510 billingApiErrorsByField, 4511 paymentType, 4512 paymentId 4513 ); 4514 } 4515 ); 4516 const computedShippingErrors = computed( 4517 [store.shipping, store.showAllErrors.shipping, computedCheckoutCart, store.checkout.mode, store.payment.type], 4518 (shipping, showAllErrors, cart, mode, paymentType) => { 4519 return globalThis.Checkout.utils.shippingErrors(shipping, showAllErrors, cart, mode, shippingFields, paymentType); 4520 } 4521 ); 4522 const computedHasValidShippingAddress = computed( 4523 [computedCheckoutCart, store.shipping, store.checkout.mode], 4524 (cart, shipping, mode) => { 4525 return !globalThis.Checkout.utils.shippingErrors(shipping, true, cart, mode, shippingFields); 4526 } 4527 ); 4528 const computedProductErrors = computed( 4529 [computedCheckoutCart, store.showAllErrors.products], 4530 (cart, showAllErrors) => { 4531 return globalThis.Checkout.utils.productErrors(cart, showAllErrors); 4532 } 4533 ); 4534 const computedShippingOptionErrors = computed( 4535 [ 4536 store.loadingShipping, 4537 computedCheckoutCart, 4538 store.shippingOptions, 4539 store.shippingOption, 4540 store.showAllErrors.shippingOption, 4541 store.payment.type 4542 ], 4543 (...args) => shippingOptionErrors(...args) 4544 ); 4545 const computedPaymentErrors = computed( 4546 [ 4547 store.payment.id, 4548 store.payment.type, 4549 store.payment["payment-card"].events, 4550 store.payment.paypal.state, 4551 store.payment.paypal.token, 4552 store.showAllErrors.payment, 4553 store.checkout.mode 4554 ], 4555 (id, type, cardEvents, paypalState, paypalToken, showAllErrors, mode) => { 4556 const errors = { 4557 globalErrors: [], 4558 fields: {} 4559 }; 4560 if (!id && mode != globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE) { 4561 if (type == "payment-card") { 4562 let hasEvent = !!Object.keys(cardEvents).length; 4563 if (hasEvent) { 4564 Object.entries(cardEvents).forEach(([field, event]) => { 4565 if (!event) { 4566 event = { source: field }; 4567 } else { 4568 hasEvent = true; 4569 } 4570 const { valid, message } = validateValue("card", event); 4571 if (!valid) { 4572 errors.fields[field] = { message }; 4573 } 4574 }); 4575 } else if (showAllErrors) { 4576 errors.globalErrors.push({ message: "Missing payment information" }); 4577 } 4578 } else if (type == "paypal") { 4579 if (showAllErrors && !(paypalState.state == globalThis.Checkout.PaypalStates.PAYMENT_METHOD_APPROVED && paypalToken)) { 4580 errors.globalErrors.push({ message: "Missing payment information" }); 4581 } 4582 } 4583 } 4584 return cleanupEmptyErrors(errors); 4585 } 4586 ); 4587 const computedTosErrors = computed( 4588 [store.tos.accepted, store.tos.present, store.showAllErrors.tos], 4589 (...args) => tosErrors(...args) 4590 ); 4591 const computedSummaryErrors = computed([store.summary], (summary) => summaryErrors(summary)); 4592 const computedErrorsByName = { 4593 contact: computedContactErrors, 4594 billing: computedBillingErrors, 4595 shipping: computedShippingErrors, 4596 shippingOption: computedShippingOptionErrors, 4597 products: computedProductErrors, 4598 payment: computedPaymentErrors, 4599 tos: computedTosErrors, 4600 summary: computedSummaryErrors 4601 }; 4602 const computedHasPhysicalProducts = computed(computedCheckoutCart, (cart) => { 4603 return globalThis.Checkout.utils.hasPhysicalProductsWithParams(cart); 4604 }); 4605 const computedPossibleOtoWithFreeShipping = computed( 4606 [computedCheckoutCart, store.checkout.mode, store.shippingOptions, store.loadingShipping], 4607 (cart, mode, shippingOptions, loadingShipping) => { 4608 return mode === "oto" && globalThis.Checkout.utils.hasPhysicalProductsWithParams(cart) && // shipping options unknown /
4608not loaded 4609 (!shippingOptions || // pending with no current shipping options 4610 loadingShipping && shippingOptions.length === 0 || // Exactly one shipping option with amount zero 4611 shippingOptions?.length === 1 && parseInt(shippingOptions[0].amount.amount) === 0); 4612 } 4613 ); 4614 const computedHasShippingEnabled = computed( 4615 [computedCheckoutCart, store.featureFlags.isShippingEnabled], 4616 (cart, isShippingEnabled) => { 4617 return globalThis.Checkout.utils.hasPhysicalProductsWithParams(cart) && isShippingEnabled; 4618 } 4619 ); 4620 const computedHideShipping = computed( 4621 [computedHasShippingEnabled, computedPossibleOtoWithFreeShipping], 4622 (isShippingEnabled, possibleOtoWithFreeShipping) => { 4623 return !isShippingEnabled || possibleOtoWithFreeShipping; 4624 } 4625 ); 4626 const computedCurrentPaymentMethod = computed([store.payment.id], (currentPaymentId) => { 4627 return store.paymentMethods.get().find((pm) => pm.id == currentPaymentId); 4628 }); 4629 const computedIsCouponReady = computed([store.state, computedCheckoutCart], (state, cart) => { 4630 const showAllProductErrors = true; 4631 const pErrors = globalThis.Checkout.utils.productErrors(cart, showAllProductErrors); 4632 return state == globalThis.Checkout.StoreStates.FILLING_FORM && !globalThis.Checkout.utils.hasErrors(pErrors); 4633 }); 4634 const computedIsDigitalWalletReadyToStart = computed( 4635 [store.checkout.mode, store.state, store.summary, computedCheckoutCart], 4636 (mode, state, summary, cart) => { 4637 const showAllProductErrors = true; 4638 const pErrors = globalThis.Checkout.utils.productErrors(cart, showAllProductErrors); 4639 return state == globalThis.Checkout.StoreStates.FILLING_FORM && !globalThis.Checkout.utils.hasErrors(pErrors); 4640 } 4641 ); 4642 const computedHideContactInformationForm = computed( 4643 [store.checkout.mode, store.payment.type], 4644 (mode, paymentType) => { 4645 return paymentType == "apple-pay" && mode == "guest" && totalSteps == 1; 4646 } 4647 ); 4648 const computedIsOTORetrialPayment = computed( 4649 [store.checkout.mode, store.payment.id], 4650 (mode, paymentId) => mode == globalThis.Checkout.CheckoutStates.OTO && !paymentId 4651 ); 4652 return { 4653 errorsByName: computedErrorsByName, 4654 modeLeaveEnterEvent: computedModeLeaveEnterEvent, 4655 hasPhysicalProducts: computedHasPhysicalProducts, 4656 hasShippingEnabled: computedHasShippingEnabled, 4657 hideShipping: computedHideShipping, 4658 hasValidShippingAddress: computedHasValidShippingAddress, 4659 isDigitalWalletReadyToStart: computedIsDigitalWalletReadyToStart, 4660 isCouponReady: computedIsCouponReady, 4661 contactErrors: computedContactErrors, 4662 productErrors: computedProductErrors, 4663 billingErrors: computedBillingErrors, 4664 shippingErrors: computedShippingErrors, 4665 shippingOptionErrors: computedShippingOptionErrors, 4666 paymentMethod: computedCurrentPaymentMethod, 4667 paymentErrors: computedPaymentErrors, 4668 tosErrors: computedTosErrors, 4669 summaryErrors: computedSummaryErrors, 4670 hideContactInformationForm: computedHideContactInformationForm, 4671 isOTORetrialPayment: computedIsOTORetrialPayment, 4672 isNewDigitalWalletPayment: computed( 4673 [store.payment.id, store.payment.type], 4674 (id, paymentType) => !id && paymentType == "apple-pay" 4675 ), 4676 checkoutCart: computedCheckoutCart 4677 }; 4678}; 4679var initializeUtilities = (store, computed2) => { 4680 initializeStoreUtilities(store, computed2); 4681 setupCFEnableDevTools(); 4682}; 4683var initializeStoreUtilities = (store, computed2) => { 4684 const proxyCache = /* @__PURE__ */ new WeakMap(); 4685 const storeValueCache = /* @__PURE__ */ new WeakMap(); 4686 const DEBOUNCE_INTERVAL = 50; 4687 const stores = { 4688 store, 4689 computed: computed2 4690 }; 4691 function createDeepNanostoreProxy(target, onChange) { 4692 return new Proxy(target, { 4693 get(target2, property) { 4694 const item = target2[property]; 4695 if (property === "__store") { 4696 return item; 4697 } 4698 if (item && typeof item === "object") { 4699 if (proxyCache.has(item)) return proxyCache.get(item); 4700 if (isStore(item)) { 4701 const __store = item;
4702 const storeValue = { 4703 __store, 4704 __value: peek(__store) 4705 }; 4706 storeValueCache.set(item, storeValue); 4707 __store.listen((value) => { 4708 storeValue.__value = value; 4709 onChange(); 4710 }); 4711 return storeValue; 4712 } else { 4713 const proxy2 = createDeepNanostoreProxy(item, onChange); 4714 proxyCache.set(item, proxy2); 4715 return proxy2; 4716 } 4717 } 4718 return item; 4719 } 4720 }); 4721 } 4722 function peek(store2) { 4723 return store2.value; 4724 } 4725 function isStore(value) { 4726 return value && value.subscribe; 4727 } 4728 let debounceTimeout; 4729 const proxy = createDeepNanostoreProxy(stores, function onChange() { 4730 clearTimeout(debounceTimeout); 4731 debounceTimeout = setTimeout(() => { 4732 window.dispatchEvent(new CustomEvent("checkout:store:change")); 4733 }, DEBOUNCE_INTERVAL); 4734 }); 4735 globalThis.Checkout.utils.getStoreJson = (tab = 0) => { 4736 return JSON.stringify( 4737 proxy, 4738 function replacer(key, value) { 4739 if (["__store"].includes(key)) return; 4740 if (value && Object.prototype.hasOwnProperty.call(value, "__value")) { 4741 return value.__value; 4742 } 4743 return value; 4744 }, 4745 tab 4746 ); 4747 }; 4748}; 4749var setupCFEnableDevTools = () => { 4750 if (localStorage.getItem("cf2:devtools:enabled")) { 4751 trackUpdatesCheckoutUpdates(); 4752 } 4753 globalThis.CFEnableDevTools = () => { 4754 localStorage.setItem("cf2:devtools:enabled", "true"); 4755 trackUpdatesCheckoutUpdates(); 4756 }; 4757 function trackUpdatesCheckoutUpdates() { 4758 document.querySelectorAll('[data-page-element="Checkout/V2"]').forEach((el) => { 4759 el.insertAdjacentHTML("afterend", '<div class="checkout-store-log"><pre></pre></div>'); 4760 document.querySelector(".checkout-store-log").style.cssText = ` 4761 z-index: 10; 4762 top: 0; 4763 background: rgba(100,100,1005,0.1); 4764 height: 100; 4765 display: flex; 4766 flex-direction: column; 4767 justify-content: center;`; 4768 document.querySelector(".checkout-store-log pre").style.cssText = ` 4769 font-size: 12px; 4770 font-weight: bold; 4771 width: fit-content;`; 4772 }); 4773 const checkoutStoreLog = document.querySelector(".checkout-store-log"); 4774 const renderDevToolsState = initReduxDevTools().render; 4775 render(); 4776 window.addEventListener("checkout:store:change", () => { 4777 render(); 4778 if (renderDevToolsState) { 4779 renderDevToolsState(); 4780 } 4781 }); 4782 function initReduxDevTools() { 4783 let store; 4784 const reduxUrl = "https://cdnjs.cloudflare.com/ajax/libs/redux/4.2.1/redux.min.js"; 4785 const scriptEle = document.createElement("script"); 4786 scriptEle.setAttribute("src", reduxUrl); 4787 document.body.appendChild(scriptEle); 4788 scriptEle.addEventListener("load", () => { 4789 store = globalThis.Redux.createStore( 4790 (state, action) => action.state || state, 4791 JSON.parse(globalThis.Checkout.utils.getStoreJson()), 4792 globalThis.__REDUX_DEVTOOLS_EXTENSION__ && globalThis.__REDUX_DEVTOOLS_EXTENSION__() 4793 ); 4794 }); 4795 return { 4796 render() { 4797 if (store) { 4798 store.dispatch({ 4799 type: "state", 4800 state: JSON.parse(globalThis.Checkout.utils.getStoreJson()) 4801 }); 4802 } 4803 } 4804 }; 4805 } 4806 function render() { 4807 let json; 4808 let error; 4809 try { 4810 const data = JSON.parse(globalThis.Checkout.utils.getStoreJson(4)); 4811 json = JSON.stringify(data, null, 2); 4812 } catch (err) { 4813 error = err; 4814 console.log(error); 4815 } 4816 checkoutStoreLog.querySelector("pre").innerHTML = error ? error.message : ["--- State ---", json].join("\n"); 4817 } 4818 } 4819}; 4820
4821// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-submit.ts 4822var REBILLY_PAYMENT_METHOD_BY_TYPE_MAP = { 4823 Klarna: "klarna-payments" 4824}; 4825var _redirecTo, _threedsListenerEnabled, _formSubmitPayload, _CheckoutSubmit_static, leadSourceGenerator_fn, submitRebilly_fn, buildPaymentMethodDetails_fn, buildRegistrationDetails_fn, shouldIncludeRegistration_fn, buildAddressParams_fn, submitOrderAsync_fn, handleFormSubmitRedirect_fn, add3dsListener_fn; 4826var CheckoutSubmit = class { 4827 static submitFromButtonClick(submitButton, onValidationError, redirectOverride) { 4828 __privateMethod(this, _CheckoutSubmit_static, add3dsListener_fn).call(this); 4829 const checkoutElement = submitButton.closest(".elCheckout"); 4830 if (this.checkSubmitShowErrors({ skipFields: /* @__PURE__ */ new Set(["payment"]) }) && this.checkSubmitShowErrors({ onlyFields: /* @__PURE__ */ new Set(["payment"]) }) && globalThis.Checkout.utils.canSubmit() && checkValidCustomFields(checkoutElement)) { 4831 globalThis.Checkout.store.state.set(globalThis.Checkout.StoreStates.SUBMITTING); 4832 globalThis.Checkout.store.submitting.set({ 4833 state: globalThis.Checkout.SubmittingStates.START 4834 }); 4835 const isUpgradeDowngrade = globalThis.Checkout.store.checkout.mode.get() == globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE; 4836 const capturedPaymentMethodId = globalThis.Checkout.store.payment.id.get(); 4837 const canSkipSubmitRebilly = isUpgradeDowngrade || capturedPaymentMethodId; 4838 if (canSkipSubmitRebilly) { 4839 const payload = this.buildPayloadFromStore({ 4840 contact: globalThis.Checkout.store.contact.get(), 4841 turnstileToken: globalThis.Checkout.turnstileToken, 4842 shippingAddress: globalThis.Checkout.store.shipping.get(), 4843 billingAddress: globalThis.Checkout.store.billing.get(), 4844 paymentMethodDetails: __privateMethod(this, _CheckoutSubmit_static, buildPaymentMethodDetails_fn).call(this) ?? {}, 4845 selectedShippingOption: globalThis.Checkout.store.shippingOption.get(), 4846 skipBillingAddress: globalThis.Checkout.utils.skipBillingAddress(globalThis.Checkout.store), 4847 redirectOverride 4848 }); 4849 return this.submit(payload); 4850 } else { 4851 const paymentType = globalThis.Checkout.store.payment.type.get(); 4852 if (["Klarna", "payment-card"].includes(paymentType)) { 4853 return __privateMethod(this, _CheckoutSubmit_static, submitRebilly_fn).call(this, onValidationError).then((tokenData) => { 4854 if (!tokenData && paymentType === "Klarna") { 4855 if (globalThis.Checkout.store.state.get() === globalThis.Checkout.StoreStates.SUBMITTING) { 4856 globalThis.Checkout.store.state.set(globalThis.Checkout.StoreStates.FILLING_FORM); 4857 globalThis.Checkout.store.submitting.set({ 4858 state: globalThis.Checkout.SubmittingStates.IDLE 4859 }); 4860 } 4861 return; 4862 } 4863 globalThis.Checkout.store.payment[paymentType].token.set(tokenData.id); 4864 const payload = this.buildPayloadFromStore({ 4865 contact: globalThis.Checkout.store.contact.get(), 4866 turnstileToken: globalThis.Checkout.turnstileToken, 4867 shippingAddress: globalThis.Checkout.store.shipping.get(), 4868 billingAddress: globalThis.Checkout.store.billing.get(), 4869 paymentMethodDetails: __privateMethod(this, _CheckoutSubmit_static, buildPaymentMethodDetails_fn).call(this) ?? {}, 4870 selectedShippingOption: globalThis.Checkout.store.shippingOption.get(), 4871 skipBillingAddress: globalThis.Checkout.utils.skipBillingAddress(globalThis.Checkout.store), 4872 redirectOverride 4873 }); 4874 return this.submit(payload); 4875 }); 4876 } else { 4877 const payload = this.buildPayloadFromStore({ 4878 contact: globalThis.Checkout.store.contact.get(), 4879 turnstileToken: globalThis.Checkout.turnstileToken, 4880 shippingAddress: globalThis.Checkout.store.shipping.get(), 4881 billingAddress: globalThis.Checkout.store.billing.get(), 4882 paymentMethodDetails: __privateMethod(this, _CheckoutSubmit_static, buildPaymentMethodDetails_fn).call(this) ?? {}, 4883 selectedShippingOption: globalThis.Checkout.store.shippingOption.get(), 4884 skipBillingAddress: globalThis.Checkout.utils.skipBillingAddress(globalThis.Checkout.store), 4885 redirectOverride 4886 }); 4887 return this.submit(payload); 4888 } 4889 } 4890 } else { 4891 onValidationError(); 4892 } 4893 } 4894 static checkSubmitShowErrors(options) { 4895 const { onlyFields, skipFields } = options ?? {}; 4896 return Object.entries(globalThis.Checkout.computed.errorsByName).map(([name, computed2]) => { 4897 if (onlyFields && !onlyFields.has(name)) return true; 4898 if (skipFields && skipFields.has(name)) return true; 4899 globalThis.Checkout.store.showAllErrors[name].set(true); 4900 return !globalThis.Checkout.utils.hasErrors(computed2.get()); 4901 }).every((v) => !!v); 4902 } 4903 static buildPayloadFromStore(payload) { 4904 const addressParams = __privateMethod(this, _CheckoutSubmit_static, buildAddressParams_fn).call(this, { 4905 billingAddress: payload.billingAddress, 4906 shippingAddress: payload.shippingAddress 4907 }, {
4908 skipBillingAddress: payload.skipBillingAddress 4909 }) ?? {}; 4910 const paymentDetails = payload.paymentMethodDetails; 4911 const purchaseCartDetails = this.buildPurchaseCartDetails(); 4912 const customFields = buildCustomFields(); 4913 const contact = payload.contact; 4914 const couponCode = globalThis.Checkout.store.coupons.appliedCode.get(); 4915 const couponData = couponCode ? { coupon_codes: [couponCode] } : {}; 4916 const virtualInstallmentId = globalThis.Checkout.store.payment.virtualInstallmentId.get(); 4917 const installmentData = decodeVirtualInstallmentId(virtualInstallmentId); 4918 const rebillyPayload = { 4919 // NOTE: Temp fix for FHL 2023 4920 ...customFields ? customFields : {}, 4921 contact: { 4922 ...contact, 4923 ...addressParams.shipping ?? {} 4924 }, 4925 turnstileToken: payload.turnstileToken, 4926 ...addressParams.billing ?? {}, 4927 purchase: { 4928 ...couponData, 4929 ...purchaseCartDetails, 4930 ...paymentDetails, 4931 process_new_order: true, 4932 ...paymentDetails?.payment_method_type === "payment-card" && installmentData ? { 4933 installment_duration: installmentData.duration, 4934 installment_type: installmentData.type 4935 } : {} 4936 }, 4937 skip_billing_address: Boolean(payload.skipBillingAddress), 4938 skip_optin_track: document.getElementById("cfAR")?.getAttribute("data-leads-collected") === "true" 4939 }; 4940 if (__privateMethod(this, _CheckoutSubmit_static, shouldIncludeRegistration_fn).call(this)) rebillyPayload["registration"] = __privateMethod(this, _CheckoutSubmit_static, buildRegistrationDetails_fn).call(this); 4941 const selected_shipping_option = payload.selectedShippingOption; 4942 if (selected_shipping_option && Object.keys(selected_shipping_option).length > 1) { 4943 rebillyPayload.purchase.selected_shipping_option = selected_shipping_option; 4944 } 4945 const redirectUrl = payload.redirectOverride || __privateGet(this, _redirecTo); 4946 if (redirectUrl) { 4947 rebillyPayload.redirect_to = redirectUrl; 4948 } 4949 return rebillyPayload; 4950 } 4951 static generateShippingOptionId(shippingOption) { 4952 return [shippingOption.description, shippingOption.amount_formatted].join("$"); 4953 } 4954 static buildDigitalWalletTransactionData(summaryData, cart, shippingEnabled, shippingOptions) { 4955 const { line_items } = summaryData; 4956 const lineItems = line_items.map(({ price, description }, index) => { 4957 let label; 4958 if (line_items.length == cart.items.length) { 4959 const variantId = cart.items[index].variant_id; 4960 const variant = globalThis.Checkout.variantsById[variantId]; 4961 label = variant.name; 4962 } else { 4963 label = description; 4964 } 4965 return { 4966 label, 4967 amount: price 4968 }; 4969 }); 4970 if (summaryData.tax?.amount > 0) { 4971 lineItems.push({ 4972 label: "Taxes", 4973 amount: summaryData.tax.amount 4974 }); 4975 } 4976 if (summaryData.shipping?.amount > 0) { 4977 lineItems.push({ 4978 label: "Shipping", 4979 amount: summaryData.shipping.amount 4980 }); 4981 } 4982 if (summaryData.discount?.amount > 0) { 4983 lineItems.push({ 4984 label: "Discount", 4985 amount: -summaryData.discount?.amount 4986 }); 4987 } 4988 return { 4989 amount: summaryData.total.amount, 4990 lineItems, 4991 ...shippingEnabled ? { 4992 status: shippingOptions.length ? "success" : "fail", 4993 shippingOptions: shippingOptions.map((shippingOption) => ({ 4994 id: this.generateShippingOptionId(shippingOption), 4995 label: shippingOption.description, 4996 description: "", 4997 amount: Number(shippingOption.amount.amount) 4998 })) 4999 } : {} 5000 }; 5001 } 5002 static buildPurchaseCartDetails() { 5003 const checkoutCart = globalThis.Checkout.computed.checkoutCart.get(); 5004 const lineItems = checkoutCart.items.map( 5005 ({ variant_id, price_id, line_item_id, quantity }) => { 5006 return { 5007 id: variant_id, 5008 quantity, 5009 price_id, 5010 ...line_item_id ? { line_item_id } : {} 5011 }; 5012 } 5013 ); 5014 return { order_id: checkoutCart.order_id, product_variants: lineItems }; 5015 } 5016 static submit(payload) { 5017 if (localStorage.getItem("cf2:devtools:enabled")) { 5018 console.log("submitted data", payload); 5019 } 5020 const requestIdempotency = uuidv4();
5021 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED, payload); 5022 let timer = null; 5023 __privateMethod(this, _CheckoutSubmit_static, submitOrderAsync_fn).call(this, payload, requestIdempotency, 3, () => { 5024 clearInterval(timer); 5025 globalThis.Checkout.store.submitting.set({ 5026 state: globalThis.Checkout.SubmittingStates.START 5027 }); 5028 }, (sleepTime) => { 5029 let remainingSeconds = sleepTime / 1e3; 5030 clearInterval(timer); 5031 timer = setInterval(() => { 5032 remainingSeconds -= 1; 5033 globalThis.Checkout.store.submitting.set({ 5034 state: globalThis.Checkout.SubmittingStates.WAITING_ON_QUEUE, 5035 remainingSeconds 5036 }); 5037 }, 1e3); 5038 }).then((response) => { 5039 if (response.status == 422) { 5040 response.json().then((responseJSON) => { 5041 const errorDetails = responseJSON.error_details; 5042 let errorDetailsMessage = responseJSON.error; 5043 if (responseJSON.error_details && !!errorDetails?.length) { 5044 errorDetailsMessage = errorDetails.map((e) => e.graceful_message ?? e.message).join("\n"); 5045 const mode = globalThis.Checkout.store.checkout.mode.get(); 5046 const isRetrieablePayment = mode == globalThis.Checkout.CheckoutStates.OTO && errorDetails.find((e) => e.source == "payment_gateway"); 5047 if (isRetrieablePayment) { 5048 globalThis.Checkout.store.showAllErrors.payment.set(false); 5049 globalThis.Checkout.store.payment.id.set(null); 5050 } 5051 } 5052 globalThis.Checkout.store.submitting.set({ 5053 state: globalThis.Checkout.SubmittingStates.ERROR, 5054 code: globalThis.Checkout.ErrorTypes.SERVER_ERROR_WITH_MESSAGE, 5055 message: errorDetailsMessage, 5056 actionable: isActionableCheckoutError(responseJSON) 5057 }); 5058 }); 5059 } else if (response.ok) { 5060 __privateSet(this, _formSubmitPayload, payload); 5061 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED_OK, payload); 5062 if (response.headers.get("X-CF2-APPROVAL-URL")) { 5063 globalThis.Checkout.store.threeds.set({ 5064 show: true, 5065 approvalUrl: response.headers.get("X-CF2-APPROVAL-URL") 5066 }); 5067 } else { 5068 globalThis.Checkout.store.submitting.set({ 5069 state: globalThis.Checkout.SubmittingStates.DONE 5070 }); 5071 globalThis.Checkout.store.state.set(globalThis.Checkout.StoreStates.SUBMITTED); 5072 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED_FINALIZED, payload); 5073 __privateMethod(this, _CheckoutSubmit_static, handleFormSubmitRedirect_fn).call(this, response, response.headers.get("Location")); 5074 } 5075 } else if (response.status >= 300 && response.status < 400) { 5076 globalThis.Checkout.store.submitting.set({ 5077 state: globalThis.Checkout.SubmittingStates.DONE 5078 }); 5079 globalThis.Checkout.store.state.set(globalThis.Checkout.StoreStates.SUBMITTED); 5080 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED_FINALIZED, payload); 5081 __privateMethod(this, _CheckoutSubmit_static, handleFormSubmitRedirect_fn).call(this, response, response.headers.get("Location") ?? globalThis.location.href); 5082 } else if (response.status === 429) { 5083 clearInterval(timer); 5084 globalThis.Checkout.store.submitting.set({ 5085 state: globalThis.Checkout.SubmittingStates.ERROR, 5086 code: globalThis.Checkout.ErrorTypes.EXCEEDED_MAX_RETRIES 5087 }); 5088 } else { 5089 globalThis.Checkout.store.submitting.set({ 5090 state: globalThis.Checkout.SubmittingStates.ERROR, 5091 code: globalThis.Checkout.ErrorTypes.UNHANDLED_SERVER_RESPONSE 5092 }); 5093 } 5094 }).catch((err) => { 5095 console.error(err); 5096 clearInterval(timer); 5097 globalThis.Checkout.store.submitting.set({ 5098 state: globalThis.Checkout.SubmittingStates.ERROR, 5099 code: globalThis.Checkout.ErrorTypes.SERVER_ERROR 5100 }); 5101 }); 5102 } 5103}; 5104_redirecTo = new WeakMap(); 5105_threedsListenerEnabled = new WeakMap(); 5106_formSubmitPayload = new WeakMap(); 5107_CheckoutSubmit_static = new WeakSet(); 5108leadSourceGenerator_fn = function() { 5109 const DEFAULT_MAX_CHARS_LENGTH = 512; 5110 const leadQueryParamMapping = { 5111 utm_source: { 5112 name: "source" 5113 }, 5114 utm_medium: { 5115 name: "medium" 5116 }, 5117 utm_campaign: { 5118 name: "campaign" 5119 }, 5120 utm_term: { 5121 name: "term" 5122 },
5123 utm_content: { 5124 name: "content" 5125 }, 5126 affiliate: {}, 5127 subAffiliate: {}, 5128 clickId: {}, 5129 salesAgent: {} 5130 }; 5131 const params = new URLSearchParams(globalThis.location.search); 5132 return Array.from(params.keys()).reduce((acc, key) => { 5133 const mappedValue = leadQueryParamMapping[key]; 5134 if (mappedValue) { 5135 const paramValue = params.get(key); 5136 const leadSourceName = mappedValue.name ?? key; 5137 acc[leadSourceName] = paramValue.substring(0, DEFAULT_MAX_CHARS_LENGTH); 5138 } 5139 return acc; 5140 }, {}); 5141}; 5142submitRebilly_fn = function(onValidationError) { 5143 const paymentType = globalThis.Checkout.store.payment.type.get(); 5144 const method = REBILLY_PAYMENT_METHOD_BY_TYPE_MAP[paymentType] ?? paymentType; 5145 const Rebilly = globalThis.Rebilly; 5146 let extraData = { method }; 5147 const leadSource = __privateMethod(this, _CheckoutSubmit_static, leadSourceGenerator_fn).call(this); 5148 if (Object.keys(leadSource).length) { 5149 extraData = { ...extraData, leadSource }; 5150 } 5151 const form = document.querySelector("#cfAR"); 5152 const rebillyDataMapping = { 5153 firstName: "first_name", 5154 lastName: "last_name", 5155 emails: "email", 5156 ...paymentType === "Klarna" ? { country: "country" } : {} 5157 }; 5158 const rebillyFieldKeyMapping = { 5159 "paymentInstrument.cvv": "cvv" 5160 }; 5161 Object.entries(rebillyDataMapping).forEach(([rebillyKey, dataKey]) => { 5162 const input = form.querySelector(`[data-rebilly="${rebillyKey}"]`); 5163 if (input) { 5164 let value = globalThis.Checkout.store.contact.get()[dataKey]; 5165 if (dataKey === "country") { 5166 const cartHasPhysicalProducts = hasPhysicalProducts(globalThis.Checkout.computed.checkoutCart.get()); 5167 const billingSameAsShipping = globalThis.Checkout.store.billingSameAsShipping.get(); 5168 const key = cartHasPhysicalProducts && billingSameAsShipping ? "shipping" : "billing"; 5169 value = globalThis.Checkout.store[key].get()[dataKey] ?? globalThis.Checkout.contactLocale.country; 5170 } 5171 input.value = value; 5172 } 5173 }); 5174 globalThis.clearBlankInputFields(); 5175 return Rebilly.createToken(form, extraData).catch((e) => { 5176 console.error(e); 5177 if (e.invalidFields && e.invalidFields.length) { 5178 e.invalidFields.forEach((error) => { 5179 const key = rebillyFieldKeyMapping[error.field]; 5180 if (key) { 5181 const event = { valid: false, error: { message: error.message } }; 5182 globalThis.Checkout.store.payment["payment-card"].events.setKey(key, event); 5183 } 5184 }); 5185 globalThis.Checkout.store.submitting.set({ 5186 state: globalThis.Checkout.SubmittingStates.ERROR, 5187 code: globalThis.Checkout.ErrorTypes.REBILLY_ERROR 5188 }); 5189 } else { 5190 let message = e.message; 5191 if (e.details.length) { 5192 const details = e.details.join(" - "); 5193 message = `${message} - ${details}`; 5194 } 5195 globalThis.Checkout.store.submitting.set({ 5196 state: globalThis.Checkout.SubmittingStates.ERROR, 5197 code: globalThis.Checkout.ErrorTypes.REBILLY_ERROR, 5198 message 5199 }); 5200 } 5201 onValidationError(e); 5202 }); 5203}; 5204buildPaymentMethodDetails_fn = function() { 5205 const mode = globalThis.Checkout.store.checkout.mode.get(); 5206 if (mode == globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE) return; 5207 const payment_method_type = globalThis.Checkout.store.payment.type.get(); 5208 const rebilly_token = globalThis.Checkout.store.payment[payment_method_type].token.get(); 5209 const payment_method_id = globalThis.Checkout.store.payment.id.get(); 5210 if (payment_method_id) return { payment_method_id, rebilly_token: null }; 5211 return { 5212 payment_method_id: null, 5213 payment_method_type, 5214 rebilly_token 5215 }; 5216}; 5217buildRegistrationDetails_fn = function() { 5218 return { 5219 calendar_event_id: document.getElementsByName("registration[calendar_event_id]")[0].value, 5220 occurs_at: document.getElementsByName("registration[occurs_at]")[0].value 5221 }; 5222}; 5223shouldIncludeRegistration_fn = function() { 5224 return document.getElementsByName("registration[calendar_event_id]")?.length > 0; 5225}; 5226buildAddressParams_fn = function(addressParams, options) { 5227 const mode = globalThis.Checkout.store.checkout.mode.get(); 5228 const billing = addressParams.billingAddress ?? {}; 5229 const shipping = addressParams.shippingAddress ?? {}; 5230 const checkoutCart = globalThis.Checkout.computed.checkoutCart.get(); 5231 if (mode == globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE && !hasPhysicalProducts(checkoutCart)) { 5232 return; 5233 } 5234 let billing_address_attributes, physical_address_attributes; 5235 if (mode !== globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE) { 5236 if (isSavedAddress(billing)) { 5237 billing_address_attributes = { 5238 id: billing.id 5239 }; 5240 } else { 5241 billing_address_attributes = { 5242 address_one: billing.address, 5243 address_two: billing.address_2, 5244 city: billing.city, 5245 region_name: billing.state, 5246 country_id: billing.country, 5247 postal_code: billing.zip 5248 }; 5249 } 5250 } 5251 if (isSavedAddress(shipping)) { 5252 physical_address_attributes = { 5253 id: shipping.id 5254 }; 5255 } else { 5256 physical_address_attributes = { 5257 address_one: shipping.address, 5258 address_two: shipping.address_2, 5259 city: shipping.city, 5260 region_name: shipping.state, 5261 country_id: shipping.country, 5262 postal_code: shipping.zip 5263 }; 5264 } 5265 if (hasPhysicalProducts(checkoutCart)) { 5266 const billingSameAsShipping = globalThis.Checkout.store.billingSameAsShipping.get(); 5267 if (options.skipBillingAddress) { 5268 return { shipping: { shipping_addresses_attributes: [{ physical_address_attributes }] } }; 5269 } 5270 if (mode == globalThis.Checkout.CheckoutStates.OTO) { 5271 return { 5272 shipping: { shipping_addresses_attributes: [{ physical_address_attributes }] }, 5273 billing: { billing_address_attributes, billing_same_as_shipping: false } 5274 }; 5275 } 5276 if (billingSameAsShipping) { 5277 return { 5278 shipping: { shipping_addresses_attributes: [{ physical_address_attributes }] }, 5279 billing: { billing_same_as_shipping: true } 5280 }; 5281 } else { 5282 return { 5283 shipping: { shipping_addresses_attributes: [{ physical_address_attributes }] }, 5284 billing: { billing_address_attributes, billing_same_as_shipping: false } 5285 }; 5286 } 5287 } else { 5288 if (options.skipBillingAddress) return; 5289 return { billing: { billing_address_attributes } }; 5290 } 5291}; 5292submitOrderAsync_fn = async function(data, requestIdempotency, maxRetries = 3, onBeforeSubmit, onRetryAfter) { 5293 let response; 5294 for (let i = 0; i < maxRetries; i++) { 5295 onBeforeSubmit(); 5296 const nonce = await fetchCheckoutNonce(); 5297 response = await fetch(renderedHref(), { 5298 credentials: "same-origin", 5299 method: "post", 5300 body: JSON.stringify({ ...data, request_idempotency: requestIdempotency, ...checkoutNonceParams(nonce) }), 5301 headers: { 5302 "Content-Type": "application/json", 5303 "X-CF2-POST-TYPE": "submit" 5304 } 5305 }).then((res) => { 5306 if (res.status >= 500) { 5307 console.error(res); 5308 throw Error("500 error"); 5309 } 5310 return res; 5311 }); 5312 if (response.status === 429) { 5313 const sleepTime = parseInt(response.headers.get("Retry-After")); 5314 onRetryAfter(sleepTime); 5315 console.log(`Waiting on queue, retrying after ${sleepTime}`); 5316 await sleepMs(sleepTime); 5317 } else { 5318 break; 5319 } 5320 } 5321 return response; 5322}; 5323handleFormSubmitRedirect_fn = async function(response, urlToRedirect) { 5324 globalThis.location.href = urlToRedirect; 5325}; 5326add3dsListener_fn = function() { 5327 if (__privateGet(this, _threedsListenerEnabled)) return; 5328 __privateSet(this, _threedsListenerEnabled, true); 5329 globalThis.addEventListener("message", (event) => { 5330 if (event.data.sender == "CfOrderStatus") { 5331 const orderDetails = event.data.details; 5332 if (__privateGet(this, _redirecTo)) { 5333 orderDetails.redirect_to = __privateGet(this, _redirecTo); 5334 } 5335 fetch(renderedHref(), { 5336 credentials: "same-origin", 5337 method: "post", 5338 body: JSON.stringify(orderDetails), 5339 headers: { 5340 "Content-Type": "application/json", 5341 "X-CF2-POST-TYPE": "submit" 5342 } 5343 }).then((response) => { 5344 if (orderDetails["orderResult"] == "declined") { 5345 globalThis.Checkout.store.submitting.set({ 5346 state: globalThis.Checkout.SubmittingStates.ERROR, 5347 code: globalThis.Checkout.ErrorTypes.THREEDS_DECLINED_ERROR 5348 }); 5349 } else { 5350 if (response.ok) { 5351 globalThis.Checkout.store.state.set(globalThis.Checkout.StoreStates.SUBMITTED);
5352 globalThis.CFDispatchEvent(globalThis.CFEvents.FORM_SUBMITTED_FINALIZED, __privateGet(this, _formSubmitPayload)); 5353 __privateMethod(this, _CheckoutSubmit_static, handleFormSubmitRedirect_fn).call(this, response, response.headers.get("Location")); 5354 } else { 5355 response.json().then((r) => { 5356 globalThis.Checkout.store.submitting.set({ 5357 state: globalThis.Checkout.SubmittingStates.ERROR, 5358 code: globalThis.Checkout.ErrorTypes.THREEDS_DECLINED_CUSTOM_ERROR, 5359 message: r.error 5360 }); 5361 }); 5362 } 5363 } 5364 globalThis.Checkout.store.threeds.set({ 5365 show: false, 5366 approvalUrl: null 5367 }); 5368 }); 5369 } 5370 }); 5371}; 5372__privateAdd(CheckoutSubmit, _CheckoutSubmit_static); 5373__privateAdd(CheckoutSubmit, _redirecTo, document.querySelector('[href="#submit-checkout-form"]')?.getAttribute("data-on-submit-go-to")); 5374__privateAdd(CheckoutSubmit, _threedsListenerEnabled, false); 5375__privateAdd(CheckoutSubmit, _formSubmitPayload, null); 5376
5377// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-apple-pay-button-v1.ts 5378init_runtime(); 5379var CheckoutApplePayButtonV1 = class extends CF2Component { 5380 constructor(el, runtimeSel) { 5381 super(el, runtimeSel); 5382 } 5383 mount() { 5384 this.applePayMounted = nanostores.atom(false); 5385 const checkoutElement = this.element.closest(".elCheckout"); 5386 if (!!this.getApplePayPreview()) { 5387 this.getApplePayPreview().addEventListener("click", (evt) => { 5388 evt.preventDefault(); 5389 CheckoutSubmit.checkSubmitShowErrors({ onlyFields: /* @__PURE__ */ new Set(["products"]) }); 5390 CheckoutSubmit.checkSubmit(checkoutElement); 5391 }); 5392 new MutationObserver((mutations) => { 5393 for (const mutation of mutations) { 5394 for (const addedNode of mutation.addedNodes) { 5395 if (addedNode.id == "rebilly-apple-pay-button") { 5396 this.applePayMounted.set(true); 5397 } 5398 } 5399 for (const removedNode of mutation.removedNodes) { 5400 if (removedNode.id == "rebilly-apple-pay-button") { 5401 this.applePayMounted.set(false); 5402 } 5403 } 5404 } 5405 }).observe(this.element.querySelector(".apple-pay-button"), { 5406 subtree: true, 5407 childList: true 5408 }); 5409 const computedState = nanostores.computed([ 5410 Checkout.computed.isDigitalWalletReadyToStart, 5411 this.applePayMounted, 5412 Checkout.store.isUpdatingRebilly 5413 ], (isDigitalWalletReadyToStart, isMounted, isUpdatingRebilly) => { 5414 if (isUpdatingRebilly) { 5415 return "loading"; 5416 } else if (!isMounted || !isDigitalWalletReadyToStart) { 5417 return "preview"; 5418 } else { 5419 return "ready"; 5420 } 5421 }); 5422 computedState.subscribe((state) => { 5423 this.getApplePayWrapper() && (this.getApplePayWrapper().dataset.state = state); 5424 }); 5425 const computedShowApplePay = nanostores.computed([ 5426 Checkout.store.payment.id, 5427 Checkout.store.payment.type 5428 ], (paymentId, paymentType) => { 5429 return !paymentId && paymentType == "apple-pay" && this.mode != "upgradeDowngrade"; 5430 }); 5431 computedShowApplePay.subscribe((showApplePay) => { 5432 this.element.closest(".submit-button-wrapper")?.setAttribute("data-show-apple-pay", showApplePay); 5433 }); 5434 } 5435 } 5436 getApplePayWrapper() { 5437 return this.element.querySelector(".apple-pay-button-wrapper"); 5438 } 5439 getApplePayPreview() { 5440 return this.element.querySelector(".apple-pay-button-preview"); 5441 } 5442}; 5443registerComponent("CheckoutApplePayButton/V1", CheckoutApplePayButtonV1); 5444window["CheckoutApplePayButtonV1"] = CheckoutApplePayButtonV1; 5445
5446// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-submit-button-v1.ts 5447init_define_process(); 5448init_general(); 5449init_runtime(); 5450var CheckoutSubmitButtonV1 = class extends CF2Component { 5451 constructor(el, runtimeSel) { 5452 super(el, runtimeSel); 5453 } 5454 onSubmit(element) { 5455 } 5456 mount() { 5457 this.storeButtonInitialHTML(); 5458 this.getSubmitButton().addEventListener("click", (evt) => { 5459 evt.preventDefault(); 5460 this.requestSubmit(); 5461 }); 5462 const checkoutElement = this.element.closest(".elCheckout"); 5463 Checkout.store.state.listen((state) => { 5464 if (state === Checkout.StoreStates.INITIALIZED && !this.keydownListenerAttached) { 5465 this.keydownListenerAttached = true; 5466 document.addEventListener("keydown", (evt) => { 5467 if (evt.isComposing || evt.keyCode === 229) return; 5468 if (evt.keyCode === 13 && $(this.element).is(":visible")) { 5469 if (isElementVisibleOnViewport(checkoutElement, 20)) { 5470 this.element.focus(); 5471 this.requestSubmit(); 5472 } 5473 } 5474 }); 5475 } 5476 }); 5477 } 5478 // The single entry point for every submit trigger. The lock is taken 5479 // synchronously, before any await, so it covers the whole attempt -- the 5480 // validation, tokenization and nonce work that runs before the payment POST as 5481 // well as the POST itself. The Enter key comes through here too, since 5482 // `pointer-events: none` only stops pointer input. 5483 requestSubmit() { 5484 if (this.isSubmitLocked()) return; 5485 this.lockSubmit(); 5486 Promise.all(this.onSubmit(this.element) ?? []).finally(() => { 5487 if (!this.submitClaimed) this.unlockSubmit(); 5488 }); 5489 } 5490 isSubmitLocked() { 5491 return this.getSubmitButton().getAttribute("data-disabled") === "true"; 5492 } 5493 // aria-disabled rides along because the button is an anchor: `pointer-events: none` 5494 // takes it out of the pointer flow but says nothing to a screen reader. 5495 lockSubmit() { 5496 this.getSubmitButton().setAttribute("data-disabled", true); 5497 this.getSubmitButton().setAttribute("aria-disabled", true); 5498 } 5499 unlockSubmit() { 5500 this.getSubmitButton().setAttribute("data-disabled", false); 5501 this.getSubmitButton().removeAttribute("aria-disabled"); 5502 } 5503 // Locks the button on behalf of a gateway. Also covers submits that never 5504 // touched this button -- express/wallet payments, the OTO one-click flow -- 5505 // which would otherwise leave it live while a payment is running. 5506 claimSubmit() { 5507 this.submitClaimed = true; 5508 this.lockSubmit(); 5509 } 5510 getSubmitButton() { 5511 return this.element.querySelector('[href="#submit-checkout-form"]'); 5512 } 5513 storeButtonInitialHTML() { 5514 const buttonMainText = this.element.querySelector(".elButtonMain .elButtonMainText"); 5515 const buttonSubText = this.element.querySelector(".elButtonSub"); 5516 this.buttonMainTextInitialHTML = buttonMainText.innerHTML; 5517 this.buttonSubTextInitialHTML = buttonSubText.innerHTML; 5518 } 5519 // The gateways' "back to idle" call, and so also the only thing that releases 5520 // the submit lock. Callers must not use it to refresh the label while a submit 5521 // is in flight. 5522 setButtonInitialHTML() { 5523 this.submitClaimed = false; 5524 this.unlockSubmit(); 5525 this.element.removeAttribute("data-loading"); 5526 const buttonMain = this.element.querySelector(".elButtonMain"); 5527 const buttonSub = this.element.querySelector(".elButtonSub"); 5528 buttonMain.querySelector(".elButtonSpinner").style.removeProperty("display"); 5529 const buttonMainText = buttonMain.querySelector(".elButtonMainText"); 5530 buttonMainText.innerHTML = this.buttonMainTextInitialHTML; 5531 buttonSub.innerHTML = this.buttonSubTextInitialHTML; 5532 } 5533 setLoading() { 5534 this.element.setAttribute("data-loading", "true"); 5535 } 5536 setSubmittingText() { 5537 this.claimSubmit(); 5538 this.element.removeAttribute("data-loading"); 5539 const buttonMain = this.element.querySelector(".elButtonMain"); 5540 const buttonSub = this.element.querySelector(".elButtonSub"); 5541 buttonMain.querySelector(".elButtonSpinner").style.display = "inline-block"; 5542 const buttonMainText = buttonMain.querySelector(".elButtonMainText"); 5543 buttonMainText.innerHTML = this.submittingText; 5544 buttonSub.innerHTML = ""; 5545 } 5546 update({ text, subText }) { 5547 this.element.removeAttribute("data-loading"); 5548 const buttonMain = this.element.querySelector(".elButtonMain"); 5549 const buttonSub = this.element.querySelector(".elButtonSub"); 5550 const buttonMainText = buttonMain.querySelector(".elButtonMainText"); 5551 buttonMainText.textContent = text; 5552 buttonSub.textContent = subText; 5553 } 5554}; 5555registerComponent("CheckoutSubmitButton/V1", CheckoutSubmitButtonV1); 5556window["CheckoutSubmitButtonV1"] = CheckoutSubmitButtonV1; 5557
5558// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-configuration-error-v1.ts 5559init_define_process(); 5560init_runtime(); 5561var CheckoutConfigurationErrorV1 = class extends CF2Component { 5562 constructor(el, runtimeSel) { 5563 super(el, runtimeSel); 5564 __publicField(this, "errorMessageMapping", { 5565 [ERROR_CODES.EMPTY_PAYMENT_METHODS_ERROR]: `<a href="https://support.myclickfunnels.com/docs/getting-started-setting-up-payments-in-clickfunnels" target="_blank">${this.checkoutConfigurationErrorsTexts.emptyPaymentMethodsError}</a>`, 5566 [ERROR_CODES.EMPTY_PRODUCTS_ERROR]: this.checkoutConfigurationErrorsTexts.emptyProductsError, 5567 [ERROR_CODES.ORDER_RECURRING_INTERVAL_MISMATCH]: this.checkoutConfigurationErrorsTexts.orderRecurringIntervalMismatchError, 5568 [ERROR_CODES.MULTIPLE_CHECKOUT_PRESENT]: this.checkoutConfigurationErrorsTexts.multipleCheckoutPresentError 5569 }); 5570 } 5571 mount() { 5572 const prettifyErrorMessage = (error) => { 5573 if (this.errorMessageMapping[error.code]) return this.errorMessageMapping[error.code]; 5574 if (error.fetchErrorType == CFFetcherErrorTypes.NETWORK_ERROR) { 5575 return `${this.checkoutConfigurationErrorsTexts.networkError} ${error.code}`; 5576 } else { 5577 return `${this.checkoutConfigurationErrorsTexts.criticalServerError} ${error.code}`; 5578 } 5579 }; 5580 Checkout.store?.criticalErrors?.subscribe((errors) => { 5581 this.errors = errors.map(prettifyErrorMessage); 5582 this.render(); 5583 }); 5584 } 5585 setErrors(errors) { 5586 if (errors === null || typeof errors === "undefined") { 5587 return; 5588 } 5589 this.errors = Array.isArray(errors) ? errors : [errors]; 5590 this.render(); 5591 } 5592 remove() { 5593 this.element.innerHTML = ""; 5594 } 5595 render(initializeChildrenInstances = false) { 5596 const is_server = true; 5597 const errors = this.errors ?? []; 5598 const checkoutConfigurationErrorsTexts = this.checkoutConfigurationErrorsTexts ?? null; 5599 let html = ""; 5600 { 5601 html += `<div class="elCheckoutConfigError`; 5602 if (errors?.length == 0) { 5603 html += ` elHide`; 5604 } 5605 html += `">`; 5606 const c0 = errors; 5607 const fl1 = new CF2ForloopDrop(c0.length); 5608 for (const error of c0) { 5609 const forloop = fl1; 5610 html += `<span>${error}</span>`; 5611 forloop.next(); 5612 } 5613 html += `</div>`; 5614 } 5615 this.replaceContent(html); 5616 if (initializeChildrenInstances) { 5617 const scopeToYggRender = this.element.querySelectorAll("[ygg-render]").length > 0; 5618 const options = { scopeToYggRender }; 5619 CF2Component.hydrateTree(this.element, options); 5620 } 5621 } 5622}; 5623registerComponent("CheckoutConfigurationError/V1", CheckoutConfigurationErrorV1); 5624window["CheckoutConfigurationErrorV1"] = CheckoutConfigurationErrorV1; 5625
5626// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-order-details-content-v1.ts 5627init_define_process(); 5628init_runtime(); 5629var CheckoutOrderDetailsContentV1 = class extends CF2Component { 5630 constructor(el, runtimeSel) { 5631 super(el, runtimeSel); 5632 __publicField(this, "undefined"); 5633 } 5634 remove() { 5635 this.element.innerHTML = ""; 5636 } 5637 render(initializeChildrenInstances = false) { 5638 const is_server = true; 5639 const order_details = this.order_details ?? { "order_number": "#12345", "shipping_address": {}, "billing_address": {}, "billing_payment_method": { "id": 1, "details": "XXXX-XXXX-XXXX-1111", "type": "payment-card", "icon": "visa" }, "line_items": [{ "variant_id": 25, "product_id": 6508, "quantity": 1, "image": "/editor/editor-demo-image-placeholder.svg" }] }; 5640 let html = ""; 5641 { 5642 html += `<div class="elCheckoutOrderDetailsInfoWrapper"><div class="elCheckoutOrderDetailsInfo"><h2> ${order_details?.order_number}</h2><div class="elCheckoutOrderDetailsStatus" data-order-status="${order_details?.service_status}">${order_details?.service_status.charAt(0).toUpperCase() + order_details?.service_status.slice(1).toLowerCase()}</div></div>`; 5643 if (order_details?.name) { 5644 html += `<span class="elCheckoutOrderDetailsName">${order_details?.name}</span>`; 5645 } 5646 html += `<span class="elCheckoutOrderDetailsDate">${order_details?.created_at}</span></div><div class="elCheckoutOrderDetailsItemsWrapper elCheckoutOrderDetailsWrapper"><h3></h3><div class="elCheckoutOrderDetailsItems elCheckoutOrderDetailsContainer">`; 5647 const c0 = order_details.line_items; 5648 const fl1 = new CF2ForloopDrop(c0.length); 5649 for (const line_item of c0) { 5650 const forloop = fl1; 5651 html += `<div class="elCheckoutOrderDetailsItem">`; 5652 const imageUrl = line_item?.image; 5653 if (imageUrl) { 5654 html += `<div class="elCheckoutOrderDetailsItemImage"><div data-page-element="Image/V2" class="elImageWrapper de-image-block id-Image/V2`; 5655 if (CF2Blank(imageUrl) && CF2Blank(null) && true) { 5656 html += ` forceHide`; 5657 } 5658 html += `" data-liquid-replace="item">`; 5659 if (imageUrl || !CF2Blank(null)) { 5660 html += `<img class="elImage" src="${imageUrl ?? null}" data-lazy-loading="true" data-lazy-loading="true"/>`; 5661 } else if (false) { 5662 html += `<div class="image-placeholder" title=""><span class="image-placeholder-header"></span></div>`; 5663 } 5664 html += `</div><div class="elCheckoutOrderDetailsItemQty">${line_item?.quantity}</div></div>`; 5665 } 5666 html += `<div class="elCheckoutOrderDetailsItemInfo"><span class="elCheckoutOrderDetailsItemName">${line_item?.product_name}</span>`; 5667 if (line_item?.display_price) { 5668 html += `<span class="elCheckoutOrderDetailsItemPrice">${line_item?.display_price}</span>`; 5669 } 5670 if (line_item?.variant_properties_values?.length > 0) { 5671 html += `<div class="elCheckoutOrderDetailsVariants">`; 5672 const c2 = line_item.variant_properties_values; 5673 const fl3 = new CF2ForloopDrop(c2.length); 5674 for (const variant_item of c2) { 5675 const forloop2 = fl3; 5676 html += `<span>${variant_item?.value}</span>`; 5677 forloop2.next(); 5678 } 5679 html += `</div>`; 5680 } 5681 html += `</div><div class="elCheckoutOrderDetailsItemAmount"><span>${line_item?.amount}</span></div></div>`; 5682 forloop.next(); 5683 } 5684 html += `</div></div>`; 5685 if (order_details?.shipping_address) { 5686 html += `<div class="elCheckoutOrderDetailsShipping elCheckoutOrderDetailsWrapper"><h3></h3><div class="elCheckoutOrderDetailsContainer"><i class="fas fa-map-marker-alt"></i><span>${order_details?.shipping_address}</span></div></div>`; 5687 } 5688 if (order_details?.billing_address) { 5689 html += `<div class="elCheckoutOrderDetailsBilling elCheckoutOrderDetailsWrapper"><h3></h3><div class="elCheckoutOrderDetailsContainer"><i class="far fa-credit-card"></i><span>${order_details?.billing_address}</span></div></div>`; 5690 } 5691 if (order_details?.billing_payment_method) { 5692 html += `<div class="elCheckoutOrderDetailsPayment elCheckoutOrderDetailsWrapper"><h3></h3>`; 5693 if (order_details?.billing_payment_method?.type == "payment-card") { 5694 html += `<div class="elCheckoutOrderDetailsPaymentType"><div class="elCheckoutOrderDetailsContainer"><i class="fab fa-cc-${order_details?.billing_payment_method?.icon}"></i><span>${order_details?.billing_payment_method?.details}</span></div></div>`; 5695 } else if (order_details?.billing_payment_method?.type == "paypal") { 5696 html += `<div class="elCheckoutOrderDetailsPaymentType"><div class="elCheckoutOrderDetailsContainer"><i class="fab fa-paypal"></i><span>${order_details?.billing_payment_method?.details}</span></div></div>`; 5697 } 5698 html += `</div>`; 5699 } 5700 html += `<div class="elCheckoutOrderDetailsSummaryWrapper elCheckoutOrderDetailsWrapper"><h3></h3>
5700<div class="elCheckoutOrderDetailsSummary elCheckoutOrderDetailsContainer">`; 5701 if (order_details?.tax_amount) { 5702 html += `<div class="elCheckoutOrderDetailsSummaryTax"><span></span><span>${order_details?.tax_amount}</span></div>`; 5703 } 5704 if (order_details?.shipping_amount) { 5705 html += `<div class="elCheckoutOrderDetailsSummaryShipping"><span></span><span>${order_details?.shipping_amount}</span></div>`; 5706 } 5707 html += `<div class="elCheckoutOrderDetailsSummaryTotal"><span></span><span>${order_details?.total_amount}</span></div></div></div>`; 5708 } 5709 this.replaceContent(html); 5710 if (initializeChildrenInstances) { 5711 const scopeToYggRender = this.element.querySelectorAll("[ygg-render]").length > 0; 5712 const options = { scopeToYggRender }; 5713 CF2Component.hydrateTree(this.element, options); 5714 } 5715 } 5716}; 5717registerComponent("CheckoutOrderDetailsContent/V1", CheckoutOrderDetailsContentV1); 5718window["CheckoutOrderDetailsContentV1"] = CheckoutOrderDetailsContentV1; 5719
5720// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-order-details-v1.ts 5721init_define_process(); 5722init_modal_v1(); 5723
5724// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-existing-orders.ts 5725init_define_process(); 5726
5727// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Utils/api.ts 5728init_define_process(); 5729init_fetcher(); 5730function makeCurrentPageFetcher(options) { 5731 const { headers, ...requestOptions } = options ?? {}; 5732 const fetcher = new Fetcher({ 5733 debug: true, 5734 pathPrefix: window.location.origin + renderedPath(), 5735 headers: { 5736 Accept: "application/json", 5737 "Content-Type": "application/json", 5738 ...headers ?? {} 5739 }, 5740 requestOptions: { 5741 retries: 3, 5742 timeoutMS: 3e4, 5743 timeoutAfterRetrial: 1e3, 5744 convertThrowToErrorResponse: true, 5745 onlyOneInflightRequest: true, 5746 ...requestOptions 5747 } 5748 }); 5749 return fetcher; 5750} 5751
5752// projects/lib/packages/yggdrasil-blueprints/src/Elements/Checkout/V2/Services/checkout-existing-orders.ts 5753var REACTAVATABLE_SERVICE_STATUS = ["canceled", "churned"]; 5754var existingOrderFetcher = makeCurrentPageFetcher({ 5755 customEvent: "CF2:ExistingOrder", 5756 shouldCaptureServerError: true, 5757 convertThrowToErrorResponse: false 5758}); 5759var _hasReactivatableItems, _hasUpgradeDowngradeItems, _productCardDetails, _productCardDetailsObj; 5760var CheckoutExistingOrders = class { 5761 static fetch(payload = {}) { 5762 if (globalThis.globalResourceData.resourceName == "checkout") return Promise.resolve(); 5763 const manage_order_id = new URLSearchParams(window.location.search).get("manage_order_id"); 5764 return existingOrderFetcher.get("/existing_orders", { manage_order_id, ...payload }).then((data) => { 5765 this.cleanUp(); 5766 this.processExistingOrdersResponse(data); 5767 }).catch((e) => { 5768 throw new CheckoutCriticalError(ERROR_CODES.FETCH_EXISTING_ORDERS_ERROR, { 5769 cause: e 5770 }); 5771 }); 5772 } 5773 static cleanUp() { 5774 __privateSet(this, _hasReactivatableItems, false); 5775 __privateSet(this, _hasUpgradeDowngradeItems, false); 5776 this.orderDetailsByOrderId = {}; 5777 __privateSet(this, _productCardDetails, {}); 5778 __privateSet(this, _productCardDetailsObj, {}); 5779 } 5780 static clearUpdatableOrders(selectedProductId) { 5781 if (anyUpdatableOrders()) { 5782 globalThis.globalResourceData.products?.forEach(({ id: productId }) => { 5783 const isSelected = selectedProductId == productId; 5784 updateCardByProductIdState(productId, { 5785 quantity: isSelected ? 1 : 0, 5786 renderType: void 0, 5787 selectedOrderIndex: void 0, 5788 selectedUpdatableCartItemIndex: void 0, 5789 updatableOrders: void 0, 5790 cartItemOrderId: void 0, 5791 cartItemLineItemId: void 0, 5792 cartItemRenderType: void 0 5793 }); 5794 }); 5795 this.cleanUp(); 5796 } 5797 } 5798 static processExistingOrdersResponse(existingOrdersResponse) { 5799 existingOrdersResponse.orders.forEach((order) => { 5800 const orderId = order.id; 5801 this.orderDetailsByOrderId[orderId] = order; 5802 const orderNumber = order.order_number; 5803 order.line_items.forEach((lineItem) => { 5804 const productId = lineItem.product_id; 5805 const lineItemSubscriptionDetails = lineItem.subscription_details; 5806 if (REACTAVATABLE_SERVICE_STATUS.includes(lineItemSubscriptionDetails?.status) && lineItemSubscriptionDetails?.reactivatable) { 5807 this.processReactivation(lineItem, orderId, orderNumber, productId); 5808 } else { 5809 this.processUpgradeDowngrades(lineItem, orderId, orderNumber, productId); 5810 } 5811 }); 5812 }); 5813 if (__privateGet(this, _hasReactivatableItems) || __privateGet(this, _hasUpgradeDowngradeItems)) { 5814 this.processUpdatableObj(); 5815 this.updateSelectedCardItem(); 5816 } 5817 } 5818 static processUpdatableObj() { 5819 __privateSet(this, _productCardDetails, {}); 5820 Object.keys(__privateGet(this, _productCardDetailsObj)).forEach((k) => { 5821 __privateGet(this, _productCardDetails)[k] = { 5822 updatableOrders: Object.values(__privateGet(this, _productCardDetailsObj)[k].updatableOrders).reverse() 5823 }; 5824 }); 5825 } 5826 static processReactivation(lineItem, orderId, orderNumber, productId) { 5827 const lineItemId = lineItem.id; 5828 const variantId = lineItem.variant_id; 5829 const priceId = lineItem.price_id; 5830 if (!globalThis.Checkout.variantsById[variantId] || !globalThis.Checkout.pricesById[priceId]) { 5831 return; 5832 } 5833 __privateSet(this, _hasReactivatableItems, true); 5834 this.storeProductCardDetails( 5835 globalThis.Checkout.CheckoutStates.REACTIVATE, 5836 orderId, 5837 orderNumber, 5838 lineItemId, 5839 productId, 5840 variantId, 5841 priceId 5842 ); 5843 } 5844 static processUpgradeDowngrades(lineItem, orderId, orderNumber, productId) { 5845 const lineItemId = lineItem.id; 5846 lineItem.upgrade_downgrade_options.forEach((upgradeDowngrade) => { 5847 const variantId = upgradeDowngrade.variant_to_id; 5848 const priceId = upgradeDowngrade.price_to_id; 5849 if (!globalThis.Checkout.variantsById[variantId] || !globalThis.Checkout.pricesById[priceId]) { 5850 return; 5851 } 5852 __privateSet(this, _hasUpgradeDowngradeItems, true);
5853 this.storeProductCardDetails( 5854 globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE, 5855 orderId, 5856 orderNumber, 5857 lineItemId, 5858 productId, 5859 variantId, 5860 priceId, 5861 upgradeDowngrade.direction 5862 ); 5863 }); 5864 } 5865 static storeProductCardDetails(type, orderId, orderNumber, lineItemId, productId, variantId, priceId, direction) { 5866 __privateGet(this, _productCardDetailsObj)[productId] = __privateGet(this, _productCardDetailsObj)[productId] ?? { 5867 updatableOrders: {} 5868 }; 5869 const updatableOrders = __privateGet(this, _productCardDetailsObj)[productId].updatableOrders; 5870 updatableOrders[orderId] = updatableOrders[orderId] ?? { 5871 type, 5872 id: orderId, 5873 number: orderNumber, 5874 updatableItems: [] 5875 }; 5876 const { name: variantName } = globalThis.Checkout.variantsById[variantId]; 5877 const { name: priceName } = globalThis.Checkout.pricesById[priceId]; 5878 const updatableItems = updatableOrders[orderId].updatableItems; 5879 updatableItems.push({ 5880 variantName, 5881 priceName, 5882 direction: direction ? direction?.charAt(0).toUpperCase() + direction?.slice(1) : null, 5883 cardDetails: { 5884 variantId, 5885 priceId, 5886 // NOTE: We disable orderId and lineItemId for reactivations until we can perform reactivations 5887 // on the same order as currently we create a new order when that happens 5888 ...type == globalThis.Checkout.CheckoutStates.UPGRADE_DOWNGRADE ? { 5889 orderId, 5890 lineItemId 5891 } : {} 5892 } 5893 }); 5894 } 5895 static updateSelectedCardItem() { 5896 let selectedCartItemDetail; 5897 const cartItems = globalThis.Checkout.computed.checkoutCart.get().items; 5898 cartItems.find(({ product_id, variant_id, price_id }) => { 5899 const cardDetails = __privateGet(this, _productCardDetails)[product_id]?.updatableOrders[0].updatableItems[0].cardDetails; 5900 if (!globalThis.Checkout.productsById[product_id].bump && __privateGet(this, _productCardDetails)[product_id]) { 5901 selectedCartItemDetail = {}; 5902 selectedCartItemDetail.variantId = cardDetails?.variantId ?? variant_id; 5903 selectedCartItemDetail.priceId = cardDetails?.priceId ?? price_id; 5904 selectedCartItemDetail.productId = product_id; 5905 return true; 5906 } 5907 }); 5908 if (!selectedCartItemDetail) { 5909 selectedCartItemDetail = {}; 5910 const mainCartItem = cartItems.find(({ product_id }) => !globalThis.Checkout.productsById[product_id].bump); 5911 const fallbackProductId = mainCartItem?.product_id ?? globalThis.globalResourceData.productVariantWithNoBump.product_id; 5912 const product = globalThis.Checkout.productsById[fallbackProductId]; 5913 const cardDetails = __privateGet(this, _productCardDetails)[product.id]?.updatableOrders[0].updatableItems[0].cardDetails; 5914 const variant = product.variants[0]; 5915 const price = variant.prices[0]; 5916 selectedCartItemDetail.variantId = cardDetails?.variantId ?? Number(variant.id); 5917 selectedCartItemDetail.priceId = cardDetails?.priceId ?? Number(price.id); 5918 selectedCartItemDetail.productId = product.id; 5919 } 5920 globalThis.globalResourceData.products?.forEach(({ id: productId }) => { 5921 const hasUpdatablePccState = !!__privateGet(this, _productCardDetails)[productId]; 5922 if (hasUpdatablePccState) { 5923 const order = __privateGet(this, _productCardDetails)[productId].updatableOrders[0]; 5924 const cartItem = order.updatableItems[0].cardDetails; 5925 const updatablePccState = __privateGet(this, _productCardDetails)[productId] ?? {}; 5926 updatablePccState.selectedOrderIndex = 0; 5927 updatablePccState.selectedUpdatableCartItemIndex = 0; 5928 updatablePccState.cartItemOrderId = cartItem.orderId; 5929 updatablePccState.cartItemLineItemId = cartItem.lineItemId; 5930 updatablePccState.cartItemRenderType = updatablePccState.renderType = order.type; 5931 updatablePccState.variantId = cartItem.variantId; 5932 updatablePccState.priceId = cartItem.priceId; 5933 const isProductInCart = selectedCartItemDetail.productId == productId; 5934 if (isProductInCart) { 5935 updatablePccState.variantId = selectedCartItemDetail.variantId; 5936 updatablePccState.priceId = selectedCartItemDetail.priceId; 5937 updatablePccState.quantity = 1; 5938 } 5939 const compositeKeys = getCompositeKeysForProduct(String(productId)); 5940 updateCardByProductIdState(productId, { 5941 ...updatablePccState, 5942 ...compositeKeys.length > 0 ? { quantity: 0 } : {} 5943 }); 5944 for (const compositeKey of compositeKeys) { 5945 const variantId = compositeKey.split(":")[1]; 5946 const matchingItem = order.updatableItems.find((item) =>
5946 String(item.cardDetails.variantId) == variantId); 5947 if (matchingItem) { 5948 updateCardByProductIdState(compositeKey, { 5949 updatableOrders: updatablePccState.updatableOrders, 5950 renderType: order.type, 5951 individualDirection: matchingItem.direction, 5952 selectedOrderIndex: 0, 5953 selectedUpdatableCartItemIndex: 0, 5954 cartItemRenderType: order.type, 5955 cartItemOrderId: matchingItem.cardDetails.orderId, 5956 cartItemLineItemId: matchingItem.cardDetails.lineItemId, 5957 variantId: matchingItem.cardDetails.variantId, 5958 priceId: matchingItem.cardDetails.priceId, 5959 quantity: isProductInCart && String(selectedCartItemDetail.variantId) == variantId ? 1 : 0 5960 }); 5961 } else { 5962 const fullOrder = this.orderDetailsByOrderId[order.id]; 5963 const isCurrentVariant = fullOrder?.line_items?.some( 5964 (li) => String(li.variant_id) == variantId && String(li.product_id) == String(productId) 5965 ); 5966 if (isCurrentVariant) { 5967 updateCardByProductIdState(compositeKey, { 5968 updatableOrders: updatablePccState.updatableOrders, 5969 renderType: order.type, 5970 individualDirection: "current", 5971 selectedOrderIndex: -1, 5972 cartItemRenderType: void 0, 5973 cartItemOrderId: void 0, 5974 cartItemLineItemId: void 0 5975 }); 5976 } 5977 } 5978 } 5979 } else { 5980 updateCardByProductIdState(productId, { selectType: "single" }); 5981 } 5982 }); 5983 } 5984}; 5985_hasReactivatableItems = new WeakMap(); 5986_hasUpgradeDowngradeItems = new WeakMap(); 5987_productCardDetails = new WeakMap(); 5988_productCardDetailsObj = new WeakMap(); 5989__privateAdd(CheckoutExistingOrders, _hasReactivatableItems, false); 5990__privateAdd(CheckoutExistingOrders, _hasUpgradeDowngradeItems, false); 5991__privateAdd(CheckoutExistingOrders, _productCardDetails, {}); 5992__privateAdd(CheckoutExistingOrders, _productCardDetailsObj, {}); 5993__publicField(CheckoutExistingOrders, "orderDetailsByOrderId", {}); 5994
5995// projects/lib/packages/yggdrasil-blueprints/__generated__/blueprints/checkout-order-details-v1.ts 5996init_runtime(); 5997var CheckoutOrderDetailsV1 = class extends CF2Component { 5998 constructor(el, runtimeSel) { 5999 super(el, runtimeSel); 6000 } 6001 mount() { 6002 this.getCloseButton().addEventListener("click", (evt) => { 6003 evt.preventDefault(); 6004 Checkout.store.selectedOrderDetailId.set(null); 6005 }); 6006 this.getModal().onClose = () => { 6007 Checkout.store.selectedOrderDetailId.set(null); 6008 }; 6009 Checkout.store.selectedOrderDetailId.listen((selectedOrderDetailId) => { 6010 if (selectedOrderDetailId) { 6011 this.showModal(); 6012 this.getContent().order_details = CheckoutExistingOrders.orderDetailsByOrderId[selectedOrderDetailId]; 6013 const orderDetails = this.getContent().order_details; 6014 this.formatOrderDetails(orderDetails); 6015 this.getContent().render(); 6016 } else { 6017 this.hideModal(); 6018 } 6019 }); 6020 } 6021 addressToString(address) { 6022 let str = ""; 6023 if (address.street_one) { 6024 str = address.street_one; 6025 if (address.street_two) { 6026 str += `, ${address.street_two}`; 6027 } 6028 if (address.city) { 6029 str += `. ${address.city}`; 6030 } 6031 if (address.region) { 6032 str += `, ${address.region}`; 6033 } 6034 if (address.postal_code) { 6035 str += ` ${address.postal_code}`; 6036 } 6037 if (address.country) { 6038 str += `, ${address.country}`; 6039 } 6040 } else { 6041 if (address.postal_code) { 6042 str += `${address.postal_code}, `; 6043 } 6044 if (address.country) { 6045 str += `${address.country}`; 6046 } 6047 } 6048 return str; 6049 } 6050 formatOrderDetails(orderDetails) { 6051 orderDetails.created_at = new Date(orderDetails.created_at_epoch * 1e3).toLocaleString(navigator.language); 6052 if (orderDetails.shipping_address) { 6053 orderDetails.shipping_address = this.addressToString(orderDetails.shipping_address); 6054 } 6055 if (orderDetails.billing_address) { 6056 orderDetails.billing_address = this.addressToString(orderDetails.billing_address); 6057 } 6058 if (orderDetails.line_items.length) { 6059 this.findAndAddProductsImage(orderDetails.line_items); 6060 } 6061 } 6062 getContent() { 6063 return this.getComponent("CheckoutOrderDetailsContent/V1"); 6064 } 6065 getModal() { 6066 return this.getComponent("Modal/V1"); 6067 } 6068 getCloseButton() { 6069 return this.getModal().element.querySelector(".elCheckoutModalFormClose"); 6070 } 6071 showModal() { 6072 this.getModal().element.style.display = "flex"; 6073 } 6074 hideModal() { 6075 this.getModal().element.style.display = "none"; 6076 } 6077 findAndAddProductsImage(lineItems) { 6078 lineItems.forEach((lineItem) => { 6079 lineItem.image = Checkout.variantsById[lineItem.variant_id].image ?? Checkout.productsById[lineItem.product_id].image; 6080 }); 6081 } 6082}; 6083registerComponent("CheckoutOrderDetails/V1", CheckoutOrderDetailsV1); 6084window["CheckoutOrderDetailsV1"] = CheckoutOrderDetailsV1; 6085 6086export { 6087 CheckoutTosV1, 6088 CheckoutMultiStepV2, 6089 hasPhysicalProducts, 6090 setupOrderSummaries, 6091 scrollToFirstVisibleError, 6092 checkValidCustomFields, 6093 buildCustomFields, 6094 collectLeads, 6095 AVAILABLE_KLARNA_COUNTRIES, 6096 numberOfStepsInCheckout, 6097 updateCardByProductIdState, 6098 unselectAllProducts, 6099 initIndividualVariantState, 6100 buildProductSelectBatched, 6101 CheckoutShippingProfileSelectV1, 6102 CheckoutLoadingV1, 6103 CheckoutSubmitNotificationV1, 6104 renderedHref, 6105 backfillAddressesId, 6106 isSavedAddress, 6107 fieldsForCountry, 6108 addressToString, 6109 parseAddressByFields, 6110 normalizeServerCheckoutError, 6111 serverCheckoutErrorMessage, 6112 isActionableCheckoutError, 6113 CheckoutCriticalError, 6114 ERROR_CODES, 6115 displayAndLogCriticalError, 6116 resolveInitialPaymentType, 6117 PaypalStates, 6118 ErrorTypes, 6119 hasUpgradeDowngradeItems, 6120 getStripeMode, 6121 getCartEstimatedTotal, 6122 convertToStripeAddress, 6123 convertAddressFromStripe, 6124 convertAddressFromSession, 6125 STRIPE_SKIP_SHIPPING_ID, 6126 calculateStripeChangeResolveDetails, 6127 calculateStripeClickResolveDetails, 6128 parseCssVars, 6129 hasErrors, 6130 productErrors, 6131 shippingOptionErrors, 6132 tosErrors, 6133 addressErrors, 6134 contactErrors, 6135 encodeVirtualInstallmentId, 6136 decodeVirtualInstallmentId, 6137 create, 6138 buildComputed, 6139 initializeUtilities, 6140 CheckoutSubmit, 6141 CheckoutSubmitButtonV1, 6142 CheckoutConfigurationErrorV1, 6143 makeCurrentPageFetcher, 6144 CheckoutExistingOrders 6145}; 6146//# sourceMappingURL=chunk-BCSE7FET.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.