Umbraco Commerce
CMSCloudHeartcoreDXP
14.latest
14.latest
  • Umbraco Commerce Documentation
  • Release Notes
    • v14.0.0
    • v14.0.0-Alpha
  • Commerce Products
    • Commerce Packages
    • Commerce Payment Providers
    • Commerce Shipping Providers
  • Getting Started
    • Requirements
    • Installation
    • Licensing
    • Configuration
    • User Interface
  • Upgrading
    • Upgrading Umbraco Commerce
    • Version Specific Upgrade Notes
    • Migrate from Vendr to Umbraco Commerce
      • Migrate Umbraco Commerce Checkout
      • Migrate custom Payment Providers
  • How-To Guides
    • Overview
    • Configure SQLite support
    • Limit Order Line Quantity
    • Use an Alternative Database for Umbraco Commerce Tables
    • Add item to Cart
    • Update Cart
    • Delete item from Cart
  • Key Concepts
    • Get to know the main features
    • Base Currency
    • Calculators
    • Currency Exchange Rate Service Provider
    • Dependency Injection
    • Discount Rules / Rewards
    • Events
      • List of validation events
      • List of notification events
    • Fluent API
    • Order Calculation State
    • Payment Forms
    • Payment Providers
    • Pipelines
    • Price/Amount Adjustments
    • Price Freezing
    • Product Adapters
    • Product Bundles
    • Product Variants
      • Complex Variants
    • Properties
    • ReadOnly and Writable Entities
    • Sales Tax Providers
    • Search Specifications
    • Settings Objects
    • Shipping Package Factories
    • Shipping Providers
    • Shipping Range/Rate Providers
    • Tax Sources
    • UI Extensions
      • Analytics Widgets
      • Entity Quick Actions
      • Order Properties
      • Order Collection Properties
      • Order Line Properties
      • Store Menu Items
    • Umbraco Properties
    • Unit of Work
    • Umbraco Commerce Builder
    • Webhooks
  • Reference
    • Stores
    • Shipping
      • Fixed Rate Shipping
      • Dynamic Rate Shipping
      • Realtime Rate Shipping
    • Taxes
      • Fixed Tax Rates
      • Calculated Tax Rates
    • Storefront API
      • Endpoints
        • Order
        • Checkout
        • Product
        • Customer
        • Store
        • Currency
        • Country
        • Payment method
        • Shipping method
        • Content
    • Management API
    • Go behind the scenes
    • Telemetry
  • Tutorials
    • Overview
    • Getting started with Umbraco Commerce: The Backoffice
Powered by GitBook
On this page
  • Setting Properties
  • System Properties
  • Order System Properties
  • Order Line System Properties
  • Automatic Properties
  • Product Uniqueness Properties
  • Order Property Map

Was this helpful?

Edit on GitHub
Export as PDF
  1. Key Concepts

Properties

Order and Order Line metadata in Umbraco Commerce.

PreviousComplex VariantsNextReadOnly and Writable Entities

Last updated 9 months ago

Was this helpful?

There is little information that Umbraco Commerce needs to know about a product in order for it to do its job. There are, however, times when developers require the ability to store additional information against an Order or Order Line. This could be the billing/shipping address of an Order, or any specific configuration details of a given Product on an Order Line.

To help facilitate this Umbraco Commerce has the concept of a Properties collection on both the Order entity and the Order Line entity respectively. The Properties collection of these entities can be thought of as a general store for additional information required by an implementation, but not strictly required by Umbraco Commerce itself.

Anything you need to remember about an Order / Order Line can be stored in its Properties collection.

Setting Properties

To set a Property on an Order or Order Line, it needs to be . Then it's a case of calling one of the related property setting methods:

// Set a single property
order.SetProperty("propertyAlias", "Property Value");

// Set multiple properties at once
order.SetProperties(new Dictionary<string, string>{
    { "propertyAlias1", "Property Value 1" },
    { "propertyAlias2", "Property Value 2" },
    { "propertyAlias3", "Property Value 3" }
})

// Remove a property
order.RemoveProperty("propertyAlias");

Property values can either be a string, or a Umbraco Commerce PropertyValue which allows you to define a value as being Server Side Only. This means that it won't be returned via non-server APIs or Read Only meaning it can't be updated once set.

// Set a string property
order.SetProperty("propertyAlias", "Property Value");

// Set a PropertyValue property as Read Only
order.SetProperty("propertyAlias", new PropertyValue("Property Value", isReadOnly: true));

System Properties

On occasions where Umbraco Commerce needs to capture some information about an Order or Order Line, it uses the Properties collection to store this information. It's useful to know what these properties are as you should avoid using these system-related property keys.

Order System Properties

Alias
Description

email

The email address of the person placing the order. Is where order.CustomerInfo.Email reads it's value from.

firstName

The first name of the person placing the order. Is where order.CustomerInfo.FirstName reads it's value from.

