AdditionalInfo entity
This section describes how to work with AdditionalInfo entity.
AdditionalInfo entity is a dictionary with string key and object value, so the value can be a simple type or an object.
There are a few things to keep in mind regarding value data type:
- DateTimeOffset is recommended since it contains the time zone information. But if DateTime is used, make sure it is Coordinated Universal Time (UTC)
- Object: must implement
Litium.ComponentModel.IReadonly
- List: Because a list is not a simple type, it cannot be added directly.
There are 2 different ways to add additional information:
-
Using anonymous type or class
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = "Value"
});
-
Using Dictionary<string, object>
await cartContext.AddOrUpdateAdditionalInfoAsync(new Dictionary<string, object>
{
{ "Name", "Value" }
});
The key/property will be added if it does not already exist in AdditionalInfo; the other keys will be unaffected.
To update the existing key, we set the new value for the existing key.
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = "new value"
});
To delete additional information, we set null for the existing key.
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = (string)null
});
Order
The additional order information is added via the method AddOrUpdateAdditionalInfoAsync of Litium.Sales.CartContext
var cartContext = _cartContextFactory.CreateAsync(createCartContextArgs)
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = "Value"
});
Order row
The additional order row information is added via the method AddOrUpdateItemAsync of Litium.Sales.CartContext
var cartContext = _cartContextFactory.CreateAsync(createCartContextArgs)
await cartContext.AddOrUpdateItemAsync(new AddOrUpdateCartItemArgs
{
ArticleNumber = "Article1",
AdditionalInfo = new
{
Name = "Value"
}
});
Display Additional info in Litium backoffice
Information stored in the AdditionalInfo entity of orders, order rows and shipments kan be displayed when viewing an individual order in the Sales module of Litium backoffice. You can control which keys and their values that should be displayed by adding them in Settings:
- Go to Settings.
- Under Sales, open the Additional order information page.
- Click the New button to open the dialog to add a new key.
- Enter the key of the AdditionalInfo you would like to display. Keys are case insensitive.
The keys added to the list will be used to filter values to show for all available entitties, ie orders, order rows and shipments.