Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guide iconUser guide
Developer guide iconDeveloper guide
Admin guide iconAdmin guide
English
  • Русский
  • English
Login
    User documentationGetting StartedFAQAltcraft glossary
      Profiles and databasesarrow
    • Subscription resourcesManaging databasesSubscriber profileProfiles import and data updateScheduled customer data importAutomatic data collectionBulk customers profiles updateDouble opt-in subscriptionSuppression listsProfile relationsProfile history exportProfile exportCreating a static segment based on import resultsHow to open a CSV fileMatchingTypes of fields in the databaseGlobal control groupsSubscription Manager
      Communication channelsarrow
      • Email channelarrow
      • Email: ISP interactions best practicesEmail: sending domain configurationEmail: setting up and using postmastersБыстрый старт
        Push channelarrow
        • Mobile Pusharrow
        • Settings & implementation
            Integrate your app with Altcraftarrow
          • Providers: push message structureProcessing and adding a subscriptionEvent registration
          Web pusharrow
        • Preliminary Settings
            Web browser push configurationarrow
          • Firebase Cloud messagingApple SafariMozilla Services
          Connecting Web Push to a WebsiteTransferring Data to the PlatformWeb Push SDK Methods
            Import of subscriptions from third-party push servicesarrow
          • Migrating push subscriptions from third-party servicesHow to transfer push subscriptions configured for Safari?Migration from OneSignal
      SMS channel
        Creating mailing from scratcharrow
      • EmailSMSWeb PushMobile PushWhatsAppViber*™Руководство: SMS-рассылка через VK NotifyMAX BotMAX GroupNotifyTelegram BotTelegram Group
      Communication Channels WorkflowРуководство: SMS-рассылка через УТШРуководство: push-рассылка через сервис от "Согласие"
      Segmentationarrow
    • Static SegmentsDynamic SegmentsUpdatable Segments
        Segmentation Conditionsarrow
      • Segmentation by Profile dataSegmentation by Interactions with EntitiesSegmentation by Activity of the channelSegmentation by external dataSegmentation by external SQL tablesSegmentation by Profile structure
      Best Send Time (BST)Logical operators "AND" and "OR"Recommendations for working with segments
      Message templatesarrow
      • Working with message templatesarrow
      • Working in the editorEmail-templateSMS templatePush templateMAX templateTelegram templateWhatsApp templateViber™ templateNotify template
        Visual editor for email-templatearrow
      • Visual editor interfaceAdding blocksElements and their settingsCustom blocksStyle managerLayer manager
      Template fragmentsImage galleryContent personalizationCreating tables based on array elementsBlock editor for email template
        Altcraft Variables and Functionsarrow
      • Logical expressions in messagesLoops in messagesMarket variables in templatesUsing the JSONPath functionality
        Dynamic content in messagesarrow
      • Dynamic HTML contentDynamic JSON contentContent from SQL database in templatesDynamic API content
      Importing and exporting a message templateImporting a template from a third-party serviceExporting a template from Pixcraft
      Mailingsarrow
    • Mailings calendarBroadcast mailingsRegular mailingTrigger mailingMultivariate testingMailing testingMailing schedulePlacement mailing
      Campaignsarrow
    • Working with CampaignsLocal control groups (LCG)Stratification Violation ErrorAudience expansionAudience building
      Automation scenariosarrow
    • Managing scenariosNodes of the scenarioClassic marketing scenariosStep-by-step welcome scenario guideScenario for automatic notification of the managerAbandoned cart scenario
      Marketarrow
    • Market settings
        Productsarrow
      • How to create a product manuallyHow to import a product from a fileScheduled product importProduct and SKU SegmentsPreparing the YML file
      OrdersMarket variables in message templateGuide: how to send an order confirmation email
      Loyalty programsarrow
    • Loyalty programsLoyalty integration with external systemsБыстрый стартBasic loyalty program use casesOrder SegmentsPromotion codes
      Reports and analyticsarrow
    • Channel reportTraffic report
        Summary reportarrow
      • Summary report metrics
      Cohorts reportLifetime reportFunnels reportGoals reportAudience growth reportClick map reportLoyalty programs reportBounces reportUndeliveries reportReport on global control groups
      Integrationsarrow
      • Action hooksarrow
      • Altcraft Action HooksAction hooks event typesAction Hook Message StructureJSON batch request (HTTP POST action hook)Message to RabbitMQ brokerMessage to RabbitMQ exchangerMessage to Kafka brokerTest event
        Integration of third-party services using Albatoarrow
      • Connecting Altcraft to Albato Launching the welcome scenario using AlbatoTransmitting event dataSetting app a trigger mailingEvent registrationGoogle Sheets and Altcraft integration AmoCRM and Altcraft integration
      Facebook Ads Manager™Google Ads AudiencesMAXYandex.Audience™VK Ads™Static segment synchronizationYandex AppMetrica™Tilda™Lpgenerator™WhatsAppViber*™ integrationIntegration scopeData Transmitted During SynchronizationNotify
      Weblayersarrow
      • Formsarrow
      • Create a formForm constructorAppearanceActions after form activationData analyticsBinding data channel and formsConditional logic in forms and surveysNPS testing
        Pixelsarrow
      • Goal customer actions and scoring
        Pop-upsarrow
      • Creating and publishing a pop-upSetting up a popup in the code editorManaging pop-ups manually via scriptPopup analyticsGuide: pop-up for push subscriptionsCase: Creating a pop-up with the "Wheel of Fortune" widgetBasic cases of placing a popup via the Tag Manager
        Tag Managerarrow
      • Configuring and installing Tag ManagerTrigger typesVariables typesLinking a pixel and the Tag manager
      Settingsarrow
    • Account settingsCustom linksVirtual sendersSending policiesAudit journalTags FAQ
        Users, groups and accessarrow
      • Two-Factor Authentication (2FA)
        Connectionsarrow
      • Connection to Facebook Ads ManagerConnection to Google AdsConnecting to Yandex.Audience™Connection to 360dialogConnection to EdnaConnection to Devino TelecomConnection to SMSTrafficConnection to VK Ads™Connection to MTS OmniChannelCustom Authentication ConnectionOAuth2 connectionBasic Authentication connectionToken Authentication connectionConnection to RapportoMAX connectionConnection to Notify
      Attribute settings
      API requests: where to startarrow
    • Import or update a profileTrigger mailing launchEngage profile in scenario
      Changelogarrow
    • v2026.1.76v2025.4.75v2025.4.74v2025.3.73v2025.2.72v2025.1.71v2024.4.70v2024.3.69v2024.2.68.2v2024.1.68
    Documentation archivelibrary
  • Message templates
  • Altcraft Variables and Functions
  • Market variables in templates

