Skip to content

Conversation

@kdaviduik
Copy link
Contributor

@kdaviduik kdaviduik commented Jan 26, 2026

WHY are these changes introduced?

Closes https://github.com/Shopify/developer-tools-team/issues/967.

Adds Storefront API 2025-10 parity for the visitorConsent parameter in @inContext directives.

Note: Most Hydrogen storefronts do NOT need this feature. If you're using:

  • Hydrogen's analytics provider, or
  • Shopify's Customer Privacy API (including third-party consent services integrated with it)

then consent is already handled automatically and you don't need to use this.

This feature is primarily intended for Checkout Kit and other non-Hydrogen integrations that manage consent outside Shopify's standard consent flow.

WHAT is this pull request doing?

Adds visitorConsent support to all cart operations in both @shopify/hydrogen and @shopify/hydrogen-react:

Package Changes
@shopify/hydrogen Add visitorConsent to CartOptionalInput type; update all 17 cart mutations/queries with @inContext(visitorConsent: $visitorConsent)
@shopify/hydrogen-react Update 9 cart queries with visitorConsent variable support

When provided, visitorConsent encodes buyer consent preferences (analytics, marketing, preferences, saleOfData) into the cart's checkoutUrl via the _cs parameter.

HOW to test your changes?

Cart operations now accept visitorConsent as an optional parameter:

await cart.addLines(lines, {
  visitorConsent: {
    marketing: true,
    analytics: true,
    preferences: true,
    saleOfData: false,
  },
});

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

kdaviduik commented Jan 26, 2026

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

@shopify
Copy link
Contributor

shopify bot commented Jan 26, 2026

Oxygen deployed a preview of your 01-25-feat_cart_add_visitorconsent_support_to_incontext_directive branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment January 28, 2026 4:38 AM

Learn more about Hydrogen's GitHub integration.

@fredericoo fredericoo changed the base branch from 2025-10-sfapi-caapi-update to graphite-base/3408 January 26, 2026 10:35
@kdaviduik kdaviduik force-pushed the 01-25-feat_cart_add_visitorconsent_support_to_incontext_directive branch from 32cb4da to aaedbc8 Compare January 27, 2026 02:18
@kdaviduik kdaviduik changed the base branch from graphite-base/3408 to 2025-10-sfapi-caapi-update January 27, 2026 02:18
@kdaviduik kdaviduik force-pushed the 2025-10-sfapi-caapi-update branch from 04f9469 to bce6ffc Compare January 27, 2026 02:28
@kdaviduik kdaviduik force-pushed the 01-25-feat_cart_add_visitorconsent_support_to_incontext_directive branch from aaedbc8 to ad445a5 Compare January 27, 2026 02:28
@fredericoo fredericoo changed the base branch from 2025-10-sfapi-caapi-update to graphite-base/3408 January 27, 2026 11:10
@kdaviduik kdaviduik force-pushed the 01-25-feat_cart_add_visitorconsent_support_to_incontext_directive branch from ad445a5 to 8444e31 Compare January 28, 2026 04:24
@kdaviduik kdaviduik changed the base branch from graphite-base/3408 to main January 28, 2026 04:33
variables: {
cartId: optionalParams?.cartId || options.getCartId(),
attributes,
...optionalParams,
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 was missing before. it's present in the other ones

@kdaviduik kdaviduik marked this pull request as ready for review January 28, 2026 04:36
@kdaviduik kdaviduik requested a review from a team as a code owner January 28, 2026 04:36
Adds Storefront API 2025-10 parity for the `visitorConsent` parameter in
`@inContext` directives across all cart operations.

**Important:** Most Hydrogen storefronts do NOT need this feature. If you're
using Hydrogen's analytics provider or Shopify's Customer Privacy API
(including third-party consent services), consent is handled automatically.

This feature is primarily intended for Checkout Kit and other non-Hydrogen
integrations that manage consent outside Shopify's standard consent flow.

Changes:
- Add `visitorConsent` to `CartOptionalInput` type with clear JSDoc explaining
  the niche use case
- Update all cart mutation/query defaults to accept and pass through
  `visitorConsent` to the `@inContext` directive
- Update `hydrogen-react` cart queries with `visitorConsent` variable support
@kdaviduik kdaviduik force-pushed the 01-25-feat_cart_add_visitorconsent_support_to_incontext_directive branch from 8444e31 to a2645af Compare January 28, 2026 04:36
@kdaviduik kdaviduik merged commit 38f8a79 into main Jan 30, 2026
13 of 14 checks passed
@kdaviduik kdaviduik deleted the 01-25-feat_cart_add_visitorconsent_support_to_incontext_directive branch January 30, 2026 02:13
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.

2 participants