Пример #1
0
 public ShippingInfo(DeliveryOptionType option, DeliveryOption deliveryOption)
 {
     if (deliveryOption != null)
     {
         Id                    = deliveryOption.Id;
         Option                = option;
         FreightCode           = deliveryOption.FreightCode;
         WarehouseCode         = deliveryOption.WarehouseCode;
         Description           = deliveryOption.Description;
         Name                  = deliveryOption.Name;
         AdditionalInformation = deliveryOption.Information;
         if (deliveryOption.Address != null)
         {
             Address = CopyAddress(deliveryOption);
         }
         ShippingIntervalDays = deliveryOption.ShippingIntervalDays;
     }
     else
     {
         Id            = 0;
         Option        = option;
         FreightCode   = string.Empty;
         WarehouseCode = string.Empty;
         Description   = string.Empty;
         Name          = string.Empty;
     }
 }
Пример #2
0
        public override string GetShippingInstructionsForDS(MyHLShoppingCart shoppingCart, string distributorID, string locale)
        {
            ShippingInfo currentShippingInfo = shoppingCart.DeliveryInfo;

            if (currentShippingInfo != null && currentShippingInfo.Option == DeliveryOptionType.Shipping)
            {
                int postCode = 0;
                if (currentShippingInfo.Address != null)
                {
                    bool success = int.TryParse(currentShippingInfo.Address.Address.PostalCode, out postCode);
                    if (success)
                    {
                        /// “Åland”
                        if (postCode >= 22000 && postCode <= 22999)
                        {
                            DeliveryOption option = base.GetDeliveryOptions(locale).Find(o => o.FreightCode == "FIA");
                            if (null != option)
                            {
                                if (!string.IsNullOrEmpty(option.Description))
                                {
                                    return(option.Description);
                                }
                            }
                        }
                    }
                }
            }
            return(string.Empty);
        }
Пример #3
0
 public ShippingAddress_V01 CopyAddress(DeliveryOption srcAddress)
 {
     return(new ShippingAddress_V01()
     {
         Address = new Address_V01()
         {
             Line1 = srcAddress.Address.Line1,
             Line2 = srcAddress.Address.Line2,
             Line3 = srcAddress.Address.Line3,
             Line4 = srcAddress.Address.Line4,
             City = srcAddress.Address.City,
             CountyDistrict = srcAddress.Address.CountyDistrict,
             StateProvinceTerritory = srcAddress.Address.StateProvinceTerritory,
             Country = srcAddress.Address.Country,
             PostalCode = srcAddress.Address.PostalCode
         },
         Alias = srcAddress.Alias,
         AltAreaCode = srcAddress.AltAreaCode,
         AltPhone = srcAddress.AltPhone,
         AreaCode = srcAddress.AreaCode,
         Phone = srcAddress.Phone,
         Attention = srcAddress.Attention,
         Created = srcAddress.Created,
         DisplayName = srcAddress.DisplayName,
         IsPrimary = srcAddress.IsPrimary,
         Recipient = srcAddress.Recipient,
         ID = srcAddress.ID,
     });
 }
Пример #4
0
        public override string GetShippingInstructionsForShippingInfo(MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.ShoppingCart_V02 cart, MyHLShoppingCart shoppingCart, string distributorID, string locale)
        {
            if (shoppingCart != null && shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping && shoppingCart.DeliveryInfo.Address != null)
            {
                List <DeliveryOption> deliveryOptions = GetDeliveryOptions(DeliveryOptionType.Shipping, shoppingCart.DeliveryInfo.Address);
                if (deliveryOptions != null)
                {
                    string warehouseCode = string.IsNullOrEmpty(cart.OrderSubType) ? shoppingCart.DeliveryInfo.WarehouseCode : cart.OrderSubType;

                    DeliveryOption deliveryOption = deliveryOptions.Find(d => d.FreightCode == shoppingCart.DeliveryInfo.FreightCode && d.WarehouseCode == warehouseCode);
                    if (deliveryOption != null)
                    {
                        shoppingCart.DeliveryInfo.WarehouseCode = warehouseCode;
                        shoppingCart.DeliveryInfo.Name          = deliveryOption.Name;
                        return(shoppingCart.DeliveryInfo.Instruction = GetShippingInstructionsForDS(shoppingCart, distributorID, locale));
                    }
                    else
                    {
                        deliveryOption = deliveryOptions.FirstOrDefault();
                        if (deliveryOption != null)
                        {
                            shoppingCart.DeliveryInfo.WarehouseCode = deliveryOption.WarehouseCode;
                            shoppingCart.DeliveryInfo.Name          = deliveryOption.Name;
                            shoppingCart.DeliveryInfo.FreightCode   = deliveryOption.FreightCode;
                            return(shoppingCart.DeliveryInfo.Instruction = GetShippingInstructionsForDS(shoppingCart, distributorID, locale));
                        }
                    }
                }
            }
            return(String.Empty);
        }
