SIGNAL RELIEF | 20% OFF Signal Relief Patches
- Shop
- About Us
- How It Works
- Patch Placement
- Rewards
- Reviews
Cart
'; document.body.appendChild(banner); } } }
Regular price $179.95 Sale price$144.00
/
20% OFF - Limited time only!
*Select discount codes not active during sale*
The single patch that provides 1 entire year of relief!
Reduce the impact of pain and get back to the life you love! The Signal Relief patch (4.5") contains microscopic particles that are arranged in an array and act as an antenna to divert signals of pain. One Signal Relief patchprovides reusable drug-free relief for back aches, shoulder aches, hip soreness, and larger areas of general and ongoing discomfort forat least one full year, guaranteed.
Benefits:
- Reusable, drug-free relief
- Alleviates pain in seconds
- Works on musculoskeletal pain
- Easy to apply anywhere on the body
- 45-Day Money-Back Guarantee
- Clinically-tested for efficacy
- Reusable Signal patch with 1-year product warranty
- 3 latex-free adhesives per patch
- 1 storage case
- Placement instructions
We process and deliver orders Monday-Friday (excluding holidays). Please note, we cannot guarantee any next day fulfillment of expedited shipments when orders are placed after 3:30 PM MST. Any order placed over the weekend will be fulfilled on the next business day.
reusable RELIEF
AS EASY AS 1-2-3
1. Find the source of your discomfort.
2. Place the patch.
3. Get back to the life you love.
Patch Placement
FAQs
Our bodies rely on electrical and chemical signals running through the nervous system for everything. When you get injured or experience pain of any kind, extra energy is created at the source – similar to how a radio creates static.This extra energy creates a pain cycle that runs in a constant loop between the source of pain and the brain.The microscopic components within the Signal Relief patch work like an antenna to interrupt the pain signal and allow your body to more readily return to a balanced state.
The Signal Relief Patch is built to last over a year, as long as you take good care of it and keep it clean! If treated properly, the technology inside the layers of the patch can last for years. We offer a one year warranty if for some reason your patch needs to be replaced.
Since there is no medication in the patch and nothing going into your body, there is no limit to how long you can wear the patch! Some people prefer to keep it on for only a few hours at a time, while others will wear it for days on end.
PATENTED TECHNOLOGY
REINVENTING RELIEF.
Think you've tried everything for relief? Think again! Signal Relief offers lasting relief with a one-time purchase. Put our technology to the test for 45 days and feel better or your money back!
KEEP YOUR PATCH IN PLACE
LATEX-FREE ADHESIVES
Every Signal Relief Patch purchase comes with a FREE pack of super sticky, latex-free adhesives you can use to keep your patch in place wherever you choose to wear it.
Customer Reviews
Signal Relief and JOVI are general wellness products intended to help promote physical activity and a healthy lifestyle. Signal does not claim to treat, cure or diagnose disease. If you have concerns about your personal health conditions, please consult your physician. The Signal Relief patch is not intended to be cut or altered in any way. Not intended for internal use.
× Shop with confidence, knowing your purchases are protected every step of the way. Free Returns & Purchase Protection Enjoy hassle-free returns and exchanges within our designated return window. If you’re not completely satisfied, we’ve got you covered. Shipping Protection Rest easy! Your package is protected during transit against loss, theft, or damage. We’ve got you covered.Checkout with confidence
${widgetSettings.title || "Default Title"} ${variantPriceText} ${ widgetSettings.showLearnMore === "true" ? '' + 'i' + 'Highly recommended - secure your items from loss, theft, or damage during transit.' + '' : "" }
${ widgetSettings.description || "" }
${widgetRightContent}
`; const targetSelectorQuick = widgetSettings.targetSelectorQuick; const injectionLocationQuick = widgetSettings.injectionLocationQuick; // Function to insert widget HTML into a target element const insertWidget = (targetSelector, location = "beforebegin") => { const targetElement = document.querySelector(targetSelector); if (targetElement) { targetElement.insertAdjacentHTML(location, widgetHTML); console.log(`Widget injected ${location} ${targetSelector}.`); applyUpdatedStyles(uniqueId); const savedState = localStorage.getItem("widgetToggleState") === "true"; // Correctly target the input using its ID const toggleButton = document.getElementById("brella-protect-toggle-button-embed"); // Ensure the element exists before trying to add event listeners if (toggleButton) { // Restore the saved state if (savedState !== null) { console.log('savedState', savedState); toggleButton.checked = savedState; } else { console.log('widgetSettings.toggleStatus', widgetSettings.toggleStatus); toggleButton.checked = widgetSettings.toggleStatus === "true"; } // Add the "change" event listener toggleButton.addEventListener("change", function () { const isChecked = this.checked; // Use 'this' since it refers to the toggleButton console.log(`Toggle state changed: ${isChecked}`); // Debugging log localStorage.setItem("widgetToggleState", isChecked); updateAllWidgets(isChecked); //addAttribute(isChecked); }); } else { console.warn('Toggle button not found in the DOM.'); } } else { console.warn(`${targetSelector} container not found.`); } }; insertWidget(targetSelectorQuick, injectionLocationQuick); var modal = document.getElementById("brella-protect-modal"); var closeBtn = document.querySelector(".brella-close"); // Open modal when trigger is clicked var modalTrigger = document.getElementById("brella-protect-learn-more-embed"); if (modalTrigger) { modalTrigger.addEventListener("click", function() { modal.style.display = "block"; }); } // Close modal when the close button is clicked if (closeBtn) { closeBtn.addEventListener("click", function() { modal.style.display = "none"; }); } // Close modal if clicking outside of the modal content modal.addEventListener("click", function(event) { // If the user clicked the semi-transparent overlay (the modal background), close the modal if (event.target === modal) { modal.style.display = "none"; } // Stop this click from reaching the window or document listeners event.stopPropagation(); }); } catch (error) { console.error("Error injecting widget:", error); } } async function addAttribute(isChecked) { const response = await fetch('/cart.js'); const cart = await response.json(); console.log("Setting _brellaToggle attribute in cart..."); fetch('/cart/update.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ attributes: { "_brellaToggle": isChecked } }) }) .then(() => console.log("Cart attribute _brellaToggle updated successfully")) .catch((error) => console.error("Failed to update _brellaToggle:", error)); } function updateAllWidgets(state) { console.log('state', state); const allToggles = document.querySelectorAll(".brella-protect-toggle-button-embed"); allToggles.forEach((toggle) => { toggle.checked = state; }); } async function injectWidget(shopDomain, countryCode) { try { const { adjustedCartTotal, productIds } = await fetchCartData(); const widgetSettings = await fetchWidgetSettings(shopDomain, adjustedCartTotal, productIds, countryCode); if (!widgetSettings) { console.warn("No widget settings found."); return; } const uniqueId = `widget-${Date.now()}`; const variantPriceText = !widgetSettings.checkoutPlus || widgetSettings.checkoutPlus === "false" ? `for $${widgetSettings.variantPrice}` : ""; const widgetRightContent = widgetSettings.checkoutPlus === "true" ? `
$${widgetSettings.variantPrice}
` : ` `; const widgetHTML = `
${widgetSettings.title || "Default Title"} ${variantPriceText} ${ widgetSettings.showLearnMore === "true" ? '' + 'i' + 'Highly recommended - secure your items from loss, theft, or damage during transit.' + '' : "" }
${ widgetSettings.description || "" }
${widgetRightContent}
`; // Function to insert widget HTML into a target element const insertWidget = (targetSelector, location = "beforebegin") => { const targetElement = document.querySelector(targetSelector); if (targetElement) { targetElement.insertAdjacentHTML(location, widgetHTML); console.log(`Widget injected ${location} ${targetSelector}.`); applyUpdatedStyles(uniqueId); const savedState = localStorage.getItem("widgetToggleState") === "true"; // Correctly target the input using its ID const toggleButton = document.getElementById("brella-protect-toggle-button-embed"); // Ensure the element exists before trying to add event listeners if (toggleButton) { // Restore the saved state if (savedState !== null) { console.log('savedState', savedState); toggleButton.checked = savedState; } else { console.log('widgetSettings.toggleStatus', widgetSettings.toggleStatus); toggleButton.checked = widgetSettings.toggleStatus === "true"; } // Add the "change" event listener toggleButton.addEventListener("change", function () { const isChecked = this.checked; // Use 'this' since it refers to the toggleButton console.log(`Toggle state changed: ${isChecked}`); // Debugging log localStorage.setItem("widgetToggleState", isChecked); updateAllWidgets(isChecked); addAttribute(isChecked); }); } else { console.warn('Toggle button not found in the DOM.'); } } else { console.warn(`${targetSelector} container not found.`); } }; const targetSelector = widgetSettings.targetSelector; const injectionLocation = widgetSettings.injectionLocation; insertWidget(targetSelector, injectionLocation); var modal = document.getElementById("brella-protect-modal"); var closeBtn = document.querySelector(".brella-close"); // Open modal when trigger is clicked var modalTrigger = document.getElementById("brella-protect-learn-more-embed"); if (modalTrigger) { modalTrigger.addEventListener("click", function() { modal.style.display = "block"; }); } // Close modal when the close button is clicked if (closeBtn) { closeBtn.addEventListener("click", function() { modal.style.display = "none"; }); } // Close modal if clicking outside of the modal content modal.addEventListener("click", function(event) { // If the user clicked the semi-transparent overlay (the modal background), close the modal if (event.target === modal) { modal.style.display = "none"; } // Stop this click from reaching the window or document listeners event.stopPropagation(); }); } catch (error) { console.error("Error injecting widget:", error); } } let observerAttached = false; function debounceBrella(func, delay) { let timeout; return function (...args) { clearTimeout(timeout); timeout = setTimeout(() => func.apply(this, args), delay); }; } function observeCartDrawer(callback) { if (observerAttached) { console.warn("Cart Drawer observer is already attached. Skipping..."); return; } observerAttached = true; const cartDrawerSelector = widgetSettings.cartDrawerSelector || "#CartDrawerUpdateMe"; const cartDrawerOpenClass = widgetSettings.cartDrawerOpenClass || "drawer--is-open-update-me"; const cartDrawer = document.querySelector(cartDrawerSelector); if (!cartDrawer) { console.warn(`Cart Drawer not found using selector: ${cartDrawerSelector}`); return; } let observer = new MutationObserver(debounceBrella((mutations) => { mutations.forEach((mutation) => { if (mutation.attributeName === "class") { if (cartDrawer.classList.contains(cartDrawerOpenClass)) { console.log("Cart Drawer is open, injecting widget..."); callback(cartDrawer); } } }); }, 1000)); // Wait 1s to avoid duplicate triggers observer.observe(cartDrawer, { attributes: true }); console.log(`Observing Cart Drawer using selector: ${cartDrawerSelector} and open class: ${cartDrawerOpenClass}`); } function attachModalListeners() { var modal = document.getElementById("brella-protect-modal"); var modalTrigger = document.getElementById("brella-protect-learn-more-embed"); var closeBtn = document.querySelector(".brella-close"); if (modalTrigger) { modalTrigger.addEventListener("click", function() { modal.style.display = "block"; }); console.log("Reattached event listener to modal trigger."); } if (closeBtn) { closeBtn.addEventListener("click", function() { modal.style.display = "none"; }); } modal.addEventListener("click", function(event) { // If the user clicked the semi-transparent overlay (the modal background), close the modal if (event.target === modal) { modal.style.display = "none"; } // Stop this click from reaching the window or document listeners event.stopPropagation(); }); } async function updateWidgetPrice(widgetSettings) { const widgetPriceElement = document.querySelector("#brella-protect-widget-title-embed"); if (widgetPriceElement && widgetSettings.variantPrice) { const variantPriceText = !widgetSettings.checkoutPlus || widgetSettings.checkoutPlus === "false" ? `for $${widgetSettings.variantPrice}` : ""; widgetPriceElement.innerHTML = `${widgetSettings.title || "Default Title"} ${variantPriceText} ${ widgetSettings.showLearnMore === "true" ? '' + 'i' + 'Highly recommended - secure your items from loss, theft, or damage during transit.' + '' : "" }`; console.log("Widget price updated in DOM."); } attachModalListeners(); if (widgetSettings.checkoutPlus === "true") { const response = await fetch('/cart.js'); if (!response.ok) throw new Error("Failed to fetch cart data"); const cart = await response.json(); const cartTotal = cart.total_price / 100 || 0; // Convert from cents to dollars const variantPrice = widgetSettings.variantPrice ? parseFloat(widgetSettings.variantPrice) : 0; const totalPrice = (cartTotal + variantPrice).toFixed(2); console.log(`Cart Total: $${cartTotal}, Variant Price: $${variantPrice}, New Total: $${widgetSettings.variantPrice}`); const widgetPriceEmbed = document.querySelector(".brella-protect-price-embed"); if (widgetPriceEmbed) { widgetPriceEmbed.innerHTML = `$${widgetSettings.variantPrice}`; console.log("Widget price updated."); } if (widgetSettings && widgetSettings.checkoutButtonSelector && widgetSettings.checkoutButtonSelector.trim() !== "") { const checkoutBtn = document.querySelector(widgetSettings.checkoutButtonSelector); console.log('checkoutBtn', checkoutBtn); if (checkoutBtn) { console.log('checkoutBtn found: ', checkoutBtn); if (widgetSettings.variantPrice) { checkoutBtn.textContent = `Checkout+`; // Clone the button and insert below the original with a different text const parentWrapper = checkoutBtn.closest("div, form"); if (parentWrapper) { const existingClonedButton = parentWrapper.parentNode.querySelector('[data-brella-cloned="true"]'); if (!existingClonedButton) { const clonedWrapper = parentWrapper.cloneNode(true); // Clone the parent div const clonedButton = clonedWrapper.querySelector("button"); // Select the cloned button clonedButton.textContent = "Checkout Without Package Protection"; // Remove inherited classes from the cloned button clonedButton.removeAttribute("class"); const bgColor = getEffectiveBackgroundColor(parentWrapper); console.log("Detected background color:", bgColor); // Set text color based on background brightness if (bgColor === "rgb(0, 0, 0)" || bgColor.includes("0, 0, 0")) { clonedButton.style.color = "#ffffff"; // Set to white if background is dark } else { clonedButton.style.color = "#000000"; // Otherwise, set to black } // Apply styles to make it look like a plain text link clonedButton.style.display = "block"; // Stack it clonedButton.style.textDecoration = "underline"; // Underline effect clonedButton.style.cursor = "pointer"; // Keep it clickable clonedButton.style.background = "transparent"; // Remove background clonedButton.style.fontWeight = "normal"; // Reset font weight clonedButton.style.fontSize = "small"; // Match surrounding text clonedButton.style.textAlign = "center"; // Center align clonedButton.style.width = "100%"; // Ensure full width clonedButton.style.marginTop = "10px"; // Add spacing clonedButton.style.border = "none"; // Add spacing clonedButton.setAttribute('data-brella-cloned', 'true'); // Insert the cloned wrapper after the original parentWrapper.insertAdjacentElement("afterend", clonedWrapper); // Prevent cloned button from adding an item to the cart clonedButton.addEventListener("click", (event) => { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(false); } console.log("Cloned button pressed: Checkout without protection."); event.stopPropagation(); // Stop any unwanted event propagation }); checkoutBtn.addEventListener('click', async (event) => { console.log('checkoutBtn pressed:', checkoutBtn); const checkbox = document.getElementById("brella-protect-toggle-button-embed"); try { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(true); } else { await addItemToCart(widgetSettings.variantId); } console.log('Item added to cart from checkoutBtn'); } catch (error) { console.error("Error adding item to cart:", error); } }); } } else { console.error("Parent wrapper not found!"); } } } } // Handle second checkout button if it exists if (widgetSettings && widgetSettings.checkoutButtonSelectorTwo && widgetSettings.checkoutButtonSelectorTwo.trim() !== "") { const checkoutBtnTwo = document.querySelector(widgetSettings.checkoutButtonSelectorTwo); console.log('checkoutBtnTwo', checkoutBtnTwo); if (checkoutBtnTwo) { console.log('checkoutBtnTwo found: ', checkoutBtnTwo); if (widgetSettings.variantPrice) { checkoutBtnTwo.textContent = `Checkout+`; // Clone the button and insert below the original with a different text const parentWrapper = checkoutBtnTwo.closest("div, form"); if (parentWrapper) { const existingClonedButton = parentWrapper.parentNode.querySelector('[data-brella-cloned="true"]'); if (!existingClonedButton) { const clonedWrapper = parentWrapper.cloneNode(true); // Clone the parent div const clonedButton = clonedWrapper.querySelector("button"); // Select the cloned button clonedButton.textContent = "Checkout Without Package Protection"; // Remove inherited classes from the cloned button clonedButton.removeAttribute("class"); const bgColor = getEffectiveBackgroundColor(parentWrapper); console.log("Detected background color:", bgColor); // Set text color based on background brightness if (bgColor === "rgb(0, 0, 0)" || bgColor.includes("0, 0, 0")) { clonedButton.style.color = "#ffffff"; // Set to white if background is dark } else { clonedButton.style.color = "#000000"; // Otherwise, set to black } // Apply styles to make it look like a plain text link clonedButton.style.display = "block"; // Stack it clonedButton.style.textDecoration = "underline"; // Underline effect clonedButton.style.cursor = "pointer"; // Keep it clickable clonedButton.style.background = "transparent"; // Remove background clonedButton.style.fontWeight = "normal"; // Reset font weight clonedButton.style.fontSize = "small"; // Match surrounding text clonedButton.style.textAlign = "center"; // Center align clonedButton.style.width = "100%"; // Ensure full width clonedButton.style.marginTop = "10px"; // Add spacing clonedButton.style.border = "none"; // Add spacing clonedButton.setAttribute('data-brella-cloned', 'true'); // Insert the cloned wrapper after the original parentWrapper.insertAdjacentElement("afterend", clonedWrapper); // Prevent cloned button from adding an item to the cart clonedButton.addEventListener("click", (event) => { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(false); } console.log("Cloned button pressed: Checkout without protection."); event.stopPropagation(); // Stop any unwanted event propagation }); } } else { console.error("Parent wrapper not found!"); } checkoutBtnTwo.addEventListener('click', async (event) => { console.log('checkoutBtnTwo pressed:', checkoutBtnTwo); const checkbox = document.getElementById("brella-protect-toggle-button-embed"); try { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(true); } else { await addItemToCart(widgetSettings.variantId); } console.log('Item added to cart from checkoutBtnTwo'); } catch (error) { console.error("Error adding item to cart:", error); } }); } } } } } async function attachAddToCartListener(shopDomain, countryCode) { console.log('Calling attach'); const addToCartButtonSelector = widgetSettings.addToCartButtonSelector || "button[id^='ProductSubmitButton-template--'][id$='__main']"; const addToCartButtons = document.querySelectorAll(addToCartButtonSelector); addToCartButtons.forEach(button => { // Check if the listener is already attached if (!button.dataset.listenerAttached) { button.addEventListener('click', () => { console.log('"Add to Cart" button clicked. Attempting to inject widget after a delay. ', widgetInjected); if (!widgetInjected) { setTimeout(() => { injectWidgetQuick(shopDomain, countryCode); widgetInjected = true; console.log('Widget injected after delay.'); }, 1500); // Delay of 1 second (1000 milliseconds) } else { console.log('Widget already injected. No action taken.'); } }); // Mark the button as having the listener attached button.dataset.listenerAttached = 'true'; console.log('"Add to Cart" button listener attached.'); } else { console.log('"Add to Cart" button already has a listener attached.'); } }); if (addToCartButtons.length === 0) { console.warn('No "Add to Cart" buttons found to attach listeners.'); } } async function main(shopDomain, countryCode) { if (isProcessing) return; isProcessing = true; const { adjustedCartTotal, productIds } = await fetchCartData(); // Fetch the updated widget settings based on the updated cart total widgetSettings = await fetchWidgetSettings(shopDomain, adjustedCartTotal, productIds, countryCode); try { await removeItemsFromCart(); } catch (error) { console.error('Error during removeItemsFromCart execution:', error); } finally { isProcessing = false; } } function applyUpdatedStyles(widgetId) { const stylesEnabled = widgetSettings.enableStyles || false; console.log('stylesEnabled', stylesEnabled); const widgetContainer = document.getElementById(widgetId); if (!widgetContainer) { console.log("Widget container not found"); return; } if (stylesEnabled) { // Apply vibrant, modern, and polished styles widgetContainer.style.display = 'flex'; widgetContainer.style.justifyContent = 'flex-end'; widgetContainer.style.alignItems = 'center'; widgetContainer.style.padding = '5px'; widgetContainer.style.borderRadius = '15px'; // Enhanced rounded corners widgetContainer.style.boxShadow = ''; widgetContainer.style.background = 'linear-gradient(145deg,rgb(236, 242, 247), #ffffff)'; widgetContainer.style.border = '1px solid #dfe3e6'; // Softer border widgetContainer.style.transition = 'all 0.3s ease-in-out'; // Smooth transitions const image = widgetContainer.querySelector('.brella-protect-widget-image-embed'); if (image) { image.style.width = '60px'; image.style.height = '60px'; } // Update the text section const textEmbed = widgetContainer.querySelector('.brella-protect-widget-text-embed'); if (textEmbed) { textEmbed.style.flexGrow = '1'; textEmbed.style.padding = '0 15px'; } const title = widgetContainer.querySelector('#brella-protect-widget-title-embed'); if (title) { title.style.fontWeight = 'bold'; title.style.fontSize = '18px'; title.style.color = '#333'; title.style.marginBottom = '5px'; } const description = widgetContainer.querySelector('#brella-protect-widget-description-embed'); if (description) { description.style.fontSize = '14px'; description.style.color = '#555'; } // Style the toggle switch const slider = widgetContainer.querySelector('.brella-protect-slider-embed'); const input = widgetContainer.querySelector('.brella-protect-switch-embed input[type="checkbox"]'); if (input && slider) { input.addEventListener('change', () => { if (input.checked) { slider.style.backgroundColor = '#2196F3'; } else { slider.style.backgroundColor = '#ccc'; } }); } } } function getEffectiveBackgroundColor(element) { while (element) { const bgColor = window.getComputedStyle(element).backgroundColor; // Check if it's a valid color (not transparent) if (bgColor !== "rgba(0, 0, 0, 0)" && bgColor !== "transparent") { return bgColor; } element = element.parentElement; // Move up the DOM } return "rgb(255, 255, 255)"; // Default to white if nothing is found } function hideProductCards(productId) { // Use the passed productId or default to "7499259641925" productId = productId || "7499259641925"; // Use href attribute so we match even if the element is added later const anchors = document.querySelectorAll(`a[href*="pr_rec_pid=${productId}"]`); anchors.forEach(anchor => { // If this anchor is inside your widget, skip it: if (anchor.closest(".brella-protect-widget-container, .brella-protect-widget-container-embed")) { return; } const productCard = anchor.closest('.card-wrapper.product-card-wrapper'); if (productCard && productCard.style.display !== "none") { productCard.style.display = "none"; console.log(`Hiding product card for product id ${productId}`); } }); } document.addEventListener("DOMContentLoaded", async () => { const shopDomain = window.Shopify?.shop; const countryCode = window.Shopify?.country; console.log(countryCode); await main(shopDomain, countryCode); const enableEmbed = widgetSettings?.enableEmbed; setInterval(() => hideProductCards(widgetSettings?.productId), 1000); if (enableEmbed) { observeCartDrawer(() => { injectWidgetQuick(window.Shopify?.shop, countryCode); }); if (!window.originalFetch) { const originalFetch = window.fetch; window.fetch = async (...args) => { const [url, options] = args; // Handle /cart/change.js requests if (url.includes("/cart/change")) { try { // Proceed with the original /cart/change.js call const response = await originalFetch(...args); // Fetch the updated cart data after the /cart/change.js call completes const { adjustedCartTotal, productIds } = await fetchCartData(); // Fetch the updated widget settings based on the updated cart total widgetSettings = await fetchWidgetSettings(shopDomain, adjustedCartTotal, productIds, countryCode); // Update the widget price in the DOM if (widgetSettings) { await updateWidgetPrice(widgetSettings); } // Return the original response to maintain normal behavior return response; } catch (error) { console.error("Error handling /cart/change.js request:", error); } } // Handle /cart/add.js requests if (url.includes("/cart/add")) { try { // Proceed with the original /cart/add.js call const response = await originalFetch(...args); // Fetch the updated cart data after the /cart/add.js call completes const { adjustedCartTotal, productIds } = await fetchCartData(); // Fetch the updated widget settings based on the updated cart total widgetSettings = await fetchWidgetSettings(shopDomain, adjustedCartTotal, productIds, countryCode); // Update the widget price in the DOM if (widgetSettings) { await updateWidgetPrice(widgetSettings); } // Return the original response to maintain normal behavior return response; } catch (error) { console.error("Error handling /cart/add.js request:", error); } } // If not /cart/change.js or /cart/add.js, proceed with the original fetch call return originalFetch(...args); }; // Store the original fetch in case you need it later window.originalFetch = originalFetch; } else { console.warn("Fetch is already overridden. Skipping override."); } if (widgetSettings && widgetSettings.checkoutPlus === "true") { const response = await fetch('/cart.js'); if (!response.ok) throw new Error("Failed to fetch cart data"); const cart = await response.json(); const cartTotal = cart.total_price / 100 || 0; // Convert from cents to dollars const variantPrice = widgetSettings.variantPrice ? parseFloat(widgetSettings.variantPrice) : 0; const totalPrice = (cartTotal + variantPrice).toFixed(2); console.log(`Cart Total: $${totalPrice}`); if (widgetSettings.checkoutButtonSelector && widgetSettings.checkoutButtonSelector.trim() !== "") { const checkoutBtn = document.querySelector(widgetSettings.checkoutButtonSelector); console.log('checkoutBtn', checkoutBtn); if (checkoutBtn) { console.log('checkoutBtn found: ', checkoutBtn); if (widgetSettings.variantPrice) { checkoutBtn.textContent = `Checkout+`; // Clone the button and insert below the original with a different text const parentWrapper = checkoutBtn.closest("div, form"); if (parentWrapper) { const existingClonedButton = parentWrapper.parentNode.querySelector('[data-brella-cloned="true"]'); if (!existingClonedButton) { const clonedWrapper = parentWrapper.cloneNode(true); // Clone the parent div const clonedButton = clonedWrapper.querySelector("button"); // Select the cloned button clonedButton.textContent = "Checkout Without Package Protection"; // Remove inherited classes from the cloned button clonedButton.removeAttribute("class"); const bgColor = getEffectiveBackgroundColor(parentWrapper); console.log("Detected background color:", bgColor); // Set text color based on background brightness if (bgColor === "rgb(0, 0, 0)" || bgColor.includes("0, 0, 0")) { clonedButton.style.color = "#ffffff"; // Set to white if background is dark } else { clonedButton.style.color = "#000000"; // Otherwise, set to black } // Apply styles to make it look like a plain text link clonedButton.style.display = "block"; // Stack it clonedButton.style.textDecoration = "underline"; // Underline effect clonedButton.style.cursor = "pointer"; // Keep it clickable clonedButton.style.background = "transparent"; // Remove background clonedButton.style.fontWeight = "normal"; // Reset font weight clonedButton.style.fontSize = "small"; // Match surrounding text clonedButton.style.textAlign = "center"; // Center align clonedButton.style.width = "100%"; // Ensure full width clonedButton.style.marginTop = "10px"; // Add spacing clonedButton.style.border = "none"; // Add spacing clonedButton.setAttribute('data-brella-cloned', 'true'); // Insert the cloned wrapper after the original parentWrapper.insertAdjacentElement("afterend", clonedWrapper); // Prevent cloned button from adding an item to the cart clonedButton.addEventListener("click", (event) => { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(false); } console.log("Cloned button pressed: Checkout without protection."); event.stopPropagation(); // Stop any unwanted event propagation }); } } else { console.error("Parent wrapper not found!"); } // Add event listener for the original checkout button to add an item if conditions are met checkoutBtn.addEventListener('click', async (event) => { console.log('checkoutBtn pressed:', checkoutBtn); try { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(true); } else { await addItemToCart(widgetSettings.variantId); } console.log('Item added to cart from checkoutBtn'); } catch (error) { console.error("Error adding item to cart:", error); } }); } } } // Handle second checkout button if it exists if (widgetSettings.checkoutButtonSelectorTwo && widgetSettings.checkoutButtonSelectorTwo.trim() !== "") { const checkoutBtnTwo = document.querySelector(widgetSettings.checkoutButtonSelectorTwo); console.log('checkoutBtnTwo', checkoutBtnTwo); if (checkoutBtnTwo) { console.log('checkoutBtnTwo found: ', checkoutBtnTwo); if (widgetSettings.variantPrice) { checkoutBtnTwo.textContent = `Checkout+`; // Clone the button and insert below the original with a different text const parentWrapper = checkoutBtnTwo.closest("div, form"); if (parentWrapper) { const existingClonedButton = parentWrapper.parentNode.querySelector('[data-brella-cloned="true"]'); if (!existingClonedButton) { const clonedWrapper = parentWrapper.cloneNode(true); // Clone the parent div const clonedButton = clonedWrapper.querySelector("button"); // Select the cloned button clonedButton.textContent = "Checkout Without Package Protection"; // Remove inherited classes from the cloned button clonedButton.removeAttribute("class"); const bgColor = getEffectiveBackgroundColor(parentWrapper); console.log("Detected background color:", bgColor); // Set text color based on background brightness if (bgColor === "rgb(0, 0, 0)" || bgColor.includes("0, 0, 0")) { clonedButton.style.color = "#ffffff"; // Set to white if background is dark } else { clonedButton.style.color = "#000000"; // Otherwise, set to black } // Apply styles to make it look like a plain text link clonedButton.style.display = "block"; // Stack it clonedButton.style.textDecoration = "underline"; // Underline effect clonedButton.style.cursor = "pointer"; // Keep it clickable clonedButton.style.background = "transparent"; // Remove background clonedButton.style.fontWeight = "normal"; // Reset font weight clonedButton.style.fontSize = "small"; // Match surrounding text clonedButton.style.textAlign = "center"; // Center align clonedButton.style.width = "100%"; // Ensure full width clonedButton.style.marginTop = "10px"; // Add spacing clonedButton.style.border = "none"; // Add spacing clonedButton.setAttribute('data-brella-cloned', 'true'); // Insert the cloned wrapper after the original parentWrapper.insertAdjacentElement("afterend", clonedWrapper); // Prevent cloned button from adding an item to the cart clonedButton.addEventListener("click", (event) => { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(false); } console.log("Cloned button pressed: Checkout without protection."); event.stopPropagation(); // Stop any unwanted event propagation }); } } else { console.error("Parent wrapper not found!"); } checkoutBtnTwo.addEventListener('click', async (event) => { console.log('checkoutBtnTwo pressed:', checkoutBtnTwo); const checkbox = document.getElementById("brella-protect-toggle-button-embed"); try { if (widgetSettings.addAttribute && widgetSettings.addAttribute === "true") { addAttribute(true); } else { await addItemToCart(widgetSettings.variantId); } console.log('Item added to cart from checkoutBtnTwo'); } catch (error) { console.error("Error adding item to cart:", error); } }); } } } } const shopTheme = window.Shopify?.theme; console.log('Shop Theme:', shopTheme?.schema_name); await injectWidget(shopDomain, countryCode); attachAddToCartListener(shopDomain, countryCode); } });