BUY 2 SETS - GET A TOWEL 50% OFF โฆ FREE SHIPPING OVER โช499 โฆ BUY 3 SETS - GET A FREE TOWEL โฆ
// ==================== IMMEDIATE CSS INJECTION ==================== // Hide Wix color pickers IMMEDIATELY to prevent flash // ==================== CONFIGURATION ==================== // Session storage keys // Get instanceId from Wix Blocks parameters // Product config cache (in-memory) // Global settings cache // ==================== SESSION STORAGE ==================== // ==================== GLOBAL SETTINGS ==================== // ==================== USER VERIFICATION ==================== // Restore Wix pickers if user is not verified // ==================== PRODUCT CONFIG ==================== // Merge with global settings // ==================== DOM MANIPULATION ==================== // Find the Wix product options container // โ FIXED: Find ALL color variant groups (each with unique name) // Find all top-level repeater items (these are the variant groups like "Color", "color") // Get direct children repeater items (variant groups) // Find the variant name (title) // Find all radio inputs within THIS group only // Create a color swatch element // Size mapping // Shape // Get color value // Handle different color types // Hover effects // Click handler // Create variant title element // Inject custom color picker for a variant // Create wrapper container // Add title // Create custom picker container // Find default/selected color from SPO config // Also check which Wix color is currently selected // Add color swatches // Check if this SPO color matches the selected Wix color // Update visual selection // Find and click the original Wix radio button // Dispatch custom event // Insert custom picker BEFORE the Wix variant container, then hide it // ==================== MAIN HANDLER ==================== // Validate productId format // Step 1: Verify user return; // restoreWixPickers already called in verifyUser // Step 2: Get product config from CMS // Step 3: Wait for DOM and inject // Find ALL Wix color variant groups // Match and inject for each SPO variant // Find matching Wix variant group by EXACT name match first // If no exact match, try partial match (but only if not already used) matchingWixGroup.used = true; // Mark as used to prevent double-matching // Remove the immediate hide style since we've injected our pickers // Add global CSS styles // ==================== PRODUCT ID EXTRACTION ==================== // Method 1: Check Wix global state // Method 2: Check window.__PRODUCT_PAGE_DATA__ // Method 3: Check for product ID in page data (LD+JSON) // Method 4: Check URL for product ID patterns // Method 5: Look for product ID in any data attribute // Method 6: Check for hidden inputs // Track if we've already processed this product // ==================== INITIALIZATION ==================== // Validate instanceId // Register Wix analytics event listeners // ProductPageLoaded event // ViewContent event (Wix Stores tracking pixel) // Fallback: If we're already on a product page, try to extract productId // Wait for page to fully load // Try again after more time // Not on a product page, don't hide anything // Start when DOM is ready
BUY 2 SETS - GET A TOWEL 50% OFF โฆ FREE SHIPPING OVER โช499 โฆ BUY 3 SETS - GET A FREE TOWEL โฆ