learnshopify.dev/Workspace
code reading

Sarah's purchase-options block. Trace it, then answer.

{% assign current_variant = product.selected_or_first_available_variant %}

{% form 'product', product %}
  <input type="hidden" name="id" value="{{ current_variant.id }}">

  {% if product.selling_plan_groups.size > 0 %}
    <fieldset class="purchase-options">
      <legend>{{ product.selling_plan_groups.first.name }}</legend>

      {% unless product.requires_selling_plan %}
        <label class="purchase-options__row">
          <input type="radio" name="selling_plan" value="" checked>
          One-time purchase
          <span class="purchase-options__price">{{ current_variant.price | money }}</span>
        </label>
      {% endunless %}

      {% for allocation in current_variant.selling_plan_allocations %}
        <label class="purchase-options__row">
          <input type="radio" name="selling_plan" value="{{ allocation.selling_plan.id }}">
          {{ allocation.selling_plan.name }}
          <span class="purchase-options__price">
            {{ allocation.price | money }}
            <s>{{ allocation.compare_at_price | money }}</s>
          </span>
        </label>
      {% endfor %}
    </fieldset>
  {% endif %}

  <button type="submit" name="add">Add to cart</button>
{% endform %}
1. A customer picks 'Deliver every 4 weeks, save 10%' and submits. What reaches the cart?
2. Why do subscription rows print `allocation.price` instead of `current_variant.price`?
3. What does `value=""` on the one-time radio accomplish?
4. This snippet also runs on the gift-card PDP, which has no selling plans. What renders?
5. What breaks if the `{% unless product.requires_selling_plan %}` wrapper is removed?
0 / 1 task solved