Goal: Filter a manually coded car make/model/year form on the product page by the currently selected Shopify variant’s “Number of Seats,” so only compatible vehicles display while keeping pricing tied to the product variant.
Proposed solutions:
Liquid + query parameters: On variant/make change, reload the page and filter options via URL parameters.
Client-side JS: Listen to variant changes and update car model options from a mapping keyed by make and variant (example code provided).
Request/constraint from OP: The approach should use the product’s existing “Number of Seats” variant (no extra seats dropdown). Seat values (e.g., “4 Koltuk,” “5 Koltuk”; “Koltuk” = “seat”) must match entries in a provided carData structure: brand → model → year-range → [seat options]. They need to read the selected variant’s seat value from the UI and filter the vehicle lists accordingly.
Current status: The general JS logic works, but the mapping must be based on the variant’s seat value rather than variant ID. A site link was requested for further review. No final implementation or resolution yet.
Artifacts: An image showing the seats variant is important for context; code snippets and the carData JSON are central to the solution.
Summarized with AI on December 16.
AI used: gpt-5.
I added a form to my design that lists car makes and models. I want to filter the form based on the selected variant. Is there any code to add available in Shopify to get the selected variant data?
I want to filter the list based on the selected variant this way.
You can leverage Shopify’s forms and query parameters to filter the options. The idea is to use the variant selection to reload the form and show only relevant car models based on the selected variant.
Liquid Code (product-template.liquid or main-product.liquid):
Here’s a code example where the form submits on variant change, and the car models are filtered based on the selected variant.
How It Works:
When the user selects a variant or make , the page reloads.
The selected values are passed through the URL query parameters.
The car model options are filtered and displayed accordingly based on the selection.
If I was able to help you, please don’t forget to Like and mark it as the Solution!
Actually, the logic of your code works well, and I have tested it, and it works. However, what I want is as you can see in the image below, the “Number of Seats” variant comes from the product itself. I manually coded the vehicle selection part. Not every vehicle has every seat count, so I want to match it with the selected value. I’ll leave my example JSON code below. You can see the parameter.
What I want to do is match the selected value in the “Number of Seats” part in the image with the “Number of Seats” of the models. This will prevent the dropdown menu from listing every brand and model. The reason I want to do it this way is that the price changes based on the seat count, so I want to keep that variant within the product.