Address is saved as a sitecore commerce party in the cart/order json. We need to extend a few cart models & party translations. These are the files that we need to extend.
- Models
- Sitecore.Commerce.XA.Feature.Cart.Models
- AddressJsonResult
- PartyInputModel
- Translations
- TranslateEntityToParty
- TranslatePartyToEntity
Models:
We need to extend Sitecore.Commerce.XA.Feature.Cart.Models.InputModels.PartyInputModel & Sitecore.Commerce.XA.Feature.Cart.Models.JsonResults.AddressJsonResult to hold the value of company from the checkout address form.
Translations:
We need to extend “TranslatePartyToEntity” & “TranslateEntityToParty” processors to create a mapping between Sitecore.Commerce.Engine.Connect.Entities.CommerceParty.Company and Sitecore.Commerce.Core.Organization.
public
class CustomTranslateEntityToParty
: TranslateEntityToParty
{
protected
override
void Translate
(
CommerceParty source,
Party destination,
TranslateEntityToPartyResult result
)
{
base
.
Translate
(source, destination, result
)
;
destination
.
Organization
= source
.
Company
;
}
}
public
class CustomTranslatePartyToEntity
: TranslatePartyToEntity
{
public CustomTranslatePartyToEntity
(IEntityFactory entityFactory
)
:
base
(entityFactory
)
{
}
protected
override
void Translate
(
TranslatePartyToEntityRequest request,
Sitecore
.
Commerce
.
Core
.
Party source,
CommerceParty destination
)
{
base
.
Translate
(request, source, destination
)
;
destination
.
Company
= source
.
Organization
;
}
}