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

Add qty rules client side validation to cart #3471

Merged
merged 5 commits into from
May 15, 2024
Merged

Conversation

sofiamatulis
Copy link
Contributor

@sofiamatulis sofiamatulis commented May 13, 2024

PR Summary:

Ensuring the qty rules validation happens before the cart API is called (this way the error doesnt need to come back from the API)

Before:

14-03-h9usw-7v7uo

After:

14-03-ve10n-sdzwn

Why are these changes introduced?

Fixes #3399

What approach did you take?

I am pulling the same functions I use in QOL and Quick Add Bulk

Testing steps/scenarios

  • Test a variant with qty rules (increment, max and min)
  • Test a variant without qty rules
  • Test the cart drawer and cart page

Demo links

Checklist

@@ -42,13 +42,43 @@ class CartItems extends HTMLElement {
}
}

resetQuantityInput(id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a similar function to what we have in BulkAdd in global.js. However, it doesnt make sense to extend that component yet since we dont have all the functionalities yet

When we do (this ticket https://github.com/orgs/Shopify/projects/6397/views/28?pane=issue&itemId=61489062) , let's do that

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to me. I think we can live with the duplication for now, especially since we have a chance to revisit it shortly.

@sofiamatulis sofiamatulis changed the title Add client side validation to cart Add qty rules client side validation to cart May 14, 2024
@sofiamatulis sofiamatulis marked this pull request as ready for review May 14, 2024 14:45
Copy link
Member

@dan-menard dan-menard left a comment

Choose a reason for hiding this comment

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

Nice fix!

One thing I noticed, I'm not getting the browser-level validation for BxGy discounts. Is that expected? (not sure if we can/want to validate that one in advance)

image

@@ -42,13 +42,43 @@ class CartItems extends HTMLElement {
}
}

resetQuantityInput(id) {
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to me. I think we can live with the duplication for now, especially since we have a chance to revisit it shortly.

@sofiamatulis
Copy link
Contributor Author

sofiamatulis commented May 14, 2024

One thing I noticed, I'm not getting the browser-level validation for BxGy discounts. Is that expected? (not sure if we can/want to validate that one in advance)

@dan-menard The client side validation is for qty rules only. I dont see the i icon next to your variant in cart, so it doesnt look like the variant you picked has qty rules set up, which is why you dont see it. This is an inventory error

assets/cart.js Outdated Show resolved Hide resolved
assets/cart.js Outdated Show resolved Hide resolved
assets/cart.js Outdated Show resolved Hide resolved
assets/cart.js Outdated Show resolved Hide resolved
assets/cart.js Outdated Show resolved Hide resolved
@sofiamatulis sofiamatulis merged commit 636b6b7 into main May 15, 2024
8 checks passed
@sofiamatulis sofiamatulis deleted the client-validation-cart branch May 15, 2024 15:50
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.

Introduce client side validation for Quantity Rules to Cart
3 participants