Skip to content

Displaying products in the code editor: methods reference

The code editor lets you pull live product data into your contents using Razor syntax. Depending on what you want to show – recommendations, cart contents, recently viewed products, price drops, or order details – each method returns a list of products and the store currency.

Method overview

MethodDescriptionReturnsAvailable in
GetRecommendationsProducts recommended for the current customer based on their behavior.Products + CurrencyEmail Newsletter, Scenario Email, Pop-up, Banner
GetCartProducts the current customer has added to their cart.Products + CurrencyScenario Email (with start point validation), Pop-up, Banner
GetAbandonedBrowseProductsProducts the customer browsed but didn’t buy.Products + CurrencyScenario Email (with start point validation)
GetPriceDropProductsProducts that got cheaper since the customer’s last visit.Products + CurrencyScenario Email (with start point validation)
GetOrdersProducts and details from a specific customer order.Products + order details + currencyEmail Newsletter, Scenario Email, Pop-up, Banner

Get recommendations

Returns a list of recommended products for the current customer, along with the store currency.

Method signature

var recommendations = Model.GetRecommendations(int count = 4);

Parameters

ParameterTypeDefaultDescription
countint4Number of products to retrieve.

Return value

{
  "Products": [
    {
      "Id": "SKU-123",
      "Name": "Nike Air Zoom",
      "Url": "https://shop.example.com/p/nike-air-zoom",
      "ImageUrl": "https://shop.example.com/media/nike-air-zoom.jpg",
      "Category": "Shoes",
      "PriceString": "349.99",
      "CurrentPriceString": "299.99",
      "OmnibusPriceString": "329.99",
      "AdditionalInfo": "",
      "CustomProductAttributes": [
        {
          "Id": 101,
          "Name": "Brand",
          "Value": "Nike",
          "ValueString": "Nike"
        }
      ]
    }
  ],
  "Currency": {
    "ISO": "PLN",
    "Sign": ""
  }
}
FieldTypeDescription
IdstringUnique product identifier.
NamestringProduct name.
UrlstringURL of the product page.
ImageUrlstringURL of the product image.
CategorystringProduct category.
PriceStringstringRegular price, formatted as string.
CurrentPriceStringstringSale price, formatted as string. Empty if no sale is active.
OmnibusPriceStringstringLowest price in the last 30 days (EU Omnibus Directive).
AdditionalInfostringOptional additional information.
CustomProductAttributeslistCustom attributes defined for the product (e.g. Brand, Color).

Usage examples

Displaying the first recommended product

@{
    var recommendations = Model.GetRecommendations(4);
    var product = recommendations.Products?.FirstOrDefault();
}
@if (product != null)
{
    <a href="@product.Url">
        <img src="@product.ImageUrl" alt="@product.Name" />
    </a>
    <div>@product.Name</div>
    <div>
        @(string.IsNullOrWhiteSpace(product.CurrentPriceString)
            ? product.PriceString
            : product.CurrentPriceString)
        @recommendations.Currency.Sign
    </div>
}

Looping through all recommended products

@{
    var recommendations = Model.GetRecommendations(4);
}
@foreach (var product in recommendations.Products)
{
    if (product != null)
    {
        <a href="@product.Url">
            <img src="@product.ImageUrl" alt="@product.Name" />
        </a>
        <div>@product.Name</div>
        <div>
            @(string.IsNullOrWhiteSpace(product.CurrentPriceString)
                ? product.PriceString
                : product.CurrentPriceString)
            @recommendations.Currency.Sign
        </div>
    }
}

Reading a custom product attribute

@{
    var brand = product?.CustomProductAttributes
        ?.FirstOrDefault(x => x.Name == "Brand")?.ValueString;
}

Notes

  • Always use null-conditional operators (?.) when accessing product properties.
  • GetRecommendations retrieves 4 products by default. Adjust the count parameter to match your banner layout.
  • Use CurrentPriceString to display the sale price, and fall back to PriceString if it is empty.
  • OmnibusPriceString contains the lowest price from the last 30 days and should be displayed alongside a discounted price to comply with EU Omnibus Directive requirements.

Get cart

Returns products currently in the current customer’s cart, along with the store currency.

Method signature

var cart = Model.GetCart(int count = 100);

Parameters

ParameterTypeDefaultDescription
countint100Maximum number of cart products to retrieve.

Return value

