-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix no-js variant select on Featured Product #736
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with and without JS enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it and it looks good 😄
templates/index.json
Outdated
@@ -2,97 +2,248 @@ | |||
"sections": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to revert these files
config/settings_data.json
Outdated
@@ -1,5 +1,33 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one
@@ -286,7 +286,7 @@ | |||
</div> | |||
|
|||
{%- form 'product', product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%} | |||
<input type="hidden" disabled name="id" value="{{ product.selected_or_first_available_variant.id }}"> | |||
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" disabled> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm I understand, you added disabled
to ensure that this input isnt used when we are on the no-js version. Correct? Because this input is actually only used for the js version and the input value was being updated when we didnt want it to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is reproducing the same fix from #210.
We're disabling this input so only the <select>
, which has the same name
, is seen by the no-js
version.
This input is re-enabled via JS on product-form.js
constructor:
ad9704f
to
1332817
Compare
This kindof breaks add to cart on browsers that dont support custom elements. |
Why are these changes introduced?
When JavaScript is disabled, only initial variant could be added to cart, regardless of which variant was selected. This PR fixes this issue by replicating the same solution implemented by #210 on
main-product.liquid
Fixes #179.
What approach did you take?
<select>
element to use the correct Form ID.Demo links
**Testing 🎩 **
Add to Cart
button.Checklist