Loading...
Area: Optimizely Commerce
Applies to versions: 14 and higher
Other versions:

Serializable carts

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

This topic describes the SerializedCarts model in Optimizely Commerce. With this model, all cart data is stored in a single table, providing a fast and efficient way to load, update, and save cart information.

How it works

In the SerializedCarts data model, all cart data is stored in one table, SerializableCart. This table contains these defined and searchable columns:

  • CartId
  • Created
  • Modified
  • Name
  • CustomerId
  • MarketId (Commerce 11.0 and higher)
  • Data

The Data column is where all the cart data is serialized to JSON format and then stored as a string.

Serializable components

All cart data is serialized to a JSON formatted string before persisting it to the database. To achieve this, several cart components participate in the serialization/deserialization which takes IMarket as a parameter.

Adding custom data

Serializable components implement the IExtendedProperties interface, and custom values can be added to the Properties collection on the Serializable components as long as the value can be JSON serialized. 

Converting a serialized cart with custom properties to a purchase order requires the Meta Fields corresponding to the custom properties to be present on the purchase order type. See Extending order classes.

The mapping between the serialized cart's custom properties and the purchase order's corresponding meta fields is strictly based on property name. The serialized cart is created with an emptyPropertiesemptyProperties collection, meaning that it is not prepopulated with the keys or default values of the meta fields added to the purchase order, or the legacy cart meta class.

Enabling SerializedCarts

By default, the SerializedCarts mode is enabled for a new installation site.

You can use ApplicationOptions to enable/disable SerializedCarts feature:

{
   "ApplicationOptions":{
      "Features":{
         "SerializedCarts":{
            "Feature":"SerializedCarts",
            "State":1, // 0 is enabled, 1 for disabled
            "Type":"Mediachase.Commerce.Core.Features.SerializedCarts, Mediachase.Commerce"
         }
      }
   }
}

Alternatively, enable the SerializedCarts mode programmatically by adding the following to your InitializeModule class:

ServiceLocator.Current.GetInstance<IFeatureSwitch>().EnableFeature(SerializedCarts.FeatureSerializedCarts);
Do you find this information helpful? Please log in to provide feedback.

Last updated: Jul 02, 2021

Recommended reading