Пример #5
0
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country,
                                                                           string locale,
                                                                           ShippingAddress_V01 address)
        {
            List <DeliveryOption> result = new List <DeliveryOption>();
            var proxy = ServiceClientProvider.GetShippingServiceProxy();
            DeliveryOptionForCountryRequest_V01 request = new DeliveryOptionForCountryRequest_V01();

            request.Country = Country;

            //request.State = request.State = (address != null && address.Address != null && !string.IsNullOrEmpty(address.Address.StateProvinceTerritory)) ? address.Address.StateProvinceTerritory : "HK";
            request.Locale = locale;
            ShippingAlternativesResponse_V01 response =
                proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01;

            foreach (ShippingOption_V01 option in response.DeliveryAlternatives)
            {
                DeliveryOption currentOption = new DeliveryOption(option);
                currentOption.Name          = option.Description;
                currentOption.WarehouseCode = option.WarehouseCode;
                currentOption.State         = request.State;
                result.Add(currentOption);
            }
            return(result.OrderBy(d => d.displayIndex.ToString() + "_" + d.DisplayName).ToList());
        }
        public override List <DeliveryOption> GetDeliveryOptionsListForMobileShipping(string Country,
                                                                                      string locale,
                                                                                      ShippingAddress_V01 address, string memberId)
        {
            var proxy = ServiceClientProvider.GetChinaShippingServiceProxy();

            var deliveryOptions = new List <DeliveryOption>();

            var AddressID = 0;

            if (EnableCnsmsAndInternetCommerce)
            {
                // Line3 stores CNSMS addressID
                if (address == null || address.Address == null || string.IsNullOrEmpty(address.Address.Line3))
                {
                    return(deliveryOptions);
                }
                int.TryParse(address.Address.Line3, out AddressID);
                if (AddressID == 0)
                {
                    return(deliveryOptions);
                }
            }
            else
            {
                AddressID = address.ID;
            }


            // bug: 131993 - to make the cache key factored by the address location (Cnty, Province, City, District), which should affect the express companies
            deliveryOptions = new List <DeliveryOption>();
            var result =
                proxy.GetGetExpressCompany(new GetGetExpressCompanyRequest(new GetExpressCompanyRequest_V01()
            {
                DistributorID    = memberId,
                AddressID        = AddressID,
                IncludeFeeDetail = true,
            })).GetGetExpressCompanyResult as GetExpressCompanyResponse_V01;

            if (result != null && result.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success)
            {
                foreach (var express in result.ExpressCompanies)
                {
                    var delivery = new DeliveryOption();
                    delivery.Name         = delivery.Description = express.ExpressCompanyName;
                    delivery.ID           = delivery.Id = express.ExpressCompanyID;
                    delivery.FreightCode  = express.ExpressCompanyID.ToString();
                    delivery.Information  = express.ExpressCompanyInfo;
                    delivery.BasePrice    = express.BasePrice;
                    delivery.FirstPrice   = express.FirstPrice;
                    delivery.FirstWeight  = express.FirstWeight;
                    delivery.RenewalPrice = express.RenewalPrice;
                    delivery.EstimatedFee = express.EstimatedFee;
                    deliveryOptions.Add(delivery);
                }
            }

            return(deliveryOptions);
        }
Пример #7
0
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address, DeliveryOptionType type)
        {
            DeliveryPickupAlternativesResponse_V03 pickupAlternativesResponse = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                List <DeliveryOption> result = new List <DeliveryOption>();
                var proxy = ServiceClientProvider.GetShippingServiceProxy();
                pickupAlternativesResponse =
                    proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V03
                {
                    CountryCode = Country,
                    State       = string.Empty
                })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V03;

                if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null)
                {
                    bool courier = false;
                    if (type == DeliveryOptionType.PickupFromCourier)
                    {
                        courier = true;
                    }
                    result.AddRange(
                        from po in pickupAlternativesResponse.DeliveryPickupAlternatives
                        select new DeliveryOption(po, courier));
                    Array.ForEach(result.ToArray(), a => a.Address = getAddress(pickupAlternativesResponse, a.Id));
                }

                return(result);
            }
            else
            {
                List <DeliveryOption> result = new List <DeliveryOption>();
                var proxy = ServiceClientProvider.GetShippingServiceProxy();
                DeliveryOptionForCountryRequest_V01 request = new DeliveryOptionForCountryRequest_V01();
                request.Country = Country;
                request.State   = (address != null && address.Address != null &&
                                   !string.IsNullOrEmpty(address.Address.StateProvinceTerritory))
                                    ? address.Address.StateProvinceTerritory
                                    : "Москва";
                request.Locale = locale;
                ShippingAlternativesResponse_V01 response =
                    proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01;
                foreach (ShippingOption_V01 option in response.DeliveryAlternatives)
                {
                    DeliveryOption currentOption = new DeliveryOption(option);
                    currentOption.Name          = option.Description;
                    currentOption.WarehouseCode = option.WarehouseCode;
                    currentOption.State         = request.State;
                    currentOption.displayIndex  = option.DisplayOrder;
                    currentOption.DisplayName   = option.Description;
                    result.Add(currentOption);
                }
                //result.Sort((x, y) => x.displayIndex.CompareTo(y.displayIndex));
                return(result.OrderBy(d => d.displayIndex.ToString() + "_" + d.DisplayName).ToList());
            }
        }
Пример #8
0
        private static List <DeliveryOption> getDeliveryOptionsFromService(string countryCode)
        {
            if (string.IsNullOrEmpty(countryCode))
            {
                return(null);
            }
            else
            {
                var proxy    = ServiceProvider.ServiceClientProvider.GetShippingServiceProxy();
                var response =
                    proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V02()
                {
                    CountryCode = countryCode
                })).GetDeliveryPickupAlternativesResult as
                    DeliveryPickupAlternativesResponse_V02;
                if (response != null && response.Status == ServiceResponseStatusType.Success &&
                    response.DeliveryPickupAlternatives != null)
                {
                    var deliveryOptions = new List <DeliveryOption>();
                    foreach (DeliveryPickupOption_V02 dpo in response.DeliveryPickupAlternatives)
                    {
                        var deliveryOption = new DeliveryOption(dpo);
                        if (!string.IsNullOrEmpty(dpo.State))
                        {
                            deliveryOption.State = dpo.State.Trim();
                        }
                        else
                        {
                            if (dpo.PickupAddress != null && dpo.PickupAddress.Address != null &&
                                dpo.PickupAddress.Address.StateProvinceTerritory != null)
                            {
                                deliveryOption.State = dpo.PickupAddress.Address.StateProvinceTerritory.Trim();
                            }
                        }

                        if (!string.IsNullOrEmpty(dpo.WarehouseCode))
                        {
                            deliveryOption.WarehouseCode = dpo.WarehouseCode;
                        }
                        else
                        {
                            if (dpo.ShippingSource != null)
                            {
                                deliveryOption.WarehouseCode = dpo.ShippingSource.Warehouse;
                            }
                        }
                        deliveryOptions.Add(deliveryOption);
                    }
                    return(deliveryOptions);
                }
            }
            return(null);
        }
