Project portfolio Browse selected work

Shopify Plus Upgrade Monthly Fee Reduction + Up to $4800 Development Fee Credit - Exclusive WesWoo Offer

Developer modules / Product detail and combined purchases

Product detail and combined purchases

Synchronize model and variant facts before media, accessories and specifications.

Models, variants and the purchase form

Let the selected variant determine price, availability and the submitted ID. Provide a reloadable variant URL before asynchronous selection, then keep media, SKU and URL aligned.

Data and dependencies

  • product and selected_or_first_available_variant.
  • Submit variant.id rather than product.id.

Interaction logic

  • The GET selector reloads the chosen variant before purchase.
  • Keep sold-out variants viewable while disabling purchase.
Example code · snippets/ww-variant-fallback.liquid
Liquid · WESWOO
{% assign current_variant = product.selected_or_first_available_variant %}
<h1>{{ product.title | escape }}</h1>
<p>{{ current_variant.title | escape }} — {{ current_variant.price | money_with_currency }}</p>
<form action="{{ product.url }}" method="get">
  <label for="Variant-{{ section.id }}">Variant</label>
  <select id="Variant-{{ section.id }}" name="variant">
    {% for variant in product.variants %}
      <option value="{{ variant.id }}"{% if variant.id == current_variant.id %} selected{% endif %}>
        {{ variant.title | escape }}{% unless variant.available %} — Sold out{% endunless %}
      </option>
    {% endfor %}
  </select>
  <button type="submit">View this variant</button>
</form>
{% assign purchase_form_id = 'Purchase-' | append: section.id %}
{% form 'product', product, id: purchase_form_id %}
  <input type="hidden" name="id" value="{{ current_variant.id }}">
  <button type="submit"{% unless current_variant.available %} disabled{% endunless %}>
    {% if current_variant.available %}Add to cart{% else %}Sold out{% endif %}
  </button>
{% endform %}

Acceptance checks

  • Open a variant URL and compare price with form ID.
  • Check sold-out states, changes and JavaScript disabled.

This is a no-script baseline for a small variant set. For high-variant products, use current theme option and on-demand rendering patterns rather than relying on this loop.

Read it, integrate it, verify it

  1. Choose a module and confirm the data contract.
  2. Connect the fragment to the current theme or framework.
  3. Check real variants, markets and recovery states.

Examples target Shopify Online Store 2.0 themes. Headless has separate data and version boundaries. Integrate fragments with actual fields, theme components and locale files.

Architecture references

Original educational examples with Shopify documentation and pinned upstream references. Follow the applicable license when adopting repository code.

Shopify/dawn · Licensecommit 3e9ee2281dc4 · Shopify-integration theme license; architecture reference without copying the implementation.
Shopify/hydrogen · Licensecommit 9e358a2462ba · MIT; retain copyright and license when using substantial code.

References checked 2026-11-12