# Class ShopperConsentMgr

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.customer.consent.ShopperConsentMgr](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.ShopperConsentMgr.md)

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

**See Also:**

- [MarketingConsentSubscription](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.MarketingConsentSubscription.md)
- [ConsentStatusEntry](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.ConsentStatusEntry.md)

## Property Summary

| Property                                                                                                                                 | Description                                                     |
| ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [subscriptions](#subscriptions): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(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

| Method                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Description                                                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| static [getSubscriptions](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.ShopperConsentMgr.md#getsubscriptions)()                                                                                                                                                                                                                                                                                                                                                                              | Retrieves marketing consent subscriptions for the current site.                                    |
| static [getSubscriptions](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.ShopperConsentMgr.md#getsubscriptionslist-boolean)([List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md), [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md))                                                                                                                                                                                               | Retrieves marketing consent subscriptions for the current site with optional filtering and status. |
| static [updateSubscription](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.ShopperConsentMgr.md#updatesubscriptionstring-string-string-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)) | Updates consent status for a subscription.                                                         |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Property Details

### subscriptions

- subscriptions: [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(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](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md)
  - : Retrieves marketing consent subscriptions for the current site.

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

    **Returns:**

    - A collection of [MarketingConsentSubscription](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.MarketingConsentSubscription.md) objects.

    **Throws:**

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

***

### getSubscriptions(List, Boolean)

- static getSubscriptions(tags: [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md), includeConsentStatus: [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md)
  - : 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](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.customer.consent.MarketingConsentSubscription.md) objects.

    **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](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), subscriptionId: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), channel: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), status: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): 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.

***
