Consent management
Introduction
This section will cover the basics of fetching consent templates, giving consent and removing consent.
Fetching consent templates
To fetch consent templates, you can use the getConsentTemplates method.
import { sdk } from '~/sdk';
const { consentTemplates } = await sdk.commerce.getConsentTemplates();
Giving consent
To give consent, you can use the giveConsent method. It requires consentTemplateId
as a parameter.
import { sdk } from '~/sdk';
const givenConsent = await sdk.commerce.giveConsent({
consentTemplateId: 'MARKETING_NEWSLETTER',
consentTemplateVersion: 0
});
Removing consent
To remove consent, you can use the removeConsent method. It requires consentCode
as a parameter.
import { sdk } from '~/sdk';
await sdk.commerce.removeConsent({ consentCode: '000007PU' });