Can't comment about commerce but Content Delivery Api you can add additional fields to the response. There are core classes that can be extended to do a lot more. In CMS you will need to extend ContentApiModelFillter something like below and override filter method to add/remove additional properties
[ServiceConfiguration(typeof(IContentApiModelFilter), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomContentApiModelFilter : ContentApiModelFilter<ContentApiModel>
{
public override void Filter(ContentApiModel contentApiModel, ConverterContext converterContext)
{
// To remove a field
contentApiModel.Properties.Remove("Category");
#region Add Content Type GUID to output
contentApiModel.Properties[CONTENT_TYPE_GUID] = Guid.Empty.ToString("N");
if (contentApiModel.ContentLink?.Id != null && contentApiModel.ContentLink.Id.HasValue)
{
var content = contentLoader.Get<IContent>(new ContentReference(contentApiModel.ContentLink.Id.Value));
var contentType = content.ContentTypeID;
var type = contentTypeRepository.Load(contentType);
if (type != null && type.GUID != Guid.Empty)
{
contentApiModel.Properties[CONTENT_TYPE_GUID] = type.GUID.ToString("N");
}
}
#endregion
}
}
Hi, I am building a headless commerce solution using content delivery API.
Is it possible to extend the Content delivery API commerce classes adding my own attributes and fields to it, taking Cart object returned by
https://localhost:8080/api/episerver/v3.0/me/carts/3 for example
the attributes iam trying to add could be added to the cart , line items , shipments or basically any content type retuned by content delivery API
this is a Json Example which I am trying to extend :