Пример #9
0
 public ShippingInfo(PickupLocationPreference_V01 pickupPref, DeliveryOption deliveryOption)
 {
     this.Id     = pickupPref.ID;
     Option      = DeliveryOptionType.Pickup;
     Description = deliveryOption.Name;
     Name        = pickupPref.PickupLocationNickname;
     if (deliveryOption.Address != null)
     {
         Address = CopyAddress(deliveryOption);
     }
     FreightCode          = deliveryOption.FreightCode;
     WarehouseCode        = deliveryOption.WarehouseCode;
     ShippingIntervalDays = deliveryOption.ShippingIntervalDays;
 }
Пример #10
0
 public ShippingInfo(DeliveryOption deliveryOption)
 {
     Id                    = deliveryOption.Id;
     Option                = deliveryOption.Option;
     FreightCode           = deliveryOption.FreightCode;
     WarehouseCode         = deliveryOption.WarehouseCode;
     Description           = deliveryOption.Description;
     Name                  = deliveryOption.Name;
     AdditionalInformation = deliveryOption.Information;
     if (deliveryOption.Address != null)
     {
         Address = CopyAddress(deliveryOption);
     }
     ShippingIntervalDays = deliveryOption.ShippingIntervalDays;
 }
        public override ShippingInfo GetShippingInfoFromID(string distributorID,
                                                           string locale,
                                                           DeliveryOptionType type,
                                                           int deliveryOptionID,
                                                           int shippingAddressID)
        {
            DeliveryOption deliveryOption = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                string countryCode = locale.Substring(3, 2);
                var    pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode, null);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        int PickupLocationID = vPickupLocation.PickupLocationID;
                        var doList           = GetDeliveryOptions(type,
                                                                  new ShippingAddress_V01
                        {
                            Address = new Address_V01 {
                                Country = "CL"
                            },
                            Alias = vPickupLocation.PickupLocationType
                        });

                        if (doList != null)
                        {
                            deliveryOption = doList.Find(d => d.Id == PickupLocationID);
                            if (deliveryOption != null)
                            {
                                //deliveryOption.Id = deliveryOption.ID = deliveryOptionID;
                                var shippingInfo = new ShippingInfo(deliveryOption);
                                shippingInfo.Id = deliveryOptionID;
                                return(shippingInfo);
                            }
                        }
                    }
                }
            }
            else
            {
                return(base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID));
            }

            return(null);
        }
        public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID)
        {
            DeliveryOption deliveryOption = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                string countryCode = locale.Substring(3, 2);
                List <PickupLocationPreference_V01> pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        int PickupLocationID         = vPickupLocation.PickupLocationID;
                        List <DeliveryOption> doList = GetDeliveryOptions(type, new ShippingAddress_V01 {
                            Address = new Address_V01 {
                                Country = "UA"
                            }
                        });
                        if (doList != null)
                        {
                            deliveryOption = doList.Find(d => d.Id == PickupLocationID);
                            if (deliveryOption != null)
                            {
                                if (deliveryOption.Address != null && !string.IsNullOrEmpty(deliveryOption.Address.StateProvinceTerritory))
                                {
                                    List <DeliveryOption> doListDetails = GetDeliveryOptions(type, new ShippingAddress_V01 {
                                        Address = deliveryOption.Address
                                    });
                                    deliveryOption = doListDetails.Find(d => d.Id == PickupLocationID);
                                }
                                //deliveryOption.Id = deliveryOption.ID = deliveryOptionID;
                                ShippingInfo shippingInfo = new ShippingInfo(deliveryOption);
                                shippingInfo.Id = deliveryOptionID;
                                return(shippingInfo);
                            }
                        }
                    }
                }
            }
            else
            {
                return(base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID));
            }

            return(null);
        }
        public override ShippingInfo GetShippingInfoFromID(
            string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID)
        {
            DeliveryOption deliveryOptionForAddress = null;
            ShippingInfo   shippingInfo             = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                string countryCode = locale.Substring(3, 2);
                var    pickupLocationPreference =
                    this.GetPickupLocationsPreferences(distributorID, countryCode);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        var pickupLocationID = vPickupLocation.PickupLocationID;
                        var doList           = this.GetDeliveryOptions(type, null);
                        if (doList != null)
                        {
                            deliveryOptionForAddress = doList.Find(d => d.Id == pickupLocationID);
                            if (deliveryOptionForAddress != null)
                            {
                                deliveryOptionForAddress.Address.Line4 = deliveryOptionForAddress.Description;
                                //*******************TBD ************************************************************
                                //deliveryOptionForAddress.WarehouseCode = "";
                                //deliveryOptionForAddress.FreightCode = "";
                                //*******************TBD ************************************************************
                                shippingInfo = new ShippingInfo(deliveryOptionForAddress)
                                {
                                    Id = deliveryOptionID
                                };
                                return(shippingInfo);
                            }
                        }
                    }
                    return(shippingInfo);
                }
            }
            else
            {
                return(base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID));
            }

            return(null);
        }
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string country, string locale, ShippingAddress_V01 address)
        {
            List <DeliveryOption>           deliveryOptions = new List <DeliveryOption>();
            CityBoxAlternativesResponse_V01 response        = null;

            var proxy = ServiceClientProvider.GetShippingServiceProxy();

            response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(new GetCityBoxRequest_V01()
            {
                Country = "CL", FreightCode = FreightCode_CityBox, Warehouse = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse.ToString(), Locale = "es-CL"
            })).GetDeliveryOptionsResult as CityBoxAlternativesResponse_V01;
            DeliveryOption dlv;
            Address_V01    add;

            if (response != null && response.DeliveryAlternatives != null)
            {
                foreach (var location in response.DeliveryAlternatives)
                {
                    add = new Address_V01()
                    {
                        City                   = location.City,
                        Country                = location.Country,
                        CountyDistrict         = location.CountyDistrict,
                        Line1                  = location.LocationDescription,
                        Line2                  = "",
                        Line3                  = location.Line1,
                        Line4                  = location.Line2,
                        PostalCode             = location.PostalCode,
                        StateProvinceTerritory = location.StateProvinceTerritory
                    };
                    int id = location.ID;
                    dlv =
                        new DeliveryOption(new ShippingAddress_V02()
                    {
                        ID       = id, Recipient = location.LocationDescription, FirstName = string.Empty,
                        LastName = string.Empty, MiddleName = string.Empty, Address = add, Phone = "", AltPhone = "", IsPrimary = false,
                        Alias    = location.LocationDescription, Created = DateTime.Now
                    });
                    dlv.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse;
                    dlv.FreightCode   = FreightCode_CityBox;
                    deliveryOptions.Add(dlv);
                }
            }
            return(deliveryOptions);
        }