Market variables in templates

Variables​

There are four variables for Market:

  • products — function selects products
{products("<filter>" 10 "manufacturer_name" "desc")}
  • sku — function selects SKUs
{sku("<filter>" 10 "manufacturer_name" "desc")}
  • orders — the function selects orders from the list of profile orders
{orders("<filter>" 10 "status" "asc")}
  • order — the function selects one order from the list of profile orders
{order("<filter>")}

Function arguments​

("<filter>" 10 "manufacturer_name" "desc")

ArgumentRequiredDescription
"<filter>"YesThe filter is a string of conditions. Allows you to select products, SKUs, orders, or order lines that meet specified conditions.

For example, you can select products from the same manufacturer or orders that exceed a specific cost.

See below for details.
10YesLimit. How many array elements to iterate over. The maximum value is 30.

For example, if you specify 10, then the filter will select the first ten elements from the array.
"manufacturer_name"NoSort objects by the specified field.

By default — no sort.
"desc"NoSort direction.

asc — ascending (by default)
desc — descending

Filter​

The filter consists of fields and operators. Each object in the market has fields. For example, products and SKUs have a name field (product name). Orders have a total_price field (total cost of the order). In a filter, you specify a field and a value that it should match. If the field of the object matches the value, this object will be selected and its data can be substituted into the template.

