Class ShopperConsentMgr
dw.customer.consent
Class ShopperConsentMgr
Object
dw.customer.consent.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:


 var ShopperConsentMgr = require('dw/customer/consent/ShopperConsentMgr');

 // Get all subscriptions for the current site
 var subscriptions = ShopperConsentMgr.getSubscriptions();

 for each (var sub in subscriptions) {
     trace('Subscription: ' + sub.subscriptionId + ' - ' + sub.title);
     trace('Available channels: ' + sub.channels.join(', '));
 }

 // Get subscriptions with consent status (for authenticated customers)
 var subsWithStatus = ShopperConsentMgr.getSubscriptions(null, true);

 // Update consent for a specific subscription
 ShopperConsentMgr.updateSubscription(
     'customer@example.com',
     'newsletter-subscription',
     'EMAIL',
     'OPT_IN'
 );
 

Properties
subscriptions  :  Collection  (Read Only)
Retrieves marketing consent subscriptions for the current site.

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

Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Method Summary
static getSubscriptions() : Collection
Retrieves marketing consent subscriptions for the current site.
static getSubscriptions(tags : List, includeConsentStatus : boolean) : Collection
Retrieves marketing consent subscriptions for the current site with optional filtering and status.
static updateSubscription(contactPointValue : String, subscriptionId : String, channel : String, status : String) : void
Updates consent status for a subscription.
Method Detail
getSubscriptions
static getSubscriptions() : Collection
Retrieves marketing consent subscriptions for the current site.

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

Returns:
A collection of MarketingConsentSubscription objects.
Throws:
ShopperConsentException - if the consent feature is not enabled or retrieval fails.

getSubscriptions
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:
A collection of MarketingConsentSubscription objects.
Throws:
ShopperConsentException - if the consent feature is not enabled, retrieval fails, or consent status retrieval fails.

updateSubscription
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.