dw.customer.consent.ShopperConsentMgr
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'
);
This method returns all available consent subscriptions without consent status information.
This method returns all available consent subscriptions without consent status information.
Use this method to retrieve subscriptions filtered by tags and optionally include the current consent status for authenticated customers.
This method updates the consent status in Salesforce Core for the specified contact point and subscription channel combination.