Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hidden inputs for product variants #3668

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sections/featured-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@
{%- endif -%}
{%- unless placeholder -%}
<div {{ block.shopify_attributes }}>
{%- form 'product', product -%}
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
{%- form 'product', product.selected_or_first_available_variant -%}
{{ form | payment_terms }}
{%- endform -%}
</div>
Expand Down Expand Up @@ -380,11 +379,11 @@
render 'share-button', block: block, share_link: share_url
%}
{%- when 'variant_picker' -%}
{% render 'product-variant-picker',
product: product,
block: block,
product_form_id: product_form_id
%}

Check warning on line 386 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L382-L386

[NestedSnippet] Too many nested snippets

Check warning on line 386 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L382-L386

[NestedSnippet] Too many nested snippets

Check warning on line 386 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L382-L386

[NestedSnippet] Too many nested snippets
{%- when 'buy_buttons' -%}
{%- render 'buy-buttons',
block: block,
Expand Down Expand Up @@ -473,7 +472,7 @@
if product.selected_or_first_available_variant.featured_media
assign seo_media = product.selected_or_first_available_variant.featured_media
else
assign seo_media = product.featured_media

Check warning on line 475 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L475

[UnusedAssign] `seo_media` is never used
endif
-%}

Expand All @@ -487,7 +486,7 @@
{% endif %}
</product-info>

{% schema %}

Check notice on line 489 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L489

[SchemaJsonFormat] JSON formatting could be improved
{
"name": "t:sections.featured-product.name",
"tag": "section",
Expand Down
7 changes: 5 additions & 2 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@
{%- endif -%}
<div {{ block.shopify_attributes }}>
{%- assign product_form_installment_id = 'product-form-installment-' | append: section.id -%}
{%- form 'product', product, id: product_form_installment_id, class: 'installment caption-large' -%}
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
{%- form 'product',
product.selected_or_first_available_variant,
id: product_form_installment_id,
class: 'installment caption-large'
-%}
{{ form | payment_terms }}
{%- endform -%}
</div>
Expand Down Expand Up @@ -462,7 +465,7 @@
%}

{%- when 'variant_picker' -%}
{% render 'product-variant-picker', product: product, block: block, product_form_id: product_form_id %}

Check warning on line 468 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L468

[NestedSnippet] Too many nested snippets

Check warning on line 468 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L468

[NestedSnippet] Too many nested snippets

Check warning on line 468 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L468

[NestedSnippet] Too many nested snippets
{%- when 'buy_buttons' -%}
{%- render 'buy-buttons',
block: block,
Expand Down Expand Up @@ -714,7 +717,7 @@
if product.selected_or_first_available_variant.featured_media
assign seo_media = product.selected_or_first_available_variant.featured_media
else
assign seo_media = product.featured_media

Check warning on line 720 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L720

[UnusedAssign] `seo_media` is never used
endif
-%}

Expand Down
15 changes: 1 addition & 14 deletions snippets/buy-buttons.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,12 @@
</div>

{%- form 'product',
product,
product.selected_or_first_available_variant,
id: product_form_id,
class: 'form',
novalidate: 'novalidate',
data-type: 'add-to-cart-form'
-%}
<input
type="hidden"
name="id"
value="{{ product.selected_or_first_available_variant.id }}"
{% if product.selected_or_first_available_variant.available == false
or quantity_rule_soldout
or product.selected_or_first_available_variant == null
%}
disabled
{% endif %}
class="product-variant-id"
>

{%- if gift_card_recipient_feature_active -%}
{%- render 'gift-card-recipient-form', product: product, form: form, section: section -%}
{%- endif -%}
Expand Down
9 changes: 0 additions & 9 deletions snippets/card-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,6 @@
novalidate: 'novalidate',
data-type: 'add-to-cart-form'
-%}
<input
type="hidden"
name="id"
value="{{ card_product.selected_or_first_available_variant.id }}"
class="product-variant-id"
{% if card_product.selected_or_first_available_variant.available == false %}
disabled
{% endif %}
>
<button
id="{{ product_form_id }}-submit"
type="submit"
Expand Down
Loading