One-Shoulder Shirring Crop Top CF513
6 reviews
€46,00€23,00
[FLASH SALE] Up to 60% Off! Prices as Marked
View all
REVIEW
`); productElement.querySelector(".info-container .compare-container").insertAdjacentHTML('afterend', `
Blow out ${save}% OFF!
`); // Add badge if the discount is equal to or greater than threshold if (save >= prcct_upsell) { productElement.querySelector(".image-wrapper .fs-badges-wrapper").insertAdjacentHTML('beforeend', `
${save}% OFF
`); } }}// Function to remove promo tag containerfunction removePromo(productElement) { const container = productElement.querySelector(".my-promo-tags"); if (container) { container.remove(); }}// Function to remove promotion textfunction removeprm(productElement) { const prmcards = productElement.querySelector('.my-promo-text'); if (prmcards) { prmcards.remove(); }}// Function to add promotion textfunction addprm(productElement, data) { console.log("Entire Data Object:", data); const attributes = data?.attributes; const vendor = data?.vendor; // Get vendor if it exists console.log("Attributes:", attributes); console.log("Vendor:", vendor); if (attributes != null) { const prmcard = attributes.find(obj => obj[0] === 'My fields.promotion')?.[1]; if (prmcard != null && prmcard[0] != null) { const infoContainer = productElement.querySelector(".info-container"); if (infoContainer) { infoContainer.insertAdjacentHTML('beforeend', `
${vendor}
${prmcard[0]}
`); } else { console.warn("info-container not found for productElement:", productElement); } } else { console.warn("No promotion card found in attributes."); } } else { console.warn("data.attributes is null or undefined."); }}// Function to move badgefunction moveBadge(productElement) { let shipdata = productElement.querySelector('.text-badge.fs-text-badge-fastship'); if (shipdata) { const shipdatabx = shipdata.parentElement; shipdatabx.appendChild(shipdata); }}// Function to add promo badge based on tagsfunction addPromoBadge(productElement, tag) { let badgesWrapper = productElement.querySelector('.fs-badges-wrapper'); // Create badgesWrapper if it doesn't exist if (!badgesWrapper) { productElement.querySelector(".image-wrapper")?.insertAdjacentHTML('beforeend', `
`); badgesWrapper = productElement.querySelector('.fs-badges-wrapper'); // console.log("Created new badges wrapper for product element:", productElement); } const existingBadge = Array.from(badgesWrapper.querySelectorAll('.text-badge.ico_badges')) .find(badge => badge.textContent.trim().toLowerCase() === tag.trim().toLowerCase()); // Add new badge if it doesn't already exist if (!existingBadge) { const badge = document.createElement('div'); if (tag === 'fastship') { badge.className = 'text-badge fastship_badge'; badge.textContent = '⚡FASTSHIP'; } else if (tag === 'new') { badge.className = 'text-badge new_badge'; badge.textContent = tag; } else { badge.className = 'text-badge ico_badges'; badge.textContent = tag; } badgesWrapper.appendChild(badge); console.log(`Added Badge: ${tag} for product element.`); }}// Event listener for DOM content loadeddocument.addEventListener('DOMContentLoaded', function() { if (window.FastRecommendationWidget) { RChooks(); } else { console.log("Waiting for FastRecommendationWidget to load..."); window.addEventListener('fast-upsell-cross-sell-ready', function() { RChooks(); }); }});// Main hook function for upsell and cross-sell productsfunction RChooks() { FastRecommendationWidget.registerHook("upsell-cross-sell-products", ({ element, products }) => { const productElements = [...element.querySelectorAll(".fs-upsell-cross-sell-product")]; let allPromosInserted = true; productElements.forEach(productElement => { const productID = productElement.dataset.id; const data = products[productID]; if (!data) { allPromosInserted = false; return; } var tags = []; var tagAttribute = data.attributes.forEach(function(attributeArray) { // "Tag"라는 항목을 찾기 if (attributeArray[0] === "Tag") { tags = attributeArray[1]; // 두 번째 요소가 배열이므로 해당 값을 tags에 저장 } }); if (tagAttribute) { tags = tagAttribute[1]; // 두 번째 요소인 배열을 tags에 저장 } // console.log("Tags for Product ID:", productID, ":sg", tags); const selectedTags = tags.filter(tag => tag.startsWith("ico_") || tag === "fastship"); selectedTags.forEach(tag => { const cleanTag = tag.startsWith("ico_") ? tag.replace("ico_", "") : tag; addPromoBadge(productElement, cleanTag); // productElement와 태그를 전달하여 배지 추가 }); let promoText = null; if (data.attributes) { const promotionField = data.attributes.find(attr => attr[0] === 'My fields.promotion'); if (promotionField && promotionField[1]) { promoText = promotionField[1][0]; } } if (promoText) { const infoContainer = productElement.querySelector(".info-container"); if (infoContainer) { infoContainer.insertAdjacentHTML('beforeend', `
${promoText}
`); } else { allPromosInserted = false; } } else { allPromosInserted = false; } // Check for price and add label if (parseFloat(data.comparePrice) > 0 && parseFloat(data.comparePrice) > parseFloat(data.price)) { addLabel(productElement, data); } moveBadge(productElement); var $isBeauty = Getattributevalue(data.attributes,"My fields.isbeauty"); var $vendor = Getattributevalue(data.attributes,"Vendor"); // Add vendor element if beauty product if ($isBeauty && $isBeauty.toLowerCase() === "true") { console.log("beauty product - add vendor element"); var vendorelement = `
${$vendor}
`; if (productElement.querySelectorAll(`.cstm-vendor`).length === 0) { productElement.querySelector(".info-container").insertAdjacentHTML('beforebegin', vendorelement); } } }); if (allPromosInserted) { console.log("Promotion Success!!"); } else { console.warn("Promotion failed"); } });}