Show / Hide Table of Contents

    Extend the order address

    Extend the Commerce OrderAddress

    1. 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;
               }
           }
       }
      }
      
    2. 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.

    3. 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.
    4. Patch the Mercury.Commerce.Orders.config file. Provide the correct type for the class that is extended by modifying the Type element of the OrderAddressEx class.

      Example

      <type 
       name="OrderAddress" 
       type="MyOrders.MyOrderAddress, MyOrders" 
       lifetime="PerCall"/>
      
    5. Modify the CommerceServer.Orders.config file. Provide the correct type for the class that is extended by modifying the Type element of the OrderAddressEx class.

      Example

      <Type Key="OrderAddress" 
         UserTypeName="MyOrderAddress" 
         AssemblyType="Local" 
         NameSpace="MyOrders" 
         Assembly="MyOrders" />
      
    6. 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

    1. Create a new pipeline processor that derives from the TranslateOrderAddressToEntity pipeline processor.

      Example

      namespace MyOrders.Pipelines
      {
       public class MyTranslateOrderAddressToEntity : TranslateOrderAddressToEntity
       {
           public MyTranslateOrderAddressToEntity() : base()
           {
           }
           ...
       }
      
    2. Override the method TranslateCustomAddressProperties and call base method.

      Example

      protected override void TranslateCustomAddressProperties(OrderAddress origin, CommerceParty destination)
      {
       base.TranslateCustomAddressProperties(origin, destination);
      }
      
    3. 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;
      }
      
    4. 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

    1. 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)
           {
           }
           ...
       }
      
    2. Override the method TranslateCustomProperties and call base method.

      Example

      protected override void TranslateCustomProperties(CommerceParty origin, OrderAddress destination)
      {
       base.TranslateCustomProperties(origin, destination);
      }
      
    3. 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;
      }
      
    4. 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.

    See also

    • Extend the address entity
    • Extend the profile address
    Advanced
    • Improve this Doc
    Back to top Copyright © 2015-2018 Aviva Solutions
    Generated by DocFX