Пример #15
0
        private void retrieveFreightCode(MyHLShoppingCart shoppingCart, MyHerbalife3.Ordering.ServiceProvider.ShoppingCartSvc.ShippingInfo_V01 address)
        {
            // to correct prod issue where wrong freight code is set
            if (shoppingCart != null && shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Address != null &&
                shoppingCart.DeliveryInfo.Address.Address != null &&
                (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping || shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup) &&
                shoppingCart.OrderCategory == MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.OrderCategoryType.RSO && shoppingCart.DeliveryInfo.FreightCode == "NOF")
            {
                // Let the ETO and APF preserve the freight
                SessionInfo sessionInfo = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale);
                var         isAPF       = APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale);

                if (!sessionInfo.IsEventTicketMode && !isAPF)
                {
                    if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping)
                    {
                        List <DeliveryOption> deliveryOptions = GetDeliveryOptions(DeliveryOptionType.Shipping,
                                                                                   shoppingCart.DeliveryInfo.Address);
                        if (deliveryOptions != null)
                        {
                            DeliveryOption op =
                                deliveryOptions.Find(
                                    d =>
                                    d.WarehouseCode == shoppingCart.DeliveryInfo.WarehouseCode &&
                                    d.State.Equals(shoppingCart.DeliveryInfo.Address.Address.StateProvinceTerritory));
                            if (op != null)
                            {
                                shoppingCart.DeliveryInfo.FreightCode = op.FreightCode;
                            }
                        }
                    }
                    else if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup)
                    {
                        var pickupLocation = GetShippingInfoFromID(shoppingCart.DistributorID, shoppingCart.Locale,
                                                                   DeliveryOptionType.Pickup,
                                                                   shoppingCart.DeliveryInfo.Id, shoppingCart.DeliveryInfo.Address.ID);
                        if (pickupLocation != null)
                        {
                            shoppingCart.DeliveryInfo.FreightCode   = pickupLocation.FreightCode;
                            shoppingCart.DeliveryInfo.WarehouseCode = pickupLocation.WarehouseCode;
                        }
                    }
                }
            }
        }
        public override void GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ShippingInfo_V01 address)
        {
            DeliveryOption deliveryOptionForAddress = null;

            if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping)
            {
                var currentAddress = shoppingCart.DeliveryInfo.Address;
                var stateCode      = this.GetStateCodeGivenStateName(currentAddress.Address.StateProvinceTerritory.Trim());
                var srchCity       = currentAddress.Address.City.Trim().ToLower();
                if (currentAddress != null)
                {
                    //1)get cart total & compare with CAP
                    var listDeliveryOptions =
                        base.GetDeliveryOptions(
                            DeliveryOptionType.Shipping, currentAddress as ShippingAddress_V02);

                    var availableOptions =
                        listDeliveryOptions.FindAll(p => p.State.ToLower().Trim() == stateCode.ToLower().Trim());
                    if (availableOptions.Count > 0)
                    {
                        var optionForMajorCity =
                            availableOptions.FirstOrDefault(
                                i =>
                                !string.IsNullOrEmpty(i.Address.City) &&
                                i.Address.City.Trim().ToLower() == srchCity.Trim().ToLower());
                        deliveryOptionForAddress = optionForMajorCity
                                                   ?? availableOptions.FindAll(p => p.Address.City == null).FirstOrDefault();

                        if (deliveryOptionForAddress != null)
                        {
                            if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale))
                            {
                                address.WarehouseCode = HLConfigManager.Configurations.APFConfiguration.APFwarehouse;
                            }
                            else
                            {
                                shoppingCart.DeliveryInfo.WarehouseCode = deliveryOptionForAddress.WarehouseCode;
                            }
                        }
                    }
                }
            }
        }
        public MyHLShoppingCart StandAloneAddressForDonation(MyHLShoppingCart myShoppingCart)
        {
            ShippingAddress_V02 shippingAddress = new ShippingAddress_V02();

            shippingAddress.Address = CreateDefaultAddress();
            shippingAddress.ID      = -4;
            DeliveryOption deliveryOption = new DeliveryOption();

            shippingAddress.ID = -4;
            ShippingInfo shippingInfo = new ShippingInfo(deliveryOption, shippingAddress);

            shippingInfo.WarehouseCode                    = "888";
            shippingInfo.FreightCode                      = "3";
            shippingInfo.AddressType                      = "EXP";
            myShoppingCart.DeliveryInfo                   = shippingInfo;
            myShoppingCart.DeliveryInfo.Option            = DeliveryOptionType.Shipping;
            myShoppingCart.DeliveryInfo.Address.Phone     = "21-61033719";
            myShoppingCart.DeliveryInfo.Address.Recipient = "Test Recipient";
            return(myShoppingCart);
        }
Пример #18
0
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address)
        {
            List <DeliveryOption> result = new List <DeliveryOption>();
            var proxy = ServiceClientProvider.GetShippingServiceProxy();
            DeliveryOptionForCountryRequest_V01 request = new DeliveryOptionForCountryRequest_V01();

            request.Country = Country;
            request.State   = (address != null && address.Address != null && !string.IsNullOrEmpty(address.Address.City)) ? address.Address.City : string.Empty;
            request.Locale  = locale;
            ShippingAlternativesResponse_V01 response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01;

            foreach (ShippingOption_V01 option in response.DeliveryAlternatives)
            {
                DeliveryOption currentOption = new DeliveryOption(option);
                currentOption.State         = request.State;
                currentOption.WarehouseCode = option.WarehouseCode;
                currentOption.FreightCode   = option.FreightCode;
                result.Add(currentOption);
            }
            return(result.ToList());
        }
