Skip to content

Display warnings and errors in the cart#3400

Open
fredericoo wants to merge 14 commits intomainfrom
Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support
Open

Display warnings and errors in the cart#3400
fredericoo wants to merge 14 commits intomainfrom
Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support

Conversation

@fredericoo
Copy link
Contributor

@fredericoo fredericoo commented Jan 22, 2026

Closes #969

#3276

WHY are these changes introduced?

This PR adds the ability to display warnings to users in the cart, improving the user experience by providing clear feedback when there are issues with their cart.

WHAT is this pull request doing?

  • Adds a new InlineWarning component for displaying warning messages in an accessible way
  • Implements useCartFeedback hook to collect and normalize errors and warnings from cart fetchers
  • Adds CartWarnings component to display warnings in the cart interface
  • Updates the cart styling to properly display warning messages
  • Integrates the warning system with the existing cart functionality

HOW to test your changes?

  1. Add items to cart
  2. Trigger a cart warning (e.g., by attempting to add more items than available in inventory)
  3. Verify that warnings appear properly in the cart interface
  4. Check that warnings are properly styled and accessible

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor Author

fredericoo commented Jan 22, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fredericoo fredericoo changed the title fix: adjust state Add MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION warning support Jan 22, 2026
@shopify
Copy link
Contributor

shopify bot commented Jan 22, 2026

Oxygen deployed a preview of your Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment February 16, 2026 1:02 PM
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2026 4:06 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2026 4:06 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2026 4:06 PM
sitemap ✅ Successful (Logs) Preview deployment Inspect deployment January 23, 2026 4:06 PM

Learn more about Hydrogen's GitHub integration.

@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch from 3ecb1f8 to 9a80d6f Compare January 22, 2026 20:09
@fredericoo fredericoo marked this pull request as ready for review January 22, 2026 20:11
@fredericoo fredericoo requested a review from a team as a code owner January 22, 2026 20:11
@kdaviduik kdaviduik changed the base branch from 2025-10-sfapi-caapi-update to graphite-base/3400 January 23, 2026 03:59
@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch from 9a80d6f to 955ac0f Compare January 23, 2026 16:03
@fredericoo fredericoo changed the base branch from graphite-base/3400 to 2025-10-sfapi-caapi-update January 23, 2026 16:03
@fredericoo fredericoo changed the title Add MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION warning support Add cart warnings component to display feedback to users Jan 23, 2026
@kdaviduik kdaviduik changed the base branch from 2025-10-sfapi-caapi-update to graphite-base/3400 January 26, 2026 03:28
@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch 2 times, most recently from 80251b9 to 98b056a Compare January 26, 2026 13:55
@fredericoo fredericoo changed the base branch from graphite-base/3400 to 2025-10-sfapi-caapi-update January 26, 2026 13:55
@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch from 98b056a to 4c316a0 Compare January 26, 2026 14:53
@fredericoo fredericoo changed the title Add cart warnings component to display feedback to users Display warnings and errors in the cart Jan 26, 2026
@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch from 4c316a0 to 75e10cd Compare January 26, 2026 15:25
@kdaviduik kdaviduik changed the base branch from 2025-10-sfapi-caapi-update to graphite-base/3400 January 26, 2026 19:37
Copy link
Contributor

Please re-request my review when you want me to take a look again :) I saw you made some changes but this comment still applies so I'm assuming it's not yet ready for re-review

image.png

@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch 2 times, most recently from 66385cf to 2ead87a Compare January 27, 2026 11:10
@fredericoo fredericoo changed the base branch from graphite-base/3400 to 2025-10-sfapi-caapi-update January 27, 2026 11:10
Base automatically changed from 2025-10-sfapi-caapi-update to main January 27, 2026 17:08
@fredericoo fredericoo force-pushed the Add_MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION_warning_support branch from 09b9d0e to cdab032 Compare January 28, 2026 18:03
@fredericoo fredericoo requested a review from kdaviduik February 3, 2026 18:40
Copy link
Contributor

@itsjustriley itsjustriley left a comment

Choose a reason for hiding this comment

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

Just some questions/small change suggests. Will work on tophatting.

import {CartForm, Image, type OptimisticCartLine} from '@shopify/hydrogen';
import {useVariantUrl} from '~/lib/variants';
import {Link} from 'react-router';
import {
Copy link
Contributor

Choose a reason for hiding this comment

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

(threading)

Overall this is looking pretty good, though it feels unexpected that pressing the enter key doesn't submit the cart form (only on blur or arrow keys submits it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good shout! its a one liner why not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also fixed an issue where if you type invalid values and then blur it would keep them in the input, now it reverts to the server value so it is truthful to the selection

Copy link
Contributor

Choose a reason for hiding this comment

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

🐛 bug: when submitting with enter, blurring will remove the warning. the warning should stay onblur after submitting with enter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that fetcher data workaround is biting us on the back omg

this is because blurring submits anyway

will have another stab at it in a bit!

const {icon, role} = FEEDBACK_PROPS[type];

return (
<div className={`inline-feedback inline-feedback--${type}`} role={role}>
Copy link
Contributor

Choose a reason for hiding this comment

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

(threading)

I was testing this with VoiceOver and the cart warning never got announced. I imagine because it's trying to set this as role=warning which doesn't exist

Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine this is the kind of thing that would get caught with an accessibility linter / automated accessibility tests, which we are planning to add

Copy link
Contributor Author

@fredericoo fredericoo Feb 5, 2026

Choose a reason for hiding this comment

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

no, role will be either "alert" or "status" but only errors will use alert (see lines 7-19)

have you tried triggering an error?

but we can revert to using role alert on both, as it was!

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes you're right, that's so weird why it's not announcing it. I was only testing with warnings, not errors. maybe try role=alert with voiceover to see if that one works?

@kdaviduik
Copy link
Contributor

@fredericoo let me know (or request my re-review) when this one is ready :)

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.

4 participants