document.addEventListener('DOMContentLoaded', function() { // Flags to track state let fileUploaded = false; let cartAdded = false; /* 1. Mark file upload */ window.addEventListener('upload:added', function(e) { const file = e.detail; if (file && file.url) { fileUploaded = true; console.log("File uploaded marked."); } }); /* 2. Mark when the add-to-cart action happens */ // Option A: Listen for add-to-cart button click const addToCartButton = document.getElementById('ProductSubmitButton-template--19428473110575__main'); if (addToCartButton) { addToCartButton.addEventListener('click', function() { cartAdded = true; console.log("Add-to-cart button clicked."); }); } else { // Option B: Use a MutationObserver to detect changes in the cart count const cartCount = document.querySelector('.cart-count-bubble span[aria-hidden="true"]'); if (cartCount) { const cartObserver = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { if (mutation.type === 'childList' || mutation.type === 'characterData') { cartAdded = true; console.log("Cart item added (mutation detected)."); break; } } }); cartObserver.observe(cartCount, { childList: true, characterData: true, subtree: true }); } } /* 3. Monitor the Supercart drawer for visibility changes */ const body = document.body; const observer = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { if (mutation.type === 'attributes' && mutation.attributeName === 'class') { const isCartOpen = body.classList.contains('supercart-open'); if (isCartOpen) { console.log('Supercart drawer is now visible'); } else { console.log('Supercart drawer is now hidden'); // If the drawer is hidden and both conditions are met, trigger removal if (fileUploaded && cartAdded) { const removeButton = document.querySelector('.filepond--file-action-button.filepond--action-revert-item-processing'); if (removeButton) { removeButton.click(); // Emulate a click to remove the file console.log("Remove button clicked."); // Display green success alert below .product-form__buttons for 3 seconds, then fade out const productFormButtons = document.querySelector('.product-form__buttons'); if (productFormButtons) { const alertDiv = document.createElement('div'); alertDiv.style.cssText = ` background-color: #d4edda; color: #155724; padding: 15px 20px; border: 1px solid #c3e6cb; border-radius: 4px; margin-top: 10px; width: 100%; text-align: center; z-index: 9999; `; alertDiv.textContent = '✓ Your image has been added to the cart'; productFormButtons.insertAdjacentElement('afterend', alertDiv); // Fade out after 3 seconds setTimeout(() => { alertDiv.style.transition = 'opacity 1s'; alertDiv.style.opacity = '0'; setTimeout(() => alertDiv.remove(), 1000); }, 3000); } // Reset flags after the removal action fileUploaded = false; cartAdded = false; } } } } } }); // Observe changes to the 'class' attribute of the body observer.observe(body, { attributes: true, attributeFilter: ['class'] }); }); html .product-form__submit { color: var(--md-sys-color-primary); border: 1px solid var(--md-sys-color-primary); font-size: 25px; background-color:transparent; } html .product-form__submit:hover { border: 2px solid var(--md-sys-color-primary); background-color:transparent; box-shadow:none; } Product Details Utilizing premium-grade inks, superior film, and adhesive, we ensure optimal color vibrancy and the purest whites across all fabric types, regardless of material, hue, or elasticity. Utilizing advanced processing techniques and premium materials, we guarantee enhanced durability, resilience, and resistance to rigorous washing conditions. Each order undergoes a meticulous review by our expert designers to ensure optimal print quality. Should you have specific requirements or need assistance kindly indicate this during checkout. We are committed to excellence; every order comes with a 100% satisfaction guarantee. In the unlikely event of dissatisfaction, we pledge to redo your order at no additional cost. Design Requirements For optimal results, we recommend using vector art. However, if providing raster art, please ensure it has a resolution of at least 300 dpi. Preferred file formats include AI, PNG, and PDF. What kind of press do I need? Any standard heat press is suitable for the task. For best results, we advise setting your heat press to 150 degrees Celcius with a duration of 8 seconds, applying medium pressure. Alternatively, an iron or a Cricut machine may also be used to press your transfers. How do transfers hold up in the wash? We've put our transfers to the test on various garments through both wash and dry cycles. Good news: the ink stays put and won't smudge onto your clothes. Even better? Our transfers have consistently held up through 65 normal everyday washes before showing any signs of wear. Shipping Info We pride ourselves on prompt shipping. Most orders are dispatched either on the same or the following business day but may take up to 2 business days. For those in a hurry, expedited shipping options are available during checkout.