Skip to content

feat(scripts): integrate consent manager with control panel privacy setting#2661

Merged
matthewvolk merged 1 commit intocanaryfrom
feat/consent-manager-script-loader-cp-setting
Oct 31, 2025
Merged

feat(scripts): integrate consent manager with control panel privacy setting#2661
matthewvolk merged 1 commit intocanaryfrom
feat/consent-manager-script-loader-cp-setting

Conversation

@matthewvolk
Copy link
Copy Markdown
Contributor

Note

This PR replaces #2658

Closes #2658

What/Why?

This PR integrates Catalyst's consent manager with the BigCommerce Control Panel's Cookie Consent setting (Channels > Channel > Customers' privacy > Turn on cookie consent banner for my store), allowing merchants to centrally control whether the consent banner is shown to storefront visitors. The implementation queries the site.settings.privacy.cookieConsentEnabled field from the Store Settings API and threads it through the consent manager component hierarchy. When a merchant disables cookie consent in the Control Panel, the consent banner is suppressed and the showConsentBanner endpoint handler returns a response with showConsentBanner: false and jurisdiction: { code: 'NONE' } which has the effect of auto-granting consents inside the c15t library.

Testing

Demo:

cookie-consent-enabled-cp-setting.mov

Migration

This PR modifies the following files that you may encounter merge conflicts with:

  1. core/app/[locale]/layout.tsx:

    • Added privacy.cookieConsentEnabled field to RootLayoutMetadataQuery (lines 34-36)
    • Added isCookieConsentEnabled constant derived from query result (lines 130-131)
    • Updated ConsentManager component to accept isCookieConsentEnabled prop (line 137)
    • Resolution tip: Add the privacy { cookieConsentEnabled } field to your metadata query, extract it from the result, and pass it to <ConsentManager isCookieConsentEnabled={isCookieConsentEnabled} ... />
  2. core/components/consent-manager/index.tsx:

    • Added isCookieConsentEnabled: boolean to ConsentManagerProps interface
    • Prop is forwarded to ConsentManagerProvider
    • Exported C15tScripts type is now imported from consent-providers.tsx
    • Resolution tip: Update your interface to include the new required prop and ensure it's passed down
  3. core/components/consent-manager/consent-providers.tsx:

    • Exported C15tScripts type (line 9)
    • Added isCookieConsentEnabled prop to interface
    • Updated showConsentBanner endpoint handler to be a closure that passes the setting: showConsentBanner: () => showConsentBanner(isCookieConsentEnabled)
    • Resolution tip: The showConsentBanner function is now wrapped in an arrow function to pass the control panel setting
  4. core/lib/consent-manager/handlers.ts:

    • showConsentBanner now accepts isCookieConsentEnabled: boolean parameter
    • Returns early with showConsentBanner: false when consent is disabled in CP
    • Resolution tip: Update any custom handler implementations to accept and handle this parameter

If you've customized your consent manager implementation, ensure that:

  • The cookieConsentEnabled field is queried from BigCommerce API
  • The boolean value flows from your layout → ConsentManager → ConsentManagerProvider → showConsentBanner handler
  • Your handler respects the setting and returns appropriately when consent is disabled

@matthewvolk matthewvolk requested a review from a team October 31, 2025 17:31
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 31, 2025

🦋 Changeset detected

Latest commit: 500936e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
catalyst-b2b Ready Ready Preview Comment Oct 31, 2025 8:26pm
catalyst-canary Ready Ready Preview Comment Oct 31, 2025 8:26pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
catalyst Ignored Ignored Oct 31, 2025 8:26pm

Copy link
Copy Markdown
Contributor

@jorgemoya jorgemoya left a comment

Choose a reason for hiding this comment

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

Maybe a dumb question, but when consent manager is disabled, what is the default consent for scripts? Do they all run or are they all disabled?


interface ConsentManagerProps extends PropsWithChildren {
scripts: C15tScripts;
isCookieConsentEnabled: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Biggest 🍹 ever, but what if we rename to isEnabled instead?

@matthewvolk matthewvolk force-pushed the feat/consent-manager-script-loader-cp-setting branch from 818e7eb to 500936e Compare October 31, 2025 20:25
@matthewvolk matthewvolk added this pull request to the merge queue Oct 31, 2025
Merged via the queue into canary with commit be00b44 Oct 31, 2025
11 checks passed
@matthewvolk matthewvolk deleted the feat/consent-manager-script-loader-cp-setting branch October 31, 2025 20:28
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.

3 participants