Skip to main content

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
==equalorder.status == 1Orders with status "new"
!=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"

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

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

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

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.

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}

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
is_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
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
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
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
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
custom_fields.<field_external_id>ID for the custom field of the order line