Пример #19
0
        public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string country, string locale, ShippingAddress_V01 address)
        {
            List <DeliveryOption> cachedOptions      = base.GetDeliveryOptions(locale);
            List <DeliveryOption> deliveryOptionList = new List <DeliveryOption>();

            if (address != null)
            {
                int  postCode = 0;
                bool success  = int.TryParse(address.Address.PostalCode, out postCode);
                if (success)
                {
                    /// not “Åland”
                    DeliveryOption option = null;
                    if (postCode < 22000 || postCode > 22999)
                    {
                        option = cachedOptions.Find(o => o.FreightCode == "FNF");
                        if (null != option)
                        {
                            deliveryOptionList.Add(option);
                        }

                        option = cachedOptions.Find(o => o.FreightCode == "FHD");
                        if (null != option)
                        {
                            deliveryOptionList.Add(option);
                        }
                    }
                    else
                    {
                        option = cachedOptions.Find(o => o.FreightCode == "FIA");
                        if (null != option)
                        {
                            deliveryOptionList.Add(option);
                        }
                    }
                }
            }

            return(deliveryOptionList);
        }
        public DeliveryOption GetDeliveryOptionFromId(int deliveryOptionId, DeliveryOptionType type)
        {
            DeliveryOption deliveryOption = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                var locations = HttpRuntime.Cache[FedexLocationCacheKey] as Dictionary <string, List <DeliveryOption> >;
                if (locations != null)
                {
                    foreach (var location in locations)
                    {
                        deliveryOption = location.Value.Find(o => o.Id == deliveryOptionId);
                        if (deliveryOption != null)
                        {
                            deliveryOption.Description = deliveryOption.Name;
                            break;
                        }
                    }
                }
            }
            return(deliveryOption);
        }
        public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string country,
                                                                                string locale,
                                                                                ShippingAddress_V01 address)
        {
            var proxy   = ServiceClientProvider.GetShippingServiceProxy();
            var request = new DeliveryOptionForCountryRequest_V01();

            request.Country = country;
            request.State   = string.Empty;
            request.Locale  = locale;
            var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01;
            var final    = new List <DeliveryOption>();

            foreach (ShippingOption_V01 option in response.DeliveryAlternatives)
            {
                var newOption = new DeliveryOption(option);
                newOption.Name = newOption.Description;
                final.Add(newOption);
            }

            return(final);
        }
        public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string Country,
                                                                                string locale,
                                                                                ShippingAddress_V01 address)
        {
            var final = new List <DeliveryOption>();

            //HOME DELIVERY
            var HomeDeliveryOption      = new DeliveryOption();
            var FreightCodeAndWarehouse = GetFreightCodeAndWarehouse(address);

            HomeDeliveryOption.FreightCode = FreightCodeAndWarehouse[0].ToString();
            HomeDeliveryOption.Description = (string)HttpContext.GetGlobalResourceObject(string.Format("{0}_GlobalResources", HLConfigManager.Platform), "HomeDeliveryOption") ?? "";
            final.Add(HomeDeliveryOption);

            //PUDO (PICKUP)
            var PudoDeliveryOptions = getDeliveryOptionsForShipping(Country, address, locale);

            if (PudoDeliveryOptions != null && PudoDeliveryOptions.Count > 0)
            {
                final.AddRange(PudoDeliveryOptions);
            }
            return(final);
        }
        public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string Country,
                                                                                string locale,
                                                                                ShippingAddress_V01 address)
        {
            var final         = new List <DeliveryOption>();
            var optionForCity = GetDeliveryOptionsListForShippingFromService(address);

            if (optionForCity == null)
            {
                var stdOption = new DeliveryOption
                {
                    FreightCode   = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode,
                    WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse,
                    Description   = "Su pedido será enviado con el Servicio de Entrega Regular"
                };
                final.Add(stdOption);
            }
            else
            {
                final.Add(optionForCity);
            }

            return(final);
        }
Пример #24
0
        public ShippingInfo(DeliveryOption deliveryOption, ShippingAddress_V01 shippingAddress)
        {
            if (deliveryOption != null)
            {
                Id = deliveryOption.Id;

                Option               = deliveryOption.Option;
                FreightCode          = deliveryOption.FreightCode;
                WarehouseCode        = deliveryOption.WarehouseCode;
                Description          = deliveryOption.Description;
                Name                 = deliveryOption.Name;
                ShippingIntervalDays = deliveryOption.ShippingIntervalDays;
            }

            if (shippingAddress != null)
            {
                Address = CopyAddress(shippingAddress);
            }

            if (deliveryOption != null)
            {
                this.AdditionalInformation = deliveryOption.Information;
            }
        }
        public override ShippingInfo GetShippingInfoFromID(string distributorID,
                                                           string locale,
                                                           DeliveryOptionType type,
                                                           int deliveryOptionID,
                                                           int shippingAddressID)
        {
            if (locale.Equals("en-MX"))
            {
                return(base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID));
            }

            var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy();
            DeliveryOptionForIDRequest_V01 request = new DeliveryOptionForIDRequest_V01();

            request.ID = deliveryOptionID;

            DeliveryOption deliveryOption = null;

            if (type == DeliveryOptionType.Pickup)
            {
                string countryCode = locale.Substring(3, 2);
                List <PickupLocationPreference_V01> pickupLocationPreference =
                    GetPickupLocationsPreferences(distributorID, countryCode);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.PickupLocationID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        int PickupLocationID = vPickupLocation.PickupLocationID;
                        request.ID = PickupLocationID;
                        PickupAlternativesResponse_V01 pickupAlternativesResponse =
                            proxy.GetPickupAlternativeForDeliveryOptionID(new GetPickupAlternativeForDeliveryOptionIDRequest(request)).GetPickupAlternativeForDeliveryOptionIDResult as PickupAlternativesResponse_V01;
                        if (pickupAlternativesResponse != null &&
                            pickupAlternativesResponse.PickupAlternatives != null &&
                            pickupAlternativesResponse.PickupAlternatives.Count > 0)
                        {
                            deliveryOption    = new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(pickupAlternativesResponse.PickupAlternatives[0]));
                            deliveryOption.Id = deliveryOption.ID = PickupLocationID;
                            return(new ShippingInfo(deliveryOption));
                        }
                    }
                }
            }
            else
            {
                ShippingAddress_V02 shippingAddress = null;
                if (shippingAddressID != 0)
                {
                    List <DeliveryOption> shippingAddresses = GetShippingAddresses(distributorID, locale);
                    if (shippingAddresses != null)
                    {
                        if ((shippingAddress = shippingAddresses.Find(s => s.ID == shippingAddressID)) == null)
                        {
                            shippingAddress = shippingAddresses.Find(s => s.IsPrimary == true);
                        }
                    }
                }
                else
                {
                    List <DeliveryOption> addresses = base.GetShippingAddresses(distributorID, locale);
                    if (addresses != null && addresses.Count > 0)
                    {
                        if ((shippingAddress = addresses.Find(s => s.IsPrimary == true)) == null)
                        {
                            shippingAddress = addresses.First();
                        }
                    }
                }

                if (shippingAddress != null)
                {
                    List <DeliveryOption> deliveryOptions = GetDeliveryOptions(type, shippingAddress);
                    if (deliveryOptions != null && deliveryOptions.Count > 0)
                    {
                        deliveryOption = deliveryOptions.First();
                        return(new ShippingInfo(deliveryOption, shippingAddress));
                    }
                }
            }

            return(null);
        }