{
  "Products": [
    {
      "Id": "SKU-123",
      "Name": "Nike Air Zoom",
      "Url": "https://shop.example.com/p/nike-air-zoom",
      "ImageUrl": "https://shop.example.com/media/nike-air-zoom.jpg",
      "Category": "Shoes",
      "PriceString": "349.99",
      "CurrentPriceString": "299.99",
      "OmnibusPriceString": "329.99",
      "AdditionalInfo": "",
      "Quantity": 2,
      "CustomProductAttributes": [
        {
          "Id": 101,
          "Name": "Brand",
          "Value": "Nike",
          "ValueString": "Nike"
        }
      ]
    }
  ],
  "Currency": {
    "ISO": "PLN",
    "Sign": ""
  }
}
FieldTypeDescription
IdstringUnique product identifier.
NamestringProduct name.
UrlstringURL of the product page.
ImageUrlstringURL of the product image.
CategorystringProduct category.
PriceStringstringRegular price, formatted as string.
CurrentPriceStringstringSale price, formatted as string. Empty if no sale is active.
OmnibusPriceStringstringLowest price in the last 30 days (EU Omnibus Directive).
QuantityintNumber of units of this product in the cart.
AdditionalInfostringOptional additional information.
CustomProductAttributeslistCustom attributes defined for the product (e.g. Brand, Color).

Usage examples

Displaying the first cart product

@{
    var cart = Model.GetCart(4);
    var product = cart.Products?.FirstOrDefault();
}
@if (product != null)
{
    <a href="@product.Url">
        <img src="@product.ImageUrl" alt="@product.Name" />
    </a>
    <div>@product.Name</div>
    <div>Quantity: @product.Quantity</div>
    <div>
        @(string.IsNullOrWhiteSpace(product.CurrentPriceString)
            ? product.PriceString
            : product.CurrentPriceString)
        @cart.Currency.Sign
    </div>
}

Looping through all cart products

@{
    var cart = Model.GetCart(4);
}
@foreach (var product in cart.Products)
{
    if (product != null)
    {
        <a href="@product.Url">
            <img src="@product.ImageUrl" alt="@product.Name" />
        </a>
        <div>@product.Name</div>
        <div>Quantity: @product.Quantity</div>
        <div>
            @(string.IsNullOrWhiteSpace(product.CurrentPriceString)
                ? product.PriceString
                : product.CurrentPriceString)
            @cart.Currency.Sign
        </div>
    }
}

Notes

  • If no cart is found for the customer, the method may return a cart-not-found error instead of an empty list. Make sure to handle this case in your template.
  • The Quantity field is unique to this method and is not available in other product methods.

Get abandoned browse products

Returns products that the customer viewed but did not purchase.

Method signature

var abandonedBrowse = Model.GetAbandonedBrowseProducts(int count = 100);

Parameters

ParameterTypeDefaultDescription
countint100Maximum number of products to retrieve.

Return value

{
  "Products": [
    {
      "Id": "SKU-123",
      "Name": "Nike Air Zoom",
      "Url": "https://shop.example.com/p/nike-air-zoom",
      "ImageUrl": "https://shop.example.com/media/nike-air-zoom.jpg",
      "Category": "Shoes",
      "PriceString": "349.99",
      "CurrentPriceString": "299.99",
      "OmnibusPriceString": "329.99",
      "AdditionalInfo": "",
      "CustomProductAttributes": [
        {
          "Id": 101,
          "Name": "Brand",
          "Value": "Nike",
          "ValueString": "Nike"
        }
      ]
    }
  ],
  "Currency": {
    "ISO": "PLN",
    "Sign": ""
  }
}
FieldTypeDescription
IdstringUnique product identifier.
NamestringProduct name.
UrlstringURL of the product page.
ImageUrlstringURL of the product image.
CategorystringProduct category.
PriceStringstringRegular price, formatted as string.
CurrentPriceStringstringSale price, formatted as string. Empty if no sale is active.
OmnibusPriceStringstringLowest price in the last 30 days (EU Omnibus Directive).
AdditionalInfostringOptional additional information.
CustomProductAttributeslistCustom attributes defined for the product (e.g. Brand, Color).

Usage examples

Displaying the first abandoned browse product

@{
    var abandonedBrowse = Model.GetAbandonedBrowseProducts(4);
    var product = abandonedBrowse.Products?.FirstOrDefault();
}
@if (product != null)
{
    <a href="@product.Url">
        <img src="@product.ImageUrl" alt="@product.Name" />
    </a>
    <div>@product.Name</div>
    <div>
        @(string.IsNullOrWhiteSpace(product.CurrentPriceString)
            ? product.PriceString
            : product.CurrentPriceString)
        @abandonedBrowse.Currency.Sign
    </div>
}

Looping through all abandoned browse products

