Broadleaf Microservices
  • v1.0.0-latest-prod

Marketing Messages

In the Broadleaf framework, offer’s are able define marketing messages that can be displayed on the storefront. This portion of the SDK handles retrieving marketing messages.

Get Marketing Messages

Operation

BrowseClient#getMarketingMessages(marketingMessageRequest, options);

Parameters

Parameter Type Required? Description

marketingMessageRequest

MarketingMessageRequest

The criteria which define which marketing messages to retrieve.

options

ClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a MarketingMessageResponse.

Examples

Example of retrieving marketing messages for several products
const messages = await browseClient.getMarketingMessages({
  productIds: [ 'product1', 'product2' ],
  cartProductIds: [ 'product3' ],
  cartSubtotal: 15,
});

console.log(messages);

Get Marketing Messages for Item

Operation

BrowseClient#getMarketingMessagesForItem(marketingMessageRequest, options);

Parameters

Parameter Type Required? Description

marketingMessageRequest

ItemMarketingMessageRequest

The criteria which define which marketing messages to retrieve.

options

ClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a list of MarketingMessage.

Examples

Example of retrieving marketing messages for a product
const lineItem = {
  attributes,
  discountable: true,
  isSubscription: false,
  lineNumber: '1', // this is the item's id
  quantity: 1,
  standardPrice: { amount: 10, currency: 'USD'}
}

const messages = await browseClient.getMarketingMessagesForItem({
  item: lineItem,
  locationType: 'EVERYWHERE',
  locale: 'en-US',
  codes: {
    sharedCodes: ['FREESHIP']
  }
});

console.log(messages);