Filter example​

Let's add the "Orders" variable to the template:

{orders ("order.total_price == '200 USD' && (order.custom_fields.field == 'lead._region')" 10 "id" "desc")}

The bold part of the variable is the filter. Let's consider it in parts:

  • order.total_price == '200 USD': the condition will select all orders with a cost equal to $200.

  • order.custom_fields.field == 'lead._region' - the condition will select orders with the additional 'field'. You can specify any additional (custom) field instead of "field". The specified equality means that the value of the "field" must match the value of the region in the customer's profile ("lead._region").

  • && is an operator. It indicates that both conditions must be met.

  • The number 10 indicates the number of output objects, "id" indicates the filter field, and "desc" indicates the descending sort.

Below are the fields and operators available in the filter.

Operators and functions in a filter​

OperatorDescriptionExampleWhat will be selected
>greaterorder.delivery_cost > '10 USD'Orders with shipping costs over $10
>=greater or equalorder.delivery_cost >= '10 USD'Orders with a shipping cost of $10 or more
<lesssku.count < '10'The number of SKUs for sale is less than 10
<=less or equalsku.count <= '10'The number of SKUs for sale is 10 or more
==equalsorder.status == '1'

order.custom_fields('date') == '2024-12-25'
Orders with "new" status

Orders with date December 25, 2024
!=not equalproduct.manufacturer_name != 'Apple'Products not manufactured by Apple
&&AND (both conditions match)product.manufacturer_name == 'Apple' && product.price < '200 USD'Apple products cost more than $200
||OR (one of the conditions matches)sku.manufacturer_name == 'MSI' || sku.manufacturer_name == 'Acer'SKU with manufacturer MSI or Acer
in('<field_name>', 'value1', 'value2'...'valueN')The field value (<field_name>) matches one of the specified values ('value1', 'value2')in(product.external_id,'1','2','3')Products with ID equal to 1, 2 or 3
contains('<field_name>', 'value1', 'value2'...'valueN')One of the array elements matches one of the specified values.

<field_name> — array

'value1', 'value2' — values to match.

Used if the field is an array, i.e. contains several elements (for example: categories, images, additional fields).
contains(product.categories,'smartphone')Products included in the category "smartphone"
len('<field_name>', <operator>, <number> )Checks the length of an array. Compares the number of elements in the array with the specified number.

<field_name> — array field (e.g., product.pictures)

<operator> — comparison operator (>, >=, <, <=, ==, !=)

<number> — integer for comparison.
len(product.pictures, !=, 0)Products that have a number of pictures not equal to zero (i.e., have at least one picture)

Working with custom fields​

Two syntaxes are available for filtering by custom fields:

Universal syntax (recommended)​

(product.custom_fields('external_id'))
info

We recommend using the universal syntax product.custom_fields('external_id') because it supports all types of identifiers — both numeric and string, including special characters. This option guarantees correct filtering regardless of your custom field's external_id format.

Examples:

{for $product in products("product.custom_fields('123') == 'red'")}
{for $product in products("in(product.custom_fields('color'), 'red', 'blue')")}
{for $product in products("sku.custom_fields('45') > '100'")}

String syntax (limited)​

(product.custom_fields.field_name)
info

The old syntax product.custom_fields.field_name can only be used if the field's external_id consists exclusively of alphabetic characters and does not contain numbers, hyphens, or other special characters.

Example:

{for $product in products("product.custom_fields.brand == 'Apple'")}

List of available fields in filters​

Products​

Prefix — product.

