Extend the order address
Extend the Commerce OrderAddress
Create a new class that derives from the
OrderAddressEx
class and extend the class.Example
namespace MyOrders { [Serializable] public class MyOrderAddress: OrderAddressEx { private string pobox; public MyOrderAddress() { } protected MyOrderAddress(SerializationInfo info, StreamingContext context) : base(info, context) { pobox = info.TryGetString(nameof(pobox)); } [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue(nameof(pobox), pobox); } public string POBox { get { return pobox; } set { SetDirty(value); pobox = value; } } } }
Modify the Class-To-Storage Mapping (
OrderObjectMappings.xml
). Follow the Commerce Server guidelines to modify mapping file and apply the instructions for the order address class.- Modify the Class-To-Pipeline Mapping (
OrderPipelineMappings.xml
). Follow the Commerce Server guidelines for line item to modify mapping file and apply the instructions for the order address class. Patch the
Mercury.Commerce.Orders.config
file. Provide the correct type for the class that is extended by modifying the Type element of theOrderAddressEx
class.Example
<type name="OrderAddress" type="MyOrders.MyOrderAddress, MyOrders" lifetime="PerCall"/>
Modify the
CommerceServer.Orders.config
file. Provide the correct type for the class that is extended by modifying the Type element of theOrderAddressEx
class.Example
<Type Key="OrderAddress" UserTypeName="MyOrderAddress" AssemblyType="Local" NameSpace="MyOrders" Assembly="MyOrders" />
Update the database.
Configure the Commerce Connect type
Patch the Mercury.Commerce.Customers.config
file. Provide the correct type for the class that is extended by patching the type attribute of the Party element in the commerce.Entities configuration section.
Example
<sitecore>
<commerce.Entities>
<Party>
<patch:attribute name="type">
MyOrders.MyCommerceParty, MyOrders</patch:attribute>
</Party>
...
</commerce.Entities>
...
</sitecore>
Extend the translation of Commerce to Commerce Connect
Create a new pipeline processor that derives from the
TranslateOrderAddressToEntity
pipeline processor.Example
namespace MyOrders.Pipelines { public class MyTranslateOrderAddressToEntity : TranslateOrderAddressToEntity { public MyTranslateOrderAddressToEntity() : base() { } ... }
Override the method
TranslateCustomAddressProperties
and call base method.Example
protected override void TranslateCustomAddressProperties(OrderAddress origin, CommerceParty destination) { base.TranslateCustomAddressProperties(origin, destination); }
Extend the translation of Commerce to Commerce Connect entity.
Example
protected override void TranslateCustomAddressProperties(OrderAddress origin, CommerceParty destination) { base.TranslateCustomAddressProperties(origin, destination); var myOrderAddress = origin as MyOrderAddress; var myCommerceParty = destination as MyCommerceParty; myCommerceParty.POBox = myOrderAddress.POBox; }
Patch the
Mercury.Commerce.Orders.config
file. Replace the Mercury pipeline processor with the extended pipeline processor in the pipeline translate.orderAddressToEntity configuration.Example
<sitecore> <pipelines> <translate.orderAddressToEntity> <processor type="Mercury.Checkout.Domain.Pipelines.TranslateOrderAddressToEntity, Mercury.Checkout"> <patch:delete/> </processor> <processor type="MyOrders.Pipelines.MyTranslateOrderAddressToEntity, MyOrders"> </processor> </translate.orderAddressToEntity> ... </sitecore>
Extend the translation of Commerce Connect to Commerce
Create a new pipeline processor that derives from the
TranslateEntityToOrderAddress
pipeline processor.Example
namespace MyOrders.Pipelines { public class MyTranslateEntityToOrderAddress : TranslateEntityToOrderAddress { public MyTranslateEntityToOrderAddress(IEntityFactory entityFactory) : base(entityFactory) { } ... }
Override the method
TranslateCustomProperties
and call base method.Example
protected override void TranslateCustomProperties(CommerceParty origin, OrderAddress destination) { base.TranslateCustomProperties(origin, destination); }
Extend the translation of Commerce Connect to Commerce entity.
Example
protected override void TranslateCustomProperties(CommerceParty origin, OrderAddress destination) { base.TranslateCustomProperties(origin, destination); var myCommerceParty = origin as MyCommerceParty; var myOrderAddress = destination as MyOrderAddress; myOrderAddress.POBox = myCommerceParty.POBox; }
Patch the
Mercury.Commerce.Orders.config
file. Replace the Mercury pipeline processor with the extended pipeline processor in the pipeline translate.entityToOrderAddress configuration.Example
<sitecore> <pipelines> <translate.entityToOrderAddress> <processor type="Mercury.Checkout.Domain.Pipelines.TranslateEntityToOrderAddress, Mercury.Checkout"> <patch:delete/> </processor> <processor type="MyOrders.Pipelines.MyTranslateEntityToOrderAddress, MyOrders"> <param ref="entityFactory"/> </processor> </translate.entityToOrderAddress> ... </sitecore>
Extend the translation of Connect to View model
More information will be added when translate pipeline is added to Mercury.
Extend the translation of View model to Connect
More information will be added when translate pipeline is added to Mercury.