make PDP variant selection work without JS
All checks were successful
deploy / deploy (push) Successful in 1m3s

Variant options (colour, size) are now URL params handled via
handle_params instead of phx-click events. Swatches and size buttons
render as patch links in shop mode, so changing variants works as
plain navigation without JS. Quantity is now a number input that
submits with the form. Unavailable variants render as disabled spans.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-25 01:08:36 +00:00
parent a61adf4939
commit 23e95a3de6
6 changed files with 238 additions and 75 deletions

View File

@@ -32,7 +32,7 @@
name="variant_id"
value={@selected_variant && @selected_variant.id}
/>
<input type="hidden" name="quantity" value={@quantity} />
<%!-- quantity is provided by the quantity_selector input below --%>
<%!-- Dynamic variant selectors --%>
<%= for option_type <- @option_types do %>
@@ -41,6 +41,7 @@
selected={@selected_options[option_type.name]}
available={@available_options[option_type.name] || []}
mode={@mode}
option_urls={(@option_urls || %{})[option_type.name] || %{}}
/>
<% end %>