Consent management

Consent management

Introduction

This section will cover the basics of fetching consent templates, giving consent and removing consent.

To fetch consent templates, you can use the getConsentTemplates method.

import { sdk } from '~/sdk';

const { consentTemplates } = await sdk.commerce.getConsentTemplates();

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
});

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' });