PageSourceSearch

https://www.lovisa.co.uk/cdn/shop/t/811/assets/component-added-to-cart.js?v=80125658308530081831789977862

js lovisa.co.uk collected 2026-09-26 13:25:31 UTC 18,896 bytes, 131 lines download raw bytes

1var promotion_slider=0;function initPromotionSlider(){promotion_slider==0?(promotion_slider=1,jQuery(".promotion-products").slick({slidesToShow:4,slidesToScroll:4,infinite:!1,arrows:!0,variableWidth:!1})):jQuery(".promotion-products").slick("refresh")}function formatPriceWithSup(price){const formatted=slate.Currency.formatMoney(price,window.theme.moneyFormat).replace(/<\/?[^>]+(>|$)/g,""),symbol=window.theme.currentCurrencySymbol;return formatted.includes(symbol)?formatted.replace(symbol,`<em class="currency-symbol">${symbol}</em>`):`<em class="currency-symbol">${symbol}</em>${slate.Currency.removeCurrencySymbol(formatted)}`}function resetButtonHtml(){$(".promotion-form").each(function(){var this_form=$(this),buttonHtml=this_form.find(".promotion_add");buttonHtml.hasClass("added")&&buttonHtml.removeClass("added"),buttonHtml.children(".added-image").css("display","none")})}function openCartPopup(){window.theme.lastActiveElement=document.activeElement;const cartPopup=document.getElementById("cart-popup");cartPopup.style.display="block",cartPopup.classList.add("active"),cartPopup.setAttribute("aria-hidden","false"),cartPopup.focus(),document.getElementById("cart-popup-overlay").style.display="block",jQuery("body").addClass("stopScrolling"),initPromotionSlider(),setTimeout(function(){this.toggleProductDetailOverlay(!0)},1e3)}function closePopup(){try{jQuery(".promotion-products").slick("slickGoTo",0)}catch{}this.resetButtonHtml(),jQuery(".product-card__variant-container[data-show-added-btn]").data("show-added-btn",!1),jQuery(".promotion-upsells-items .add-product-variant").css("display","block"),jQuery(".promotion-upsells-items .promotion_added_variant_btn").css("display","none");const cartPopup=document.getElementById("cart-popup");cartPopup.style.display="none",cartPopup.classList.remove("active"),cartPopup.setAttribute("aria-hidden","true"),document.getElementById("cart-popup-overlay").style.display="none",window.theme.lastActiveElement&&(window.theme.lastActiveElement.focus(),window.theme.lastActiveElement=null),jQuery("body").removeClass("stopScrolling")}function toggleProductDetailOverlay(show){const loaderOverlay=document.querySelector(".add-bag-overlay__loader");show&&loaderOverlay?(loaderOverlay.classList.add("hide-overlay"),loaderOverlay.classList.add("fade-overlay")):loaderOverlay&&(loaderOverlay.classList.remove("hide-overlay"),loaderOverlay.classList.remove("fade-overlay"))}function updateCartPopup(product){if(document.body.classList.contains("template-cart")||window.location.pathname.indexOf("/cart")===0||window.theme&&window.theme.template&&window.theme.template.template==="cart"){window.theme&&window.theme.cartPage&&(typeof window.theme.cartPage.updateCartItemsEvent=="function"&&window.theme.cartPage.updateCartItemsEvent(),typeof window.theme.cartPage.refreshCart=="function"&&window.theme.cartPage.refreshCart()),setTimeout(()=>{window.scrollTo({top:0,behavior:"smooth"})},500);return}fetch("/cart?view=json").then(response=>response.json()).then(cart=>{const cartProduct=cart.items.find(item=>item.variant_id===product.vId||item.id===product.vId||item.variant_id+""===product.vId||item.id+""===product.vId)||{},finalPrice=cartProduct.final_price||product.final_price||cartProduct.price||product.price,comparePrice=cartProduct.compare_at_price||cartProduct.original_price||product.compare_price||product.original_price,imageSrc=cartProduct.image?.src||product.image?.src||cartProduct.image||product.image;window.theme.upsells.type==="xgen"&&getXgenAtcRec(cartProduct.id);let original_price="",discount_percent="";comparePrice>finalPrice&&(original_price=`<span class="original-price">${formatPriceWithSup(comparePrice)}</span>`,discount_percent=`<span class="discount-percent">(-${Math.round((comparePrice-finalPrice)*100/comparePrice)}%)</span>`),this.toggleProductDetailOverlay(!1);var size="";(cartProduct.size||product.size)&&(size=`<div class='size'>${window.theme&&window.theme.strings&&window.theme.strings.sizeLabel||"Size:"} ${cartProduct.size||product.size}</div>`);const productDetails=`
2        <div class="product-image">
3          <img src="${imageSrc}" alt="${product.title}" />
4        </div>
5        <div class="product-info">
6          <div class="product-title">
7            ${product.title}
8          </div>
9          <div class="details">
10            ${size}
11            <div class="qty">
12              ${window.theme&&window.theme.strings&&window.theme.strings.qtyLabel||"Qty:"} ${product.quantity}
13            </div>
14            <div class="price-block">
15              ${original_price}
16              <div class="discount-line">
17                <span class="${original_price?"new-price":"price"}">
18                  ${formatPriceWithSup(finalPrice)}
19                </span>
20                ${discount_percent}
21              </div>
22            </div>
23          </div>
24        </div>
25      `;document.getElementById("popup-product-details")&&(document.getElementById("popup-product-details").innerHTML=productDetails),openCartPopup(),this.toggleProductDetailOverlay(!0)})}jQuery(document).ready(function(){jQuery(".cart-popup-overlay").click(function(){closePopup()}),jQuery(document).on("keydown:escape",function(e){closePopup()}),jQuery(document).on("click",".promotion .promotion_add_option",function(){var button=jQuery(this),form=button.closest(".promotion-form"),variants=form.find(".product-card__variants");return variants.length&&variants.children().length&&variants.addClass("product-card__variants--show"),!1}),jQuery(document).on("click",".promotion .promotion_add",function(){var add_product=$(this);const productId=add_product.data("upsell-product-id"),productFeatureImage=add_product.data("upsell-product-feature-image"),productUrl=add_product.data("upsell-product-url"),productVendor=add_product.data("upsell-product-vendor"),productPrice=add_product.data("upsell-product-price"),productComparePrice=add_product.data("upsell-product-compare-price"),itemObj={id:productId,quantity:1,image:productFeatureImage,url:productUrl,vendor:productVendor,price:productPrice,compare_price:productComparePrice};theme.sideCart.addItemFrmMybag(itemObj);const addedImage=add_product.children(".added-image");add_product.addClass("added"),addedImage.css("display","block")}),jQuery(document).on("click",".promotion-upsells-items .add-product-variant",function(){var variant_id=jQuery(this).data("variant-id"),featured_image=jQuery(this).data("variant-feature-image"),url=jQuery(this).closest(".promotion-form").find(".url").val(),vendor=jQuery(this).closest(".promotion-form").find(".vendor").val(),price=jQuery(this).closest(".promotion-form").val(),compare_price=$(this).closest(".promotion-form").find(".product-card__variants"),itemObj={id:variant_id,quantity:1,image:featured_image,url,vendor,price,compare_price};theme.sideCart.addItemFrmMybag(itemObj);const container=jQuery(this).closest(".product-card__variant-container");return jQuery(this).css("display","none"),container.find(".promotion_added_variant_btn").css("display","flex"),!1})});function getXgenAtcRec(pid){window.xgenCommon.recommend({ids:[window.xgen_vars.xgen_upsells_id]}).then(data=>{const cart=window.theme.sideCart.cart||{items:[]},result=data[window.xgen_vars.xgen_upsells_id],xgenProducts=result.items;if(xgenProducts.length){const productsNotInCart=xgenProducts.map(item=>window.xgenCommon.unifyProduct(item)).filter(product=>product.variants.some(variant=>variant.available)).filter(product=>cart.items.every(cartItem=>cartItem.product_id!==product.id)),promotionProducts=document.querySelector(".promotion-products");if(jQuery(".promotion-products").slick("destroy"),promotionProducts.innerHTML="",promotionProducts&&productsNotInCart.length){document.querySelector(".promotion-upsells-items").classList.remove("hidden"),promotion_slider=0;let recommendationsHtml="";productsNotInCart.forEach(product=>{const isOnlyInStore=product.tags&&product.tags.some(tag=>typeof tag=="string"&&tag.trim().toLowerCase()==="in-store");recommendationsHtml+=`
26          <div class="promotion" data-sku="${product.variants[0].sku}">
27              <a href="${product.url}">
28                <img src="${product.featured_image}" alt="${product.title}" width="68" height="86">
29            </a>
30            <div class="title">${product.title}</div>
31            <div class="price">${formatPriceWithSup(product.price)}</div>
32            <div class="promotion-form ${isOnlyInStore?"hide":""}">
33              ${product.variants.size>1?`
34                <button  class="promotion_add_option" aria-label="Add to bag option" >
35                  <svg class="added-image" style="display:none;" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
36                    <g clip-path="url(#clip0_3339_6012)">
37                    <circle cx="7.11279" cy="7" r="6.125" fill="white"/>
38                    <path d="M5.99447 9.74507L3.29461 7.04521L4.19457 6.14526L5.99447 7.94516L9.59429 4.34535L10.4942 5.2453L5.99447 9.74507Z" fill="#333333"/>
39                    <path fill-rule="evenodd" clip-rule="evenodd" d="M0.112793 7C0.112793 3.13401 3.2468 0 7.11279 0C10.9788 0 14.1128 3.13401 14.1128 7C14.1128 10.866 10.9788 14 7.11279 14C3.2468 14 0.112793 10.866 0.112793 7ZM7.11279 12.7273C3.94971 12.7273 1.38552 10.1631 1.38552 7C1.38552 3.83691 3.94971 1.27273 7.11279 1.27273C10.2759 1.27273 12.8401 3.83691 12.8401 7C12.8401 10.1631 10.2759 12.7273 7.11279 12.7273Z" fill="#333333"/>
40                    </g>
41                    <defs>
42                    <clipPath id="clip0_3339_6012">
43                    <rect width="13.7745" height="14" fill="white" transform="translate(0.112793)"/>
44                    </clipPath>
45                    </defs>
46                  </svg>
47                  Add
48                </button>
49                <div class="product-overlay"></div>
50                <div role="list" class="product-card__variants">
51                  <div role="listitem" class="product-card__variant-container hide">
52                    <button class="promotion_added_variant btn btn--text" aria-label="Add to bag">
53                      <svg class="added-image-variant"  xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
54                        <g clip-path="url(#clip0_3339_6012)">
55                        <circle cx="7.11279" cy="7" r="6.125" fill="white"/>
56                        <path d="M5.99447 9.74507L3.29461 7.04521L4.19457 6.14526L5.99447 7.94516L9.59429 4.34535L10.4942 5.2453L5.99447 9.74507Z" fill="#333333"/>
57                        <path fill-rule="evenodd" clip-rule="evenodd" d="M0.112793 7C0.112793 3.13401 3.2468 0 7.11279 0C10.9788 0 14.1128 3.13401 14.1128 7C14.1128 10.866 10.9788 14 7.11279 14C3.2468 14 0.112793 10.866 0.112793 7ZM7.11279 12.7273C3.94971 12.7273 1.38552 10.1631 1.38552 7C1.38552 3.83691 3.94971 1.27273 7.11279 1.27273C10.2759 1.27273 12.8401 3.83691 12.8401 7C12.8401 10.1631 10.2759 12.7273 7.11279 12.7273Z" fill="#333333"/>
58                        </g>
59                        <defs>
60                        <clipPath id="clip0_3339_6012">
61                        <rect width="13.7745" height="14" fill="white" transform="translate(0.112793)"/>
62                        </clipPath>
63                        </defs>
64                      </svg>
65                      Add
66                    </button>
67                  </div>
68                  ${product.variants.map(variant=>`
69                    <div role="listitem" class="product-card__variant-container" data-show-added-btn="false" >
70                      ${variant.available?`
71                        <button class="promotion_added_variant_btn btn btn--text" style="display: none;" aria-label="{{ 'cart.general.add_to_bag' | t }}">
72                          <svg class="added-image-variant"  xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
73                            <g clip-path="url(#clip0_3339_6012)">
74                            <circle cx="7.11279" cy="7" r="6.125" fill="white"/>
75                            <path d="M5.99447 9.74507L3.29461 7.04521L4.19457 6.14526L5.99447 7.94516L9.59429 4.34535L10.4942 5.2453L5.99447 9.74507Z" fill="#333333"/>
76                            <path fill-rule="evenodd" clip-rule="evenodd" d="M0.112793 7C0.112793 3.13401 3.2468 0 7.11279 0C10.9788 0 14.1128 3.13401 14.1128 7C14.1128 10.866 10.9788 14 7.11279 14C3.2468 14 0.112793 10.866 0.112793 7ZM7.11279 12.7273C3.94971 12.7273 1.38552 10.1631 1.38552 7C1.38552 3.83691 3.94971 1.27273 7.11279 1.27273C10.2759 1.27273 12.8401 3.83691 12.8401 7C12.8401 10.1631 10.2759 12.7273 7.11279 12.7273Z" fill="#333333"/>
77                            </g>
78                            <defs>
79                            <clipPath id="clip0_3339_6012">
80                            <rect width="13.7745" height="14" fill="white" transform="translate(0.112793)"/>
81                            </clipPath>
82                            </defs>
83                          </svg>
84                          Add
85                        </button>
86                        <button class="add-product-variant btn btn--text " data-variant-id="${variant.id}"  data-variant-feature-image="${product.featured_image}" >
87                          ${variant.title}
88                        </button>
89                      `:""}
90                    </div>
91                  `).join(" ")}
92                  <div role="listitem" class="product-card__variant-container">
93                    <button type="button" class="close-show-variants" aria-label="Close variants">
94                      <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">
95                        <path d="M8.36702 4.53952C8.58739 4.33412 8.59953 3.98898 8.39414 3.7686C8.18875 3.54823 7.8436 3.53609 7.62323 3.74148L6.02716 5.22906L4.53958 3.63299C4.33419 3.41262 3.98904 3.40048 3.76866 3.60587C3.54829 3.81126 3.53615 4.15641 3.74154 4.37678L5.22912 5.97285L3.633
9505 7.46043C3.41268 7.66582 3.40054 8.01097 3.60593 8.23134C3.81132 8.45171 4.15647 8.46386 4.37684 8.25846L5.97291 6.77088L7.46049 8.36695C7.66588 8.58733 8.01103 8.59947 8.2314 8.39408C8.45177 8.18869 8.46392 7.84354 8.25852 7.62317L6.77095 6.0271L8.36702 4.53952Z" fill="#333333"/>
96                        <path fill-rule="evenodd" clip-rule="evenodd" d="M6.10352e-05 6C6.10352e-05 2.68629 2.68635 0 6.00006 0C9.31377 0 12.0001 2.68629 12.0001 6C12.0001 9.31371 9.31377 12 6.00006 12C2.68635 12 6.10352e-05 9.31371 6.10352e-05 6ZM6.00006 10.9091C3.28885 10.9091 1.09097 8.71122 1.09097 6C1.09097 3.28878 3.28885 1.09091 6.00006 1.09091C8.71128 1.09091 10.9092 3.28878 10.9092 6C10.9092 8.71122 8.71128 10.9091 6.00006 10.9091Z" fill="#333333"/>
97                      </svg>
98                    </button>
99                  </div>
100                </div>
101              `:`<button  class="promotion_add" aria-label="Add to bag"
102                  data-upsell-product-id='${product.variants[0].id}'
103                  data-upsell-product-feature-image="${product.featured_image}"
104                  data-upsell-product-url="${product.url}"
105                  data-upsell-product-vendor="${product.vendor}"
106                  data-upsell-product-price="${product.price}"
107                  data-upsell-product-compare-price="${product.compare_at_price}"
108                  >
109                  <svg class="added-image" style="display:none;" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
110                    <g clip-path="url(#clip0_3339_6012)">
111                    <circle cx="7.11279" cy="7" r="6.125" fill="white"/>
112                    <path d="M5.99447 9.74507L3.29461 7.04521L4.19457 6.14526L5.99447 7.94516L9.59429 4.34535L10.4942 5.2453L5.99447 9.74507Z" fill="#333333"/>
113                    <path fill-rule="evenodd" clip-rule="evenodd" d="M0.112793 7C0.112793 3.13401 3.2468 0 7.11279 0C10.9788 0 14.1128 3.13401 14.1128 7C14.1128 10.866 10.9788 14 7.11279 14C3.2468 14 0.112793 10.866 0.112793 7ZM7.11279 12.7273C3.94971 12.7273 1.38552 10.1631 1.38552 7C1.38552 3.83691 3.94971 1.27273 7.11279 1.27273C10.2759 1.27273 12.8401 3.83691 12.8401 7C12.8401 10.1631 10.2759 12.7273 7.11279 12.7273Z" fill="#333333"/>
114                    </g>
115                    <defs>
116                    <clipPath id="clip0_3339_6012">
117                    <rect width="13.7745" height="14" fill="white" transform="translate(0.112793)"/>
118                    </clipPath>
119                    </defs>
120                  </svg>
121                  Add
122                </button>`}
123              <input type="hidden" class="id" value="${product.variants[0].id}">
124              <input type="hidden" class="image" value="${product.featured_image}">
125              <input type="hidden" class="vendor" value="${product.vendor}">
126              <input type="hidden" class="price" value="${product.price}">
127              <input type="hidden" class="url" value="${product.url}">
128              <input type="hidden" class="compare_price" value="${product.compare_at_price}">
129            </div>
130          </div>`}),promotionProducts.innerHTML=recommendationsHtml;const wrongCurrencyVariantIds=productsNotInCart.filter(product=>(product.currency?product.currency.code:product.price_currency)!==Shopify.currency.active).map(product=>product.variants[0].id);wrongCurrencyVariantIds.length&&typeof window.getProductPrices=="function"&&(console.log("Fixing cart recommendations currency"),window.getProductPrices(wrongCurrencyVariantIds)),initPromotionSlider()}if(result&&result.items&&result.items.find(item=>item.price_currency!==Shopify.currency.active)&&typeof window.getProductPrices=="function"){console.log("XGen results not in currency "+Shopify.currency.active+". Fetching product prices.");const variantIds=[];result.items.forEach(item=>{const product=window.xgenCommon.unifyProduct(item);
130product.variants&&product.variants.forEach(v=>{v.id&&variantIds.push(v.id.toString().replace("gid://shopify/ProductVariant/",""))})}),variantIds.length&&window.getProductPrices([...new Set(variantIds)])}}})}class ProductCardSlider extends HTMLElement{constructor(){super(),this._initialized=!1}connectedCallback(){this.setupObserver()}setupObserver(){new IntersectionObserver((entries,obs)=>{entries.forEach(entry=>{entry.isIntersecting&&!this._initialized&&(this.initSlider(),this._initialized=!0,obs.unobserve(this))})},{rootMargin:"50px"}).observe(this)}async initSlider(){const swiperEl=this.querySelector(".swiper");swiperEl&&new Swiper(swiperEl,{slidesPerView:1,loop:!0,roundLengths:!0,pagination:{el:swiperEl.querySelector(".swiper-pagination")},preloadImages:!1,lazy:!0,watchSlidesProgress:!0,observer:!0,observeParents:!0})}}customElements.define("product-card-slider",ProductCardSlider);
131//# sourceMappingURL=/cdn/shop/t/811/assets/component-added-to-cart.js.map?v=80125658308530081831789977862

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.