All products

Design a Shopify variant picker with AI

Build a Hydrogen product selector that distinguishes sold-out options from combinations that do not exist. Check that the cart receives the variant a shopper chose.

Design a Shopify variant picker with AI when two disabled options mean different things. A blue shoe in size eight might be temporarily sold out, while the green shoe was never made in that size. The shopper needs to know which choice could return and which one they should change.

The hydrogen-variant-form skill guides the selection logic for a Hydrogen storefront. It separates the state shown by each option from the action of adding an item to the cart. A useful preview includes the starting selection and the result of changing the options in different orders.

What it does

  • Represent valid, unavailable and nonexistent combinations
  • Use a suitable initial variant when one is provided
  • Update an option's state when another option changes
  • Check whether the selected variant can be bought
  • Pass the correct merchandise identifier to the cart action

Install and use

  1. Install the skill and the reference for your framework in a coding agent. Use a Hydrogen project and authorised product data with representative variants and availability.
  2. Ask, “Build a size and colour picker for this test product. Distinguish a sold-out size from a size never made in green, and show when Add to cart is available.”
  3. Try both selection orders in the preview. Add an eligible test item and compare its variant with the one visible on the page.

FAQ

Source

Made by Shopify. Original skill: hydrogen-variant-form, published on GitHub under the MIT licence.

View on GitHub