A user is trying to customize variant selection buttons on their Shopify store (adriabeachwear.com) using the Envy theme, but encounters issues where button-style variants only work for the first option and immediately redirect to cart.
Initial Problem:
Custom code displays two variant dropdowns (e.g., “Taglia: slip” sizes and “Taglia: brasiliana” sizes)
When styled as buttons instead of dropdowns, only the first variant selector functions correctly
Missing JavaScript selectVariant() function causes buttons to submit the form prematurely
Solution Provided:
A community member (tim_1) identified the root cause: incomplete JavaScript implementation
Provided working code that properly handles variant selection without auto-submitting to cart
Included markup for both variant option groups with proper form structure
Follow-up Issue:
After a theme update, the original fix stopped working and styling changed
Updated code was provided to match the new theme structure and CSS variables
User requested minor CSS adjustments to perfectly match original variant styling
Status: Ongoing - user implementing final styling tweaks to align with standard product form appearance.
Summarized with AI on November 9.
AI used: claude-sonnet-4-5-20250929.
I used this code to add variants to my product, but the result is that i can display the variants only as dropdown list. If i display the variants as button, the selection of the variants works only for the first one and send you directly to the cart.
how I can fix this code to display the 2 drop-down list as button.
The idea is that when any of these buttons is clicked, browser must execute Javascript function selectVariant with relevant parameter.
However, there is no JS code.
By default, any button inside the form (product form in this case) submits your form with whatever selections are made. And since selectVariant is not defined, buttons perform their default function, same as you click “add to cart”.