Пример #26
0
        public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID)
        {
            if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.UseXHLTables)
            {
                var proxy   = ServiceClientProvider.GetMexicoShippingServiceProxy();
                var request = new ServiceProvider.ShippingMexicoSvc.DeliveryOptionForIDRequest_V01();
                request.ID      = deliveryOptionID;
                request.Country = "AR";

                DeliveryOption deliveryOption = null;
                if (type == DeliveryOptionType.Pickup)
                {
                    string countryCode = locale.Substring(3, 2);
                    List <PickupLocationPreference_V01> pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode);
                    if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                    {
                        var vPickupLocation = pickupLocationPreference.Find(p => p.PickupLocationID == deliveryOptionID);
                        if (vPickupLocation != null)
                        {
                            int PickupLocationID = vPickupLocation.PickupLocationID;
                            request.ID = PickupLocationID;
                            var pickupAlternativesResponse =
                                proxy.GetPickupAlternativeForDeliveryOptionID(new ServiceProvider.ShippingMexicoSvc.GetPickupAlternativeForDeliveryOptionIDRequest(request)).GetPickupAlternativeForDeliveryOptionIDResult as ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01;
                            if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null && pickupAlternativesResponse.PickupAlternatives.Count > 0)
                            {
                                deliveryOption             = new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(pickupAlternativesResponse.PickupAlternatives[0]));
                                deliveryOption.Id          = deliveryOption.ID = PickupLocationID;
                                deliveryOption.Description = deliveryOption.Description;
                                var shippingInfo = new ShippingInfo(deliveryOption);
                                shippingInfo.Address.Address.Line1 = shippingInfo.Address.Address.Line2;
                                shippingInfo.Address.Address.Line2 = string.Empty;
                                return(shippingInfo);
                            }
                        }
                    }
                }
                else
                {
                    ShippingAddress_V02 shippingAddress = null;
                    if (shippingAddressID != 0)
                    {
                        List <DeliveryOption> shippingAddresses = GetShippingAddresses(distributorID, locale);
                        if (shippingAddresses != null)
                        {
                            if ((shippingAddress = shippingAddresses.Find(s => s.ID == shippingAddressID)) == null)
                            {
                                shippingAddress = shippingAddresses.Find(s => s.IsPrimary == true);
                            }
                        }
                    }
                    else
                    {
                        List <DeliveryOption> addresses = base.GetShippingAddresses(distributorID, locale);
                        if (addresses != null && addresses.Count > 0)
                        {
                            if ((shippingAddress = addresses.Find(s => s.IsPrimary == true)) == null)
                            {
                                shippingAddress = addresses.First();
                            }
                        }
                    }

                    if (shippingAddress != null)
                    {
                        List <DeliveryOption> deliveryOptions = GetDeliveryOptions(type, shippingAddress);
                        if (deliveryOptions != null && deliveryOptions.Count > 0)
                        {
                            deliveryOption = deliveryOptions.First();
                            return(new ShippingInfo(deliveryOption, shippingAddress));
                        }
                    }
                }

                return(null);
            }
            else
            {
                return(GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID));
            }
        }
        public override ShippingInfo GetShippingInfoFromID(
            string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID)
        {
            DeliveryOption deliveryOptionForAddress = null;
            ShippingInfo   shippingInfo             = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                string countryCode = locale.Substring(3, 2);
                var    pickupLocationPreference =
                    this.GetPickupLocationsPreferences(distributorID, countryCode);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        var pickupLocationID = vPickupLocation.PickupLocationID;
                        var doList           = this.GetDeliveryOptions(type, null);
                        if (doList != null)
                        {
                            deliveryOptionForAddress = doList.Find(d => d.Id == pickupLocationID);
                            if (deliveryOptionForAddress != null)
                            {
                                shippingInfo = new ShippingInfo(deliveryOptionForAddress)
                                {
                                    Id = deliveryOptionID
                                };
                                return(shippingInfo);
                            }
                        }
                    }
                    return(shippingInfo);
                }
            }

            shippingInfo = base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID);
            if (shippingInfo != null && type == DeliveryOptionType.Shipping)
            {
                var currentAddress = shippingInfo.Address;
                var stateCode      = this.GetStateCodeGivenStateName(currentAddress.Address.StateProvinceTerritory.Trim());
                var srchCity       = currentAddress.Address.City.Trim().ToLower();
                if (currentAddress != null)
                {
                    //1)get cart total & compare with CAP
                    var listDeliveryOptions =
                        base.GetDeliveryOptions(
                            DeliveryOptionType.Shipping, currentAddress as ShippingAddress_V02);

                    var availableOptions =
                        listDeliveryOptions.FindAll(p => p.State.ToLower().Trim() == stateCode.ToLower().Trim());
                    if (availableOptions.Count > 0)
                    {
                        var optionForMajorCity =
                            availableOptions.FirstOrDefault(
                                i =>
                                !string.IsNullOrEmpty(i.Address.City) &&
                                i.Address.City.Trim().ToLower() == srchCity.Trim().ToLower());
                        deliveryOptionForAddress = optionForMajorCity
                                                   ?? availableOptions.FindAll(p => p.Address.City == null).FirstOrDefault();

                        if (deliveryOptionForAddress != null)
                        {
                            shippingInfo.FreightCode   = deliveryOptionForAddress.FreightCode;
                            shippingInfo.WarehouseCode = deliveryOptionForAddress.WarehouseCode;
                        }
                    }
                }
            }
            return(shippingInfo);
        }
        public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string country, string locale,
                                                                                ShippingAddress_V01 address)
        {
            StringBuilder perfMsg = new StringBuilder();

            DateTime perf01 = DateTime.Now;

            perfMsg.AppendLine(string.Format("GetDeliveryOptionsListForShipping - start : {0}", perf01));

            var proxy = ServiceClientProvider.GetChinaShippingServiceProxy();

            List <DeliveryOption> deliveryOptions = new List <DeliveryOption>();
            int AddressID = 0;

            if (EnableCnsmsAndInternetCommerce)
            {
                // Line3 stores CNSMS addressID
                if (address == null || address.Address == null || string.IsNullOrEmpty(address.Address.Line3))
                {
                    return(deliveryOptions);
                }
                int.TryParse(address.Address.Line3, out AddressID);
                if (AddressID == 0)
                {
                    return(deliveryOptions);
                }
            }
            else
            {
                AddressID = address.ID;
            }

            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (member == null || member.Value == null)
            {
                return(deliveryOptions);
            }

            // bug: 131993 - to make the cache key factored by the address location (Cnty, Province, City, District), which should affect the express companies
            var    addr     = address.Address;
            string CacheKey = string.Format("{0}{1}_{2}_{3}_{4}_{5}", "CN_EXPRESS_COMPANY_", member.Value.Id, addr.Country, addr.StateProvinceTerritory, addr.City, addr.CountyDistrict);

            if (EmployExpressDdlCache)
            {
                //deliveryOptions = HttpRuntime.Cache[CacheKey] as List<DeliveryOption>;
                //if (deliveryOptions != null)
                //{
                //    if (TraceExpressDdlPerformance)
                //    {
                //        perfMsg.AppendLine(string.Format("GetDeliveryOptionsListForShipping - return cache : {0}", DateTime.Now.Subtract(perf01).Milliseconds));
                //        System.Diagnostics.Debug.WriteLine(perfMsg.ToString());
                //    }
                //    return deliveryOptions;
                //}
            }

            deliveryOptions = new List <DeliveryOption>();
            GetExpressCompanyResponse_V01 result =
                proxy.GetGetExpressCompany(new GetGetExpressCompanyRequest(new GetExpressCompanyRequest_V01
            {
                DistributorID    = member.Value.Id,
                AddressID        = AddressID,
                IncludeFeeDetail = true,
            })).GetGetExpressCompanyResult as GetExpressCompanyResponse_V01;

            if (result != null && result.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success)
            {
                var selectText =
                    (string)HttpContext.GetLocalResourceObject(HLConfigManager.Configurations.CheckoutConfiguration
                                                               .CheckoutOptionsControl, "TextSelect", CultureInfo.CurrentCulture);
                deliveryOptions.Add(new DeliveryOption()
                {
                    Name        = selectText,
                    Id          = 0,
                    FreightCode = "0",
                    Information = selectText,
                    Description = selectText
                });
                foreach (var express in result.ExpressCompanies)
                {
                    DeliveryOption delivery = new DeliveryOption();
                    delivery.Name         = delivery.Description = express.ExpressCompanyName;
                    delivery.ID           = delivery.Id = express.ExpressCompanyID;
                    delivery.FreightCode  = express.ExpressCompanyID.ToString();
                    delivery.Information  = express.ExpressCompanyInfo;
                    delivery.BasePrice    = express.BasePrice;
                    delivery.FirstPrice   = express.FirstPrice;
                    delivery.FirstWeight  = express.FirstWeight;
                    delivery.RenewalPrice = express.RenewalPrice;
                    delivery.EstimatedFee = express.EstimatedFee;
                    deliveryOptions.Add(delivery);
                }

                if (EmployExpressDdlCache)
                {
                    //HttpRuntime.Cache.Insert(CacheKey,
                    //                                 deliveryOptions,
                    //                                 null,
                    //                                 DateTime.Now.AddMinutes(SHIPPINGINFO_CACHE_MINUTES),
                    //                                 Cache.NoSlidingExpiration,
                    //                                 CacheItemPriority.NotRemovable,
                    //                                 null);
                }
            }

            if (TraceExpressDdlPerformance)
            {
                //perfMsg.AppendLine(string.Format("GetDeliveryOptionsListForShipping - hit db : {0}", DateTime.Now.Subtract(perf01).Milliseconds));
                //System.Diagnostics.Debug.WriteLine(perfMsg.ToString());
            }
            return(deliveryOptions);
        }
        public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type,
                                                           int deliveryOptionID, int shippingAddressID)
        {
            if (type == DeliveryOptionType.Shipping)
            {
                var shippingAddresses = GetDSShippingAddresses(distributorID, locale);
                ShippingAddress_V02 shippingAddress = shippingAddresses.Find(s => s.ID == shippingAddressID);
                DeliveryOption      deliveryOption  = null;
                var freightCodeAndWarehouse         = GetFreightCodeAndWarehouseFromAddress(shippingAddress, null);
                if (freightCodeAndWarehouse != null)
                {
                    deliveryOption = new DeliveryOption(freightCodeAndWarehouse[1], freightCodeAndWarehouse[0],
                                                        DeliveryOptionType.Shipping,
                                                        string.Empty);
                }

                if (deliveryOption == null || shippingAddress == null)
                {
                    return(null);
                }
                ShippingInfo shippingInfo = new ShippingInfo(deliveryOption, shippingAddress);
                shippingInfo.AddressType = "EXP"; // this is address type for shipping

                if (Settings.GetRequiredAppSetting("LogShipping", "false").ToLower() == "true")
                {
                    LogRequest(string.Format("GetShippingInfoFromID for shipping option: {0}",
                                             OrderCreationHelper.Serialize(shippingInfo)));
                }
                return(shippingInfo);
            }
            else if (type == DeliveryOptionType.Pickup)
            {
                ShippingInfo shippingInfo = base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID);

                if (shippingInfo != null)
                {
                    shippingInfo.FreightCode = "0";
                    shippingInfo.AddressType = "SD"; // this is address type for pickup
                }

                //Stores Pickup Location phone in session and sets shippingInfo phone to DS phone
                //var sessionInfo = SessionInfo.GetSessionInfo(distributorID, locale);

                //sessionInfo.SelectedPickupLocationPhone = shippingInfo.Address.Phone;
                //shippingInfo.Address.Phone = String.Empty;

                return(shippingInfo);
            }
            if (type == DeliveryOptionType.PickupFromCourier)
            {
                string countryCode = locale.Substring(3, 2);
                var    pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        int pickupLocationID = vPickupLocation.PickupLocationID;
                        var doList           = GetDeliveryOptions(type,
                                                                  new ShippingAddress_V01
                        {
                            Address = new Address_V01 {
                                Country = "CN"
                            }
                        });
                        if (doList != null)
                        {
                            var deliveryOption = doList.Find(d => d.Id == pickupLocationID);
                            if (deliveryOption != null)
                            {
                                var shippingInfo = new ShippingInfo(deliveryOption);
                                shippingInfo.Id          = deliveryOptionID; // this is ID field from PickUpStore
                                shippingInfo.AddressType = "PUC" + deliveryOption.AddressType;
                                return(shippingInfo);
                            }
                        }
                    }
                }
            }
            return(null);
        }
