A product page with color variants fails to update the URL with variant IDs when users select different options. The expected behavior is for the URL to append ?variant=[ID] when clicking variant swatches.
Root Cause:
The site uses custom hardcoded theme (not a standard Shopify theme), and the swatch click function wasn’t updating the browser URL.
Solution Provided:
A JavaScript code snippet was shared that:
Captures the variantid attribute when .pdp-colors elements are clicked
Constructs a new URL with the variant parameter
Updates the browser history using window.history.replaceState()
The code should be added at the end of the script (around line 23, replacing lines 6-142 in the original implementation).
Outcome:
The original poster confirmed the solution worked perfectly. Another user later requested similar help for the Venue theme, with assistance offered.
Summarized with AI on November 19.
AI used: claude-sonnet-4-5-20250929.