@{
    var abandonedBrowse = Model.GetAbandonedBrowseProducts(4);
}
@foreach (var product in abandonedBrowse.Products)
{
    if (product != null)
    {
        <a href="@product.Url">
            <img src="@product.ImageUrl" alt="@product.Name" />
        </a>
        <div>@product.Name</div>
        <div>
            @(string.IsNullOrWhiteSpace(product.CurrentPriceString)
                ? product.PriceString
                : product.CurrentPriceString)
            @abandonedBrowse.Currency.Sign
        </div>
    }
}

Reading a custom product attribute

@{
    var color = product?.CustomProductAttributes
        ?.FirstOrDefault(x => x.Name == "Color")?.ValueString;
}

Notes

  • If the number of products found is lower than count, the Products list may contain null entries. Always check for null before accessing product properties.

Get price drop products

Returns products whose price has dropped since the customer’s last visit.

Method signature

var priceDropProducts = Model.GetPriceDropProducts(int count = 100);

Parameters

ParameterTypeDefaultDescription
countint100Maximum number of products to retrieve.

Return value

{
  "Products": [
    {
      "Id": "SKU-123",
      "Name": "Nike Air Zoom",
      "Url": "https://shop.example.com/p/nike-air-zoom",
      "ImageUrl": "https://shop.example.com/media/nike-air-zoom.jpg",
      "Category": "Shoes",
      "PriceString": "299.99",
      "CurrentPriceString": "",
      "OmnibusPriceString": "",
      "PriceLastSeenByCustomer": 349.99,
      "PriceLastSeenByCustomerString": "349.99",
      "AdditionalInfo": "",
      "CustomProductAttributes": [
        {
          "Id": 101,
          "Name": "Brand",
          "Value": "Nike",
          "ValueString": "Nike"
        }
      ]
    }
  ],
  "Currency": {
    "ISO": "PLN",
    "Sign": ""
  }
}
FieldTypeDescription
IdstringUnique product identifier.
NamestringProduct name.
UrlstringURL of the product page.
ImageUrlstringURL of the product image.
CategorystringProduct category.
PriceStringstringCurrent product price, formatted as string.
CurrentPriceStringstringSale price, formatted as string. Empty if no sale is active.
OmnibusPriceStringstringLowest price in the last 30 days (EU Omnibus Directive).
PriceLastSeenByCustomerdecimalThe price the customer saw on their last visit.
PriceLastSeenByCustomerStringstringPriceLastSeenByCustomer formatted as string.
AdditionalInfostringOptional additional information.
CustomProductAttributeslistCustom attributes defined for the product (e.g. Brand, Color).

Usage examples

Displaying the first price drop product

@{
    var priceDropProducts = Model.GetPriceDropProducts(4);
    var product = priceDropProducts.Products?.FirstOrDefault();
}
@if (product != null)
{
    <a href="@product.Url">
        <img src="@product.ImageUrl" alt="@product.Name" />
    </a>
    <div>@product.Name</div>
    <div>Now: @product.PriceString @priceDropProducts.Currency.Sign</div>
    <div>Was: @product.PriceLastSeenByCustomerString @priceDropProducts.Currency.Sign</div>
}

Looping through all price drop products

@{
    var priceDropProducts = Model.GetPriceDropProducts(4);
}
@foreach (var product in priceDropProducts.Products)
{
    if (product != null)
    {
        <a href="@product.Url">
            <img src="@product.ImageUrl" alt="@product.Name" />
        </a>
        <div>@product.Name</div>
        <div>Now: @product.PriceString @priceDropProducts.Currency.Sign</div>
        <div>Was: @product.PriceLastSeenByCustomerString @priceDropProducts.Currency.Sign</div>
    }
}

Notes

  • If the number of products found is lower than count, the Products list may contain null entries. Always check for null before accessing product properties.
  • PriceLastSeenByCustomerString holds the price the customer saw on their previous visit. Use it alongside PriceString to clearly communicate the price reduction.

Get orders

Returns products and details from a specific order placed by the customer, along with the original and converted currency. Returns products and details from a specific order placed by the customer, along with the original and converted currency. The method is available in Email Newsletters, Scenario Emails, Pop-ups, and Banners.

When usingit in a post-purchase scenario, the ‘Order’ start point passes the orderId as a data field. You can use it directly in the method to retrieve the correct order.

Method signature

var orders = Model.GetOrders(string orderID, int websiteId, string[] status);

Parameters

If no parameters are provided, the method returns all orders for the current customer.

