-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Product form] Fix Add to Cart error on page load/slower connections #3008
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.
This LGTM! I compared against main
and also tested this in Firefox and everything works as expected when the network speed is throttled.
@ludoboludo FYI: This fix is going to prevent changing the variant when javascript is disabled... IssueYou can refer to the original issue that fixed. The gist is that on no js there will be TWO fields with name="id":
The last field with name="id" will be chosen if not disabled. This will prevent the user changing the variant, only the first/selected variant will ever be added to the cart because the buy buttons hidden field is lower in the page. Alternative SolutionOn the product page only (quick add is only shown when js enabled), you might include something like this really early in the product page lifecycle, maybe with a script tag right the buy buttons (can check the template type): document.querySelectorAll("product-form form [name=id]").forEach(input => input.disabled = false) AsideDo you have any idea if Shopify is going to allow checking out without javascript? There has been lots of changes in the past year to the checkout, but no js support is gone... You just get an infinite spinner now when you checkout with no js. In the past, this was never an issue. |
Hey @naxorn thanks for the heads up. Do you find that you have to support many customers that navigate the web with no js ? |
Hard to say about no js users... All the logging I'm aware of requires javascript, so I cannot see a way to track no js usage. I guess it comes down to choice for the user. Dawn is built around supporting/testing no js options still and find it strange that Shopify (in the past year or so) forces the user to turn on javascript. FYI: PayPal supports no js checkout. The worst thing for me is that the no js checkout still exists depending on the checkout link provided from Shopify... For example:
On duckduckgo they have something like this in the head that redirects to the no js version: <noscript>
<meta http-equiv="refresh" content="0; url=[link to page supporting no js version]"/>
<style>body { display: none }</style>
</noscript> |
* Update 1 translation file (Shopify#2997) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Update 1 translation file (Shopify#3001) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * [Image_tag] Update to remove lazy loading and let it automatically decide the best loading strategy (Shopify#3002) * remove lazy loading where necessary to better performance * add fetch priority * [Facets] update filter counts on filter selection (Shopify#2988) * Correct CSS (Shopify#3003) * Check if there is compare_at_price (Shopify#3000) * Update 1 translation file (Shopify#3012) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * [Facets] fix mobile count update (Shopify#3018) * Update 1 translation file (Shopify#3043) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Update 1 translation file (Shopify#3044) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * [Image with text] Add color scheme picker for section wrapper (Shopify#3016) * [Image with text] Add color scheme picker for section wrapper * address review comment about overlap and transparency * Refactor `quick-order-list.css` (Shopify#3006) * Fix Add to Cart error on page load/slower connections (Shopify#3008) * [Facets] dynamic header (Shopify#3048) * Add component-card.css to cart drawer (Shopify#3049) * [Refactoring] Replace loading spinner with snippet (Shopify#2996) * Change spinner for main-cart-items * Change spinner for cart-drawer * remove extra div and change classes * Replace spinner with snippet for pdp and fead prod * Remove unnecessary classes * Add comment for snippet * Change naming for files and css classes * Put back deleted elements * Remove unused classes * Put back loading-overlay for cases when no spinner * Chnage loading-overlay--error name * Minor change in CSS * Move loading-overlay styles to template-collection * Rename component-loading-overlay * Fix bug with overlay and spinner for facets * Remove component-loading-spinner import from files * Use spinner snippet for predictive search * Hide product count when loading for drawer filters * Address feedback. Clean-up. * Minor changes to address feedback * Fix spinner conflict with cart drawer * Address feedabck * Add missing whitespace for if tag * [Sliders] Regression fix. Apply CSS only when necessary in theme editor (Shopify#3070) * [Sliders] Regretion fix. Apply CSS only when necessary in theme editor * change of approach * add comment to explain CSS * Add visual representation for filters (Shopify#3045) * [Facets] update visual representation of facets operators (Shopify#3061) * [Collection template] Product grid color scheme picker (Shopify#3017) * [Collection template] Product grid color scheme picker] * move color setting up in the list * support gradient * [Cart] Add color picker on cart page and in general cart settings (Shopify#3021) * rebase final final * use the update for the loading spinner * add color picker for the cart drawer and cart popup * fix spacing issues on cart page * add gradient support * address review comments * adjust where the class is added. Fix gradient issue * isolation needed for shadow * add comment * Remove unnecessary isolate * use the isolate class instead * [Product] Add color scheme picker (Shopify#3015) * [Product] Add color scheme picker * support gradient * apply background color to be full width * address review comments: color scheme applied to quick add modal and lightbox modal * add color scheme to product availability drawer and move color settings up * fix color classes to work properly with gradients * Add support for gradient on modal * remove console log * [VisualDisplay] bump the active outline width (Shopify#3083) (Shopify#3091) * 12.0.0 Version Bump and release notes (Shopify#3092) * Update 1 translation file (Shopify#3093) * updated code to match new color scheme naming (Shopify#2801) * updated code to match new color scheme naming * removing additional background-1 after rebase * Fixed race condition for cart note updates (Shopify#3125) * [Facets] support dynamic facet lists (Shopify#3123) * Assign font family to input fields (Shopify#2871) * Price per item, Popover and global style bugs (Shopify#2851) * Fix cart submission on Quick Order List (Shopify#2868) * Social icons: Visual fixes (Shopify#2855) * Adjust spacing. * Facebook + Tumblr icon size adjustments. * Update social icon SVGs. * Tidy up new icon sizes again. * Resize icons. * Make spacing slightly smaller. * Make icons larger so they're more similar to the old sizes. * Remove padding to compensate for extra viewbox space. * Try a smaller Twitter icon. * Update snapchat icon. * Resize social links in menu drawer to 44x44 * replace translation string to have the translation visible (Shopify#2869) * B2B compare at price with price range (Shopify#2858) * Add sale badge and price-range for volume-pricing * Add compare_at price to PDP and Feat Prod. * Change opacity to 100% for price per item. * Update the logic * Hide price per item for unavailable variants. * Remove margin for dl. * Refactoring * Correct a mistake in liquid. * Change the JS logic back for updating price per item * Add compare at to prod card. Add style to compare at * Assign font family to input fields. * Update assets/base.css Co-authored-by: Kai <[email protected]> * Use the theme's font style + weight in form elements. --------- Co-authored-by: Sofia Matulis <[email protected]> Co-authored-by: melissaperreault <[email protected]> Co-authored-by: Eugene Kasimov <[email protected]> Co-authored-by: Kai <[email protected]> * Update 1 translation file (Shopify#3155) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Update 1 translation file (Shopify#3157) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Update 1 translation file (Shopify#3158) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Update 1 translation file (Shopify#3161) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Update 2 translation files (Shopify#3160) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Applied image shape and ratio to placeholder images (Shopify#2817) added classes and styles to get image shape and image ratio working added styling on portrait placeholders aligned placeholder when in potrait mode applying code review suggestions and removed image-ratio * [Visual Display] Display accurate filter colors when high contrast mode is enabled (Shopify#3165) * Improved country selectors (Shopify#3175) Original PR with review comments -> Shopify#3135 * Update inline quantity error styles. (Shopify#3150) * Update 1 translation file (Shopify#3177) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * [Variant Picker] Update settings copy (Shopify#3173) * Bring back the lighthouse-ci-action to v1 (Shopify#3181) This will make sure new releases are automatically used. Better for forks as well. * Changed slider to work on tablet for multicolumn (Shopify#3176) * Changed slider to work on tablet for multicolumn * Adjusted to prevent early cutoff on tablet * Adjusted Featured Collection placeholders to work with any number of desktop columns (Shopify#3182) * Adjusted featured collection placeholders to work with any number of desktop columns * [Variant Picker] Add swatch display type (Shopify#3180) * [VariantPicker] Unify variant selects and radios under new component * [VariantPicker] Add swatch settings * [VariantPicker] Move styles to dedicated CSS file * [Variant Picker] Update settings copy * [VariantPicker] Add swatch component * [VariantPicker] Add a swatch to selected dropdown option * [Variant Picker] Update disabled state * [Variant Picker] Swatch snippet * [Variant Picker] Swatch input snippet * [Variant Picker] Tweak swatch border colors * Update swatch border (Shopify#3184) * Update translations: merchant (Shopify#3178) * Update 1 translation file * Update 1 translation file * Update 2 translation files * Update 1 translation file --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * [Variant Picker] Ensure that swatches wrap correctly (Shopify#3185) * Focus search on country selector open and fix iOS bug (Shopify#3183) * Focus search on country selector open * Set stacking context * Prevent sticky header from hiding when country selector is open (Shopify#3188) * change to 100% (Shopify#3190) * [Variant Picker] Simplify swatch settings (Shopify#3189) * [Variant Picker] Simplify swatch settings * Update 7 translation files * Update 12 translation files * Update 1 translation file --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Escape filter label consistently (Shopify#3192) * Update 1 translation file (Shopify#3202) Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> Co-authored-by: Ludo <[email protected]> Co-authored-by: Patrick Racicot <[email protected]> Co-authored-by: Eugene Kasimov <[email protected]> Co-authored-by: Andrew Etchen <[email protected]> Co-authored-by: Jason Addleman <[email protected]> Co-authored-by: Sofia Matulis <[email protected]> Co-authored-by: Louisa Goncharenko <[email protected]> Co-authored-by: Tyler Alsbury <[email protected]> Co-authored-by: Kjell Reigstad <[email protected]> Co-authored-by: melissaperreault <[email protected]> Co-authored-by: Kai <[email protected]> Co-authored-by: Alex Ilea <[email protected]> Co-authored-by: Abdulrahman Hamideh <[email protected]> Co-authored-by: CP Clermont <[email protected]>
PR Summary:
The
product-form.js
can take a little too long to load and create issues, more noticeable on slower connections where adding to cart before the full page has finished loading will give you an error.This aims to prevent that from happening.
Why are these changes introduced?
Prevents the add to cart from erroring before the
product-form.js
script has loaded.What approach did you take?
Wrapped a condition around the
disabled
state of the hidden input similar to how thedisabled
attribute is setup on the submit button.Other considerations
Decision log
Visual impact on existing themes
Testing steps/scenarios
You shouldn't get an error but redirected to the cart page with the product in it.
Demo links
Checklist