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

Cart error issue #633

Merged
merged 3 commits into from
Sep 17, 2021
Merged

Cart error issue #633

merged 3 commits into from
Sep 17, 2021

Conversation

ludoboludo
Copy link
Contributor

Why are these changes introduced?

Fixes #380

What approach did you take?

Two fixes in this PR:

  • We have the cart notification on the cart page and we noticed that the form within the notification had the same ID as the form for the cart-items. Changing the one from the cart notification to make sure there wasn't a duplicate fixed a couple things: pressing Enter will submit the form and take you to checkout and when changing the quantity by highlighting the number and pressing Enter you will get an error message if you try a higher quantity than available.
  • On safari specifically, when you changed the quantity in the cart, an error kept showing up (Fix add to cart error messaging #582 (comment)). It was due to how Mac handles focus management differently. It sends back focus to the body when clicking on an input that isn't of type="text". So I added a check in the if statement so it doesn't error anymore.

Other considerations

There isn't a fix for the situation where for example:

  • you have 3 of the same item in your cart
  • the have a stock limit of 10
  • you manually input 11
  • then you will notice that the quantity updates to 10 but no error is mentioned.

This to me seems like there could be some work done platform wise to handle cases like this. Otherwise we need to run lots of checks and logic.

Demo links

Checklist

Copy link
Contributor

@tyleralsbury tyleralsbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested both fixes and it all looks good. This one was sneaky.

@tauthomas01 tauthomas01 self-assigned this Sep 17, 2021
Copy link
Contributor

@tauthomas01 tauthomas01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff for finding the root cause 👍

@ludoboludo ludoboludo merged commit 2b3f8f6 into main Sep 17, 2021
@ludoboludo ludoboludo deleted the cart-error-issue branch September 17, 2021 15:29
@gregjotau
Copy link

@ludoboludo just added this to famme.no and the cart seems broken.

@ludoboludo
Copy link
Contributor Author

@gregjotau could you provide some details on what's not working so I can see if I can replicate the issue locally ?

@gregjotau
Copy link

try adding to cart

@gregjotau
Copy link

I tried to revert, but it is still not working...

@gregjotau
Copy link

https://github.com/gregjotau/dawn-famme

The repo is here, there is not much customization @ludoboludo

@gregjotau
Copy link

product-form.js?v=3576239225032671514? [sm]:21 Uncaught TypeError: Cannot read properties of null (reading 'classList')
at HTMLElement.onSubmitHandler (product-form.js?v=3576239225032671514? [sm]:21)

@gregjotau
Copy link

We just sent out an "email blast" so a lot of lost customers now :(

@gregjotau
Copy link

@ludoboludo no product pages are working. Adding to cart simply does not work anymore.

@gregjotau
Copy link

@gregjotau could you provide some details on what's not working so I can see if I can replicate the issue locally ?

A video, this is critical as I cannot fix it even with a revert.

Screen.Recording.2021-09-17.at.23.07.10.mov

@ludoboludo
Copy link
Contributor Author

ludoboludo commented Sep 17, 2021

Ah I think it's because there are some changes in other PR that you haven't added to your store. Take a look at this file and the PR that goes with it. Did you add that to your store as well ? #576 and specifically the main-product.liquid file.

@gregjotau

@gregjotau
Copy link

2 sec

@ludoboludo
Copy link
Contributor Author

It changes how the .loading-overlay__spinner is. Now it's an element within the button rather than dealt with using a pseudo element.

@gregjotau
Copy link

yeah, have already cherry picked #576

@gregjotau
Copy link

but might not have merged it correctly

@gregjotau
Copy link

OK, spotted something in base.css

@gregjotau
Copy link

Nope, sorry, still does not work

@ludoboludo
Copy link
Contributor Author

Yeah I see that on variant change it seem to remove the .loading-overlay__spinner element.

For now I'd suggest adding a conditional around

      this.querySelector('.loading-overlay__spinner').classList.remove('hidden');

So have it say:

if (this.querySelector('.loading-overlay__spinner')) this.querySelector('.loading-overlay__spinner').classList.remove('hidden');

@gregjotau
Copy link

2 sec

@gregjotau
Copy link

That seemed to work, but the spinner does not work for add nr 2, but OK. That should be fine for now.

@gregjotau
Copy link

OK, thanks for the quick help!

@gregjotau
Copy link

Have to sleep now. Keep up the great work 🤓

@ludoboludo
Copy link
Contributor Author

Yeah something we will look into this first thing next week 👍 Seems like the variant change is removing the spinner. Then making the JS fail. Didn't come up from this PR but something we did recently that had this unexpected impact.

@gregjotau
Copy link

np! Have a great weekend :)

phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
* first draft

* found a fix! Thanks Tyler :)

* remove error in catch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cart Page: Inconsistent error messaging for low item stock
4 participants