FieldDescription
product.external_idProduct ID
product.nameProduct name
product.manufacturer_nameManufacturer's name
product.urlURL of the product page on the store website
product.picturesProduct Image URL
product.countNumber of products available for sale
product.is_availableIs the product in stock at the store?
product.deliveryPossibility of delivery (for all regions to which the store delivers)
product.barcodeList of product barcodes from the manufacturer
product.categoriesProduct category ID
product.custom_fields.&lt;field_external_id&gt;Custom product field ID. For numeric IDs use custom_fields('123')

SKU​

Prefix — sku.

FieldDescription
sku.external_idSKU ID
sku.nameSKU name
sku.manufacturer_nameManufacturer's name
sku.urlURL of the SKU page on the store website
sku.picturesSKU image URL
sku.countNumber of SKUs available for sale
sku.is_availableIs the SKU in stock at the store?
sku.deliveryPossibility of delivery (for all regions to which the store delivers)
sku.barcodeList of SKU barcodes from the manufacturer
sku.categoriesSKU category ID
sku.custom_fields.&lt;field_external_id&gt;Custom sku field ID. For numeric IDs use custom_fields('123')

Orders​

Prefix — order.

FieldDescription
order.external_idOrder ID
order.statusOrder status ID

1 - new
2 - delivered
3 - paid
4 - cancelled
5 - partial refund
order.delivery_costShipping cost
order.total_priceTotal cost of the order.

It consists of the number of each item in the order and the cost of delivery.
order.custom_fields.<external_id поля>Custom order field ID
order.real_create_timeOrder creation time
order.real_update_timeOrder update time
order.region_external_idRegion ID

Sorting by Custom Fields​

Sometimes you need to sort objects by their custom field values (the custom_fields object).
Custom fields are stored in the database as a JSON string. Therefore, to access a field inside the JSON for sorting, you can use the -> operator.

Example of accessing a key:

custom_fields -> 'priority'

Usage in a sort parameter function (using products as an example):

{for $index $el = products("contains(product.categories,'smartphone')" 3 "custom_fields -> 'priority'" "desc")}
{$el.name} — {$el.price}
{else}
if empty array
{end}

In this example, the product list is first filtered by the smartphone category, then sorted by the value of the priority key inside custom_fields in descending order, and the first 3 results are displayed.

info

Important

  • The -> operator is used only in the sort parameter to access a JSON key.
  • For filtering by custom fields, use the dot notation from the "Filter" section, for example: order.custom_fields.field == 'value'.
  • The -> operator is not a market operator — it is a database operator (PostgreSQL) used for the query, so this sorting method should be considered a workaround.

Use cases​

Any variable in the market is an array. For example, products contains an array of all products uploaded to the platform, and orders contains an array of orders for one profile. To iterate over an array, use loops.

  • Searching the array of products (products)
  • Search SKU (sku) array
  • Searching the array of all orders (orders)
  • Search for items in order with id = '0001' (order + lines)

Outputs 5 Apple products in an email:

You might be interested in these products:
{for $index $el = products("product.manufacturer_name == 'Apple'" 5 "external_id" "desc")}
{$el.name} - {$el.price}
{else}
if empty array
{end}

7 cheapest smartphones:

The best smartphone prices for you and your loved ones:
{for $index $el = products("product.categories == 'smartphone'" 7 "price" "asc")}
{$el.name} - {$el.price}
{else}
if empty array
{end}

Goods with delivery:

Delivered to your door:
{for $index $el = products("product.delivery == true" 10 "name" "desc")}
{$el.name} - {$el.price}
{else}
if empty array
{end}

Smartphones under 20000:

Smartphones you will like:
{for $index $el = sku("contains(sku.categories,'smartphone') && sku.price < '20000 RUB'" 3 "price" "asc")}
{$el.name} - {$el.price}
{else}
if empty array
{end}

IPhone with more than 128GB of storage:

