Product Helper Functions

The Product Helper functions can be used to fetch data from the Database, or when a Product is used in an event or User Journey Step.

Fetch from Product Feed

findProduct Function

The findProduct method can be used to fetch product data by resolving SKUs from different sources. It supports:

1. User traits: extracting a single SKU stored as a trait (also Array).

2. Events: parsing SKUs directly from event payloads

The #findProduct fetches a product from your Product Feed, by using an SKU. By itself, it's a limited function, but when used in conjunction with #includeProducts or #findMatching, it can be a powerful tool for customizing your messages.

Examples

The first example shows how to use the #findProduct function to fetch the image link of a users' favourite Product, which has been attached to the User trait via the User Feed.

{{#findProduct user.[traits.favoriteProductSku]}}
    {{[properties.image]}}
{{/findProduct}}

Use case: 

Retrieves the SKU from the trait string array along with the related feed information. Since traits.recoModel can contain up to 10 SKUs, we specifically extract the SKU at position 3 (index 2).

{{#findProduct user.[traits.recoModel].[2]}}
{{#findProduct [properties.sku]}}
{{[properties.link]}}
{{[properties.title]}}
{{/findProduct}}{{/findProduct}}

 

Get the remaining Stock Count for products in the Cart

The second example shows how to use the #findProduct function together with #includeProducts to show the remaining stock for the three most expensive items in the cart.

{{#includeProducts '{
    "cartProducts": true,
    "options": {
        "maxResults": 3, 
        "sortBy": "properties.price", 
        "desc": true, 
        "distinct": true
        }
      }'
}}
 {{#findProduct [properties.sku]}}
 {{[properties.stockRemaining]}}
 {{/findProduct}}
{{/includeProducts}}

#findProduct extension to search a list (also within another product)

we've included an update to our #findProduct function that can enable you to go even further than before by pulling a specific element from a list (or even a list attached to another product). Here's what the list could look like in the product feed:

{
  mainProductSKU: 111111,  
  accessoriesSKUS: 998776, 776655, 223344, 778899
}

This works great with simple cross-selling cases, especially when you'd like your customer to buy accessories for an item or even other related items. Here's an example of how to search within another product:

{{#findProduct [properties.sku]}} <!-- this searches for the main product -->
    {{#findProduct [properties.accessoriesSKUS] itemFromList=0}} <!--this searches within the main product for the first item in the list-->
        {{[properties.name]}}
        {{[product.price]}}
    {{/findProduct}}
{{/findProduct}}

The above example will search the "mainProductSKU" (111111 in our example) and returns the details of the first accessory (itemFromList=0 in our example, which is 998776).

FindProduct within journey steps in the Real Time Campaign only

For example, in our Real time campaign we have Completed Order event as an initial trigger event. As this event is the first step within the journey, it holds relevant product-related data such as the SKU. To enrich the campaign content with dynamic product information, we utilize the #findProduct handlebar helper. This allows us to fetch specific product attributes from the product feed, based on the SKU captured in the first journey step.

For example, the following expression retrieves the product title that corresponds to the SKU from the "Completed Order" event:

{{#findProduct journey.steps.[0].[properties.sku]}} 
{{[properties.title]}}
{{/findProduct}}

Added to the basket and not bought product

The customer journey should be initiated by the "Added Product" event, which indicates that a user has placed an item into their basket. Following this trigger, the product should remain in the basket for a specified period of time without any further purchasing activity.

During this time, the system will monitor whether the user proceeds to complete the purchase by tracking the "Completed Order" event. If this event does not occur within the defined timeframe, the assumption is that the purchase was abandoned.

In such a case, we will initiate a reminder email to re-engage the user. This email will include dynamic product information retrieved via the #findProduct Handlebars helper, using the SKU from the original "Added Product" event. The message will display key product attributes such as the product title and formatted price using formatDigits, along with a conditional display using #cif to tailor the content based on available properties or user behavior.

{{#findProduct journey.steps.[0].[properties.sku]}}
{{[properties.title]}}
{{[properties.attributes.model]}}
{{[properties.bigImageLink]}}
{{formatDigits '{"propertyName": "[properties.price]", "numberDecimals": 0,"decimalSeparator": ",", "thousandsSeparator": ".","percentage": "false"}'}}
{{#cif '{"property": "properties.rate", "operator": "==", "value": "0"}'}}n/a{{else}}{{[properties.attributes.consumptionCombined]}}
{{/cif}}
{{/findProduct}}

#findProduct in Stories

{{#findProduct story.blocks.[blockID].[properties.sku]}} 
{{[properties.Description]}}
{{/findProduct}}