ParameterTypeRequiredDescription
orderIdstringnoID of the order to retrieve. If omitted, all customer orders are returned.
websiteIdintnoID of the website the order is associated with. If omitted and multiple orders share the same ID, the most recent one is returned (based on order date).
statuslistnoA list of order statuses to filter by : paid, placed, completed, canceled
sortnoOrders can be sorted by following columns: OrderDate,
Value, ConvertedValue,OrderId, WebsiteId, and in the following order: ASC, DESC.
dateRangestring(date)noFormat: YYYY-MM-DD

Return value

[
  {
    "Products": [
      {
        "Id": "product123",
        "Name": "Product Name",
        "Url": "https://shop.com/product/product123",
        "ImageUrl": "https://shop.com/images/product123.jpg",
        "Category": "Electronics",
        "Price": 79.99,
        "PriceString": "79.99",
        "ConvertedPrice": 72.53,
        "Quantity": 2,
        "Returned": false,
        "OrderProductId": 123,
        "CustomProductAttributes": [
          { "Id": 1, "Name": "name1", "Value": "blue", "ValueString": "blue" },
          { "Id": 2, "Name": "name2", "Value": 15.99, "ValueString": "15.99" }
        ]
      }
    ],
    "OrderDate": "2025-04-14T23:06:00",
    "Status": "Paid",
    "TotalValue": 159.98,
    "ConvertedTotalValue": 134.67,
    "OriginalCurrency": { "ISO": "USD", "Sign": "$" },
    "ConvertedCurrency": { "ISO": "EUR", "Sign": "" },
    "CustomOrderAttributes": [
      { "Id": 1, "Name": "custom order attribute name", "Value": 123, "ValueString": "123" }
    ]
  }
]
FieldTypeDescription
IdstringUnique product identifier.
NamestringProduct name.
UrlstringURL of the product page.
ImageUrlstringURL of the product image.
CategorystringProduct category.
PricedecimalRegular price as a decimal value.
PriceStringstringRegular price, formatted as string.
ConvertedPricedecimalPrice converted to the store’s reporting currency.
QuantityintNumber of units of this product in the order.
ReturnedboolIndicates whether the product was returned.
OrderProductIdintUnique identifier of the product line within the order.
CustomProductAttributeslistCustom attributes defined for the product (e.g. Brand, Color).
OrderDatedatetimeDate and time the order was placed.
StatusstringCurrent order status (e.g. “Paid”, “Completed”).
TotalValuedecimalTotal order value in the original currency.
ConvertedTotalValuedecimalTotal order value converted to the reporting currency.
OriginalCurrencyobjectCurrency used when the order was placed (ISO and Sign).
ConvertedCurrencyobjectCurrency used for converted values (ISO and Sign).
CustomOrderAttributeslistCustom attributes defined for the order.

Usage examples

Displaying products from a specific order

@{
    var orders = Model.GetOrders("12343XYZ", websiteId: 2, status: new[] { "Paid", "Completed" });
    var firstOrder = orders?.FirstOrDefault();
    var product = firstOrder?.Products?.FirstOrDefault();
}
@if (product != null)
{
    <a href="@product.Url">
        <img src="@product.ImageUrl" alt="@product.Name" />
    </a>
    <div>@product.Name</div>
    <div>Quantity: @product.Quantity</div>
    <div>@product.PriceString @firstOrder.OriginalCurrency.Sign</div>
}

Looping through all products in an order

@{
    var orders = Model.GetOrders("12343XYZ", websiteId: 2, status: new[] { "Paid", "Completed" });
    var firstOrder = orders?.FirstOrDefault();
}
@if (firstOrder != null)
{
    foreach (var product in firstOrder.Products)
    {
        if (product != null)
        {
            <a href="@product.Url">
                <img src="@product.ImageUrl" alt="@product.Name" />
            </a>
            <div>@product.Name</div>
            <div>Quantity: @product.Quantity</div>
            <div>@product.PriceString @firstOrder.OriginalCurrency.Sign</div>
        }
    }
}

Reading a custom order attribute

@{
    var customAttr = firstOrder?.CustomOrderAttributes
        ?.FirstOrDefault(x => x.Name == "custom order attribute name")?.ValueString;
}

Reading a custom product attribute

@{
    var brand = product?.CustomProductAttributes
        ?.FirstOrDefault(x => x.Name == "Brand")?.ValueString;
}

Notes

  • Always use null-conditional operators (?.) when accessing order and product properties to prevent errors.
  • GetOrders can return multiple orders. Use FirstOrDefault() to work with a single order, or loop through the full list.
  • Use PriceString with OriginalCurrency.Sign to display prices in the order’s original currency. Use ConvertedPrice with ConvertedCurrency.Sign if you need to display prices in a converted currency.
  • If no orders match the given parameters, the method may return an empty list. Make sure to handle this case in your template.