Enough memory for everything:
{for $index $el = sku("contains(sku.name,'IPhone') && sku.custom_fields.memory >= '128'" 10 "name" "desc")}
{$el.name} - {$el.price}
{else}
if empty array
{end}

Orders at pickup points:

Orders are waiting for you at the pickup point:
{for $index $el = orders("order.status == '2'" 10 "external_id" "desc")}
Order # {$el.external_id}
Due: {$el.total_price}
{else}
if empty array
{end}

List of new orders:

New orders in the last week:
{for $index $el = orders("order.status == '1'" 20 "external_id" "desc")}
Order # {$el.external_id}
Due: {$el.total_price}
{else}
if empty array
{end}
{for $index $el = order("order.external_id == '0001'")}
{if $index equal "lines"}
{for $i $line = $el}
{$line.name} position name: {$line.name}
{$line.price} Item price: {$line.final_price_of_line}
{end}
{end}

{if $index equal "delivery_cost"}
{$el} {$delivery_cost} {$el}
{end}
{if $index equal "total_price"}
To pay: {$el}
{end}

{else}
if empty array
{end}

List of available fields for substitution in the template​

products/sku​

Substitution fieldDescription
external_idProduct/SKU ID
nameProduct/SKU name
manufacturer_nameManufacturer's name
urlURL of the product page on the store website
picturesList of URL links to product images (array)
countQuantity of products/SKU available for sale
availableIs the product/sku in stock at the store?
deliveryPossibility of delivery (for all regions to which the store delivers)
barcodeList of product barcodes from the manufacturer (array)
categoriesList of product/SKU category IDs (array)
custom_fields.<external_id поля>Custom field ID. For numeric IDs and special characters use custom_fields('external_id') syntax.
priceCurrent product price
old_pricePrevious product price
regional_data.<region_external_id>.countQuantity of products/SKU available for sale in the specified region.

regional_data is product/sku data that varies by region.

<region_external_id> is region ID.
regional_data.<region_external_id>.deliveryPossibility of delivery to the specified region
regional_data.<region_external_id>.availableIs the product/SKU in stock in the specified region?
regional_data.<region_external_id>.priceProduct/SKU price in the specified region

orders / order​

Substitution fieldDescription
external_idOrder ID
statusOrder status ID
delivery_costShipping cost
total_priceTotal cost of the order.

It consists of the cost of each item in the order and the cost of delivery.
custom_fields.<external_id поля>Custom field ID. For numeric IDs and special characters use custom_fields('external_id') syntax.
create_timeOrder creation time
update_timeOrder update time
region.external_idRegion ID
linesOrder line. Only for the order function.

lines​

Substitution fieldDescription
idLine ID
external_idOrder line additional ID
custom_status_external_idOrder line status ID
base_price_per_itemBase price
final_price_of_lineFinal price
countQuantity of products or skus in the line
custom_fields.<field_external_id>ID for the custom field of the order line. For numeric IDs and special characters use custom_fields('external_id') syntax.
product_external_idLine product ID
nameLine name
manufacturer_nameManufacturer's name of the line product
urlURL of the page of the line product
picturesList of URL links to images of the line product
balanceStock quantity
availableIs the line product in stock at the store
deliveryPossibility of delivery of the line product (array)
barcodesList of barcodes of the line product (array)
categoriesList of category IDs of the line product
info

Custom field override priority:
(defines which field values are applied first)

SKU > Product > Order-item

Last updated on Mar 12, 2026
Previous
Loops in messages
Next
Using the JSONPath functionality
  • Variables
  • Function arguments
  • Filter
    • Filter example
    • Operators and functions in a filter
    • Working with custom fields
      • Universal syntax (recommended)
      • String syntax (limited)
    • List of available fields in filters
      • Products
      • SKU
      • Orders
    • Sorting by Custom Fields
  • Use cases
  • List of available fields for substitution in the template
    • products/sku
    • orders / order
    • lines
© 2015 - 2026 Altcraft, LLC. All rights reserved.