Пример #30
0
        public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID)
        {
            var sessionInfo = SessionInfo.GetSessionInfo(distributorID, locale);

            if (type == DeliveryOptionType.ShipToCourier)
            {
                var shippingInfo    = base.GetShippingInfoFromID(distributorID, locale, DeliveryOptionType.Shipping, deliveryOptionID, shippingAddressID);
                var deliveryOptions = GetDeliveryOptions(type, shippingInfo.Address);
                if (deliveryOptions != null && deliveryOptions.Count > 0)
                {
                    var deliveryOption = deliveryOptions.FirstOrDefault();
                    if (deliveryOption != null)
                    {
                        shippingInfo.FreightCode   = deliveryOption.FreightCode;
                        shippingInfo.WarehouseCode = deliveryOption.WarehouseCode;
                    }
                }
                else
                {
                    shippingInfo.FreightCode = FREIGHTCODE_FOR_CUSTOMCOURIER;
                }
                shippingInfo.Option = DeliveryOptionType.ShipToCourier;
                return(shippingInfo);
            }
            else if (type == DeliveryOptionType.Pickup)
            {
                ShippingInfo shippingInfo = base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID);
                if (shippingInfo != null)
                {
                    List <DeliveryOption> shippingAddresses = GetShippingAddresses(distributorID, locale);
                    if (shippingAddresses != null)
                    {
                        DeliveryOption deliveryOption = null;
                        deliveryOption = shippingAddressID != 0 ? shippingAddresses.Find(s => s.ID == shippingAddressID) : shippingAddresses.Find(s => s.IsPrimary);
                        if (deliveryOption != null)
                        {
                            if (sessionInfo != null && sessionInfo.ShoppingCart != null)
                            {
                                MyHLShoppingCart myShoppingCart = sessionInfo.ShoppingCart;
                                if (myShoppingCart != null)
                                {
                                    if (myShoppingCart.ShippingAddressID != deliveryOption.ID)
                                    {
                                        ShoppingCartProvider.UpdateShoppingCart(myShoppingCart);
                                    }
                                    myShoppingCart.ShippingAddressID = deliveryOption.ID;
                                }
                            }
                        }
                    }
                }
                return(shippingInfo);
            }
            else if (type == DeliveryOptionType.PickupFromCourier)
            {
                var countryCode = locale.Substring(3, 2);
                var pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode);
                if (pickupLocationPreference != null && pickupLocationPreference.Count > 0)
                {
                    var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID);
                    if (vPickupLocation != null)
                    {
                        var addressV1 = new Address_V01 {
                            Country = countryCode
                        };
                        var address = new ShippingAddress_V01 {
                            Address = addressV1
                        };
                        var deliveryOptions = GetDeliveryOptionsFromCache(address);
                        if (deliveryOptions != null)
                        {
                            var deliveryOption = deliveryOptions.Find(d => d.Id == vPickupLocation.PickupLocationID);
                            if (deliveryOption != null)
                            {
                                var shippingInfo = new ShippingInfo(deliveryOption)
                                {
                                    Id            = deliveryOptionID,
                                    FreightCode   = deliveryOption.FreightCode,
                                    WarehouseCode = deliveryOption.WarehouseCode
                                };
                                return(shippingInfo);
                            }
                        }
                    }
                }
            }
            else
            {
                List <DeliveryOption> shippingAddresses = GetShippingAddresses(distributorID, locale);
                DeliveryOption        shippingAddress   = shippingAddresses.Find(s => s.Id == shippingAddressID);
                if (shippingAddress != null)
                {
                    List <DeliveryOption> deliveryOptions = GetDeliveryOptionsListForShipping("BR", "pt-BR", shippingAddress);
                    var varOptions = deliveryOptions.Where(s => s.State.Trim() == shippingAddress.Address.StateProvinceTerritory.Trim());
                    if (varOptions.Any())
                    {
                        var option       = varOptions.First();
                        var shippingInfo = new ShippingInfo(option, shippingAddress)
                        {
                            Option = DeliveryOptionType.Shipping
                        };
                        return(shippingInfo);
                    }
                }
            }
            if (sessionInfo != null && sessionInfo.ShoppingCart != null)
            {
                HLRulesManager.Manager.ProcessCart(sessionInfo.ShoppingCart, ShoppingCartRuleReason.CartRetrieved);
            }
            return(base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID));
        }