Class ShopperConsentMgr

Provides static helper methods for managing shopper marketing consent subscriptions.

This API enables retrieving and updating marketing consent preferences. Consent subscriptions define communication categories (e.g., “Newsletter”, “Product Updates”) and the channels (EMAIL, SMS, WHATSAPP) through which marketing communications can be sent.

Prerequisites:

  • The Marketing Consent feature must be enabled and configured
  • For consent status retrieval, the current request must have a customer context

Example usage:

1var ShopperConsentMgr = require('dw/customer/consent/ShopperConsentMgr');
2
3// Get all subscriptions for the current site
4var subscriptions = ShopperConsentMgr.getSubscriptions();
5
6for each (var sub in subscriptions) {
7    trace('Subscription: ' + sub.subscriptionId + ' - ' + sub.title);
8    trace('Available channels: ' + sub.channels.join(', '));
9}
10
11// Get subscriptions with consent status (for authenticated customers)
12var subsWithStatus = ShopperConsentMgr.getSubscriptions(null, true);
13
14// Update consent for a specific subscription
15ShopperConsentMgr.updateSubscription(
16    'customer@example.com',
17    'newsletter-subscription',
18    'EMAIL',
19    'OPT_IN'
20);

See Also:

Property Summary 

PropertyDescription
subscriptions: Collection (read-only)Retrieves marketing consent subscriptions for the current site.

Constructor Summary 

This class does not have a constructor, so you cannot create it directly.

Method Summary 

MethodDescription
static getSubscriptions()Retrieves marketing consent subscriptions for the current site.
static getSubscriptions(List, Boolean)Retrieves marketing consent subscriptions for the current site with optional filtering and status.
static updateSubscription(String, String, String, String)Updates consent status for a subscription.

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Property Details 

subscriptions 

subscriptions: Collection (read-only)

Retrieves marketing consent subscriptions for the current site.

This method returns all available consent subscriptions without consent status information.


Method Details 

getSubscriptions() 

static getSubscriptions(): Collection

Retrieves marketing consent subscriptions for the current site.

This method returns all available consent subscriptions without consent status information.

Returns:

Throws:

  • ShopperConsentException - if the consent feature is not enabled or retrieval fails.

getSubscriptions(List, Boolean) 

static getSubscriptions(tags: List, includeConsentStatus: Boolean): Collection

Retrieves marketing consent subscriptions for the current site with optional filtering and status.

Use this method to retrieve subscriptions filtered by tags and optionally include the current consent status for authenticated customers.

Parameters:

  • tags - Optional list of tags to filter subscriptions. Pass null for all subscriptions.
  • includeConsentStatus - If true, includes the current consent status for each subscription. Requires a customer context.

Returns:

Throws:

  • ShopperConsentException - if the consent feature is not enabled, retrieval fails, or consent status retrieval fails.

updateSubscription(String, String, String, String) 

static updateSubscription(contactPointValue: String, subscriptionId: String, channel: String, status: String): void

Updates consent status for a subscription.

This method updates the consent status in Salesforce Core for the specified contact point and subscription channel combination.

Parameters:

  • contactPointValue - The contact point value (email address or phone number).
  • subscriptionId - The subscription ID.
  • channel - The channel type ("EMAIL", "SMS", or "WHATSAPP").
  • status - The consent status ("OPT_IN" or "OPT_OUT").

Throws:

  • ShopperConsentException - if the consent feature is not enabled or update fails.