/// <summary>
        /// Translates the addresses.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="cart">The cart.</param>
        protected override void TranslateAddresses(CommerceServer.Core.Runtime.Orders.OrderAddressCollection collection, Commerce.Entities.Carts.Cart cart)
        {
            List<Party> partyList = new List<Party>();

            foreach (OrderAddress commerceAddress in collection)
            {
                int partyType = (commerceAddress[CommerceServerStorefrontConstants.KnowWeaklyTypesProperties.PartyType] == null) ? 1 : Convert.ToInt32(commerceAddress[CommerceServerStorefrontConstants.KnowWeaklyTypesProperties.PartyType], CultureInfo.InvariantCulture);

                Party party = null;

                switch (partyType)
                {
                    default:
                    case 1:
                        party = this.EntityFactory.Create<Commerce.Connect.CommerceServer.Orders.Models.CommerceParty>("Party");
                        this.TranslateAddress(commerceAddress, party as Sitecore.Commerce.Connect.CommerceServer.Orders.Models.CommerceParty);
                        break;

                    case 2:
                        party = this.EntityFactory.Create<RefSFModels.EmailParty>("EmailParty");
                        this.TranslateAddress(commerceAddress, party as RefSFModels.EmailParty);
                        break;
                }

                partyList.Add(party);
            }

            cart.Parties = partyList.AsReadOnly();
        }
예제 #2
0
        /// <summary>
        /// Determines whether this instance [can run pipeline] the specified basket.
        /// </summary>
        /// <param name="basket">The basket.</param>
        /// <returns>True if the piepline can be executed.  Otherwise false.</returns>
        protected override bool CanRunPipeline(CommerceServer.Core.Runtime.Orders.Basket basket)
        {
            bool canRunPipeline = true;

            foreach (OrderForm orderForm in basket.OrderForms)
            {
                foreach (LineItem lineItem in orderForm.LineItems)
                {
                    if (!this.IsValidShippingMethod(lineItem.ShippingMethodId))
                    {
                        return false;
                    }
                }
            }

            return canRunPipeline;
        }
        /// <summary>
        /// Translates the commerce customer party.
        /// </summary>
        /// <param name="party">The party.</param>
        /// <param name="profile">The profile.</param>
        protected virtual void TranslateCommerceCustomerParty(RefSFModels.CommerceParty party, CommerceServer.Core.Runtime.Profiles.Profile profile)
        {
            profile["GeneralInfo.first_name"].Value = party.FirstName;
            profile["GeneralInfo.last_name"].Value = party.LastName;
            profile["GeneralInfo.address_name"].Value = party.Name;
            profile["GeneralInfo.address_line1"].Value = party.Address1;
            profile["GeneralInfo.address_line2"].Value = party.Address2;
            profile["GeneralInfo.city"].Value = party.City;
            profile["GeneralInfo.region_code"].Value = party.RegionCode;
            profile["GeneralInfo.region_name"].Value = party.RegionName;
            profile["GeneralInfo.postal_code"].Value = party.ZipPostalCode;
            profile["GeneralInfo.country_code"].Value = party.CountryCode;
            profile["GeneralInfo.country_name"].Value = party.Country;
            profile["GeneralInfo.tel_number"].Value = party.PhoneNumber;
            profile["GeneralInfo.region_code"].Value = party.State;

            this.TranslateCommerceCustomerPartyCustomProperties(party, profile);
        }
 /// <summary>
 /// Translates the custom party.
 /// </summary>
 /// <param name="party">The party.</param>
 /// <param name="profile">The profile.</param>
 private void TranslateCustomParty(RefSFModels.CommerceParty party, CommerceServer.Core.Runtime.Profiles.Profile profile)
 {
 }
 /// <summary>
 /// Translates the commerce customer party custom properties.
 /// </summary>
 /// <param name="party">The party.</param>
 /// <param name="profile">The profile.</param>
 protected virtual void TranslateCommerceCustomerPartyCustomProperties(RefSFModels.CommerceParty party, CommerceServer.Core.Runtime.Profiles.Profile profile)
 {
 }
 /// <summary>
 /// Translates the address.
 /// </summary>
 /// <param name="sourceAddress">The source address.</param>
 /// <param name="destinationParty">The destination party.</param>
 protected virtual void TranslateAddress(CommerceServer.Core.Runtime.Orders.OrderAddress sourceAddress, RefSFModels.EmailParty destinationParty)
 {
     RefSFArguments.TranslateOrderAddressToEntityRequest request = new RefSFArguments.TranslateOrderAddressToEntityRequest(sourceAddress, destinationParty);
     PipelineUtility.RunCommerceConnectPipeline<RefSFArguments.TranslateOrderAddressToEntityRequest, CommerceResult>(PipelineNames.TranslateOrderAddressToEntity, request);
 }