lastName

The last name of the person placing the order. Is where order.CustomerInfo.LastName reads it's value from.

Order Line System Properties

Alias
Description

sku

Automatic Properties

Umbraco Commerce has a built-in mechanism that can be configured to automatically copy properties from a Product information source to the Order Line automatically. This is done by using the Product Property Aliases field on the Store settings screen.

When a Product is added to the Order containing a comma-separated list of property aliases, the property values are automatically copied to the Order Lines Properties collection.

This is useful for occasions such as rendering out the Order Lines on a Cart page and you have Product information you want to display. By copying it to the Order Lines Properties collection, you have instant access to those properties without the need to re-fetch the original Product entity.

Product Uniqueness Properties

Another use of the Properties collection for an Order Line is that of identifying product "Uniqueness".

Umbraco Commerce uses Product Uniqueness to identify either of the two:

  • Whether a Product is added to a Cart should be considered as a Quantity increase on an existing Order Line

  • Whether it should be considered as a unique product combination and so should be given an Order Line of its own.

A good example of this is when you have configurable products, such as customizable T-Shirt designs. In this case, each unique configuration should be considered as its own Order Line so that you can manage the specific configurations.

Product uniqueness is configured via the Product Uniqueness Property Aliases field on the Store setting screen.

When set to a comma-separated list of property aliases and a Product is added to an Order, the properties are compared against all pre-existing Order Lines for that Product. Should their values be different, then a unique Order Line will be created for that Product.

Order Property Map

In Umbraco Commerce, you may need to access order information in a structured way for shipping calculations and using the Storefront and Management API's. An order property map can be set up to specify how items in an order's properties collection correspond to properties of a structured model.

Order property maps can be defined per store, but there is also a default map that is pre-configured.

// Create a new mapping for the given store
builder.WithOrderPropertyConfigs()
    .Add("storeAlias", map => map
        // Define your property map here
    );

// Update the default mapping
builder.WithOrderPropertyConfigs()
    .UpdateDefault(map => map
        // Define your property map here
    );

The default property map is configured as follows:

builder.WithOrderPropertyConfigs()
    .AddDefault(map => map
        // Customer
        .For(x => x.Customer.FirstName).MapFrom(Core.Constants.Properties.Customer.FirstNamePropertyAlias)
        .For(x => x.Customer.LastName).MapFrom(Core.Constants.Properties.Customer.LastNamePropertyAlias)
        .For(x => x.Customer.Email).MapFrom(Core.Constants.Properties.Customer.EmailPropertyAlias)
        .For(x => x.Customer.Telephone).MapFrom("telephone")
        // Billing
        .For(x => x.Billing.Contact.FirstName).MapFrom("billingFirstName")
        .For(x => x.Billing.Contact.LastName).MapFrom("billingLastName")
        .For(x => x.Billing.Contact.Email).MapFrom("billingEmail")
        .For(x => x.Billing.Contact.Telephone).MapFrom("billingTelephone")
        .For(x => x.Billing.CompanyName).MapFrom("billingCompany")
        .For(x => x.Billing.CompanyTaxCode).MapFrom("billingCompanyTaxCode")
        .For(x => x.Billing.AddressLine1).MapFrom("billingAddressLine1")
        .For(x => x.Billing.AddressLine2).MapFrom("billingAddressLine2")
        .For(x => x.Billing.City).MapFrom("billingCity")
        .For(x => x.Billing.ZipCode).MapFrom("billingZipCode")
        // Shipping
        .For(x => x.Shipping.SameAsBilling).MapFrom("shippingSameAsBilling")
        .For(x => x.Shipping.Contact.FirstName).MapFrom("shippingFirstName")
        .For(x => x.Shipping.Contact.LastName).MapFrom("shippingLastName")
        .For(x => x.Shipping.Contact.Email).MapFrom("shippingEmail")
        .For(x => x.Shipping.Contact.Telephone).MapFrom("shippingTelephone")
        .For(x => x.Shipping.CompanyName).MapFrom("shippingCompany")
        .For(x => x.Shipping.CompanyTaxCode).MapFrom("shippingCompanyTaxCode")
        .For(x => x.Shipping.AddressLine1).MapFrom("shippingAddressLine1")
        .For(x => x.Shipping.AddressLine2).MapFrom("shippingAddressLine2")
        .For(x => x.Shipping.City).MapFrom("shippingCity")
        .For(x => x.Shipping.ZipCode).MapFrom("shippingZipCode")
        //Notes
        .For(x => x.Notes.CustomerNotes).MapFrom("customerNotes")
        .For(x => x.Notes.InternalNotes).MapFrom("internalNotes"));

The SKU of the product, extracted from the product node via the .

Order property maps are defined via the interface.

IUmbracoCommerceBuilder
Product Adapter
in its Writable state
Product Property Aliases Configuration
Product Uniqueness Property Aliases Configuration