Example #1
0
        protected override void LoadData()
        {
            _shippingAddresses = ShippingProvider.GetShippingAddresses(DistributorID, Locale);
            _pickupLocations   = ShippingProvider.GetDeliveryOptions(DeliveryOptionType.Pickup,
                                                                     ShippingProvider.GetDefaultAddress());

            if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.AllowPickUpFromCourier)
            {
                _pickupRrefList = ProductsBase.GetShippingProvider()
                                  .GetPickupLocationsPreferences(DistributorID, CountryCode);
            }
        }
        protected override void loadData()
        {
            _shippingAddresses = ShippingProvider.GetShippingAddresses(DistributorID, Locale);

            // Retrieve the pickupoption from the cache, not hardcoded to pickup, unless nothing is loaded, so use default
            _pickupLocations = ShippingProvider.GetDeliveryOptions(DeliveryOptionType.Pickup,
                                                                   ShippingProvider.GetDefaultAddress());
            _pickupRrefList = ProductsBase.GetShippingProvider()
                              .GetPickupLocationsPreferences(DistributorID, CountryCode);
            // Showing the right options according xml configurations.
            if (!HLConfigManager.Configurations.PickupOrDeliveryConfiguration.AllowPickUpFromCourier &&
                DeliveryType.Items.FindByValue("PickupFromCourier") != null)
            {
                DeliveryType.Items.Remove(DeliveryType.Items.FindByValue("PickupFromCourier"));
            }
        }
        protected override void loadAddressEditMode()
        {
            int id = 0;

            if (DropdownNickName.SelectedIndex >= 0)
            {
                if (int.TryParse(DropdownNickName.SelectedValue, out id))
                {
                    DeliveryOptionType option = getDeliveryOptionTypeFromDropdown(DeliveryType);
                    //DeliveryOption deliveryOption = getSelectedAddress(id, (DeliveryOptionType)Enum.Parse(typeof(DeliveryOptionType), DeliveryType.SelectedValue));
                    DeliveryOption deliveryOption = null;
                    if (option == DeliveryOptionType.Shipping || option == DeliveryOptionType.ShipToCourier)
                    {
                        var addresses = _shippingAddresses.Where(s => s.Id == id);
                        if (addresses.Count() == 0)
                        {
                            addresses = _shippingAddresses.Where(s => s.IsPrimary);
                        }
                        deliveryOption = addresses.Count() == 0 ? null : addresses.First();
                    }
                    else if (option == DeliveryOptionType.PickupFromCourier)
                    {
                        var varPref = _pickupRrefList.Where(f => f.ID == id);
                        if (varPref.Count() > 0)
                        {
                            int PickupLocationID = varPref.First().PickupLocationID;

                            List <DeliveryOption> doList = ShippingProvider.GetDeliveryOptions(option,
                                                                                               new ShippingAddress_V01
                            {
                                Address =
                                    new Address_V01
                                {
                                    Country = "PT"
                                }
                            });
                            if (doList != null)
                            {
                                deliveryOption = doList.Find(d => d.Id == PickupLocationID);
                            }
                        }
                    }
                    else
                    {
                        if (_pickupLocations != null && _pickupLocations.Count > 0)
                        {
                            var varPickupLocation = _pickupLocations.Where(p => p.Id == id);
                            if (varPickupLocation.Count() > 0)
                            {
                                deliveryOption = varPickupLocation.First();
                            }
                        }
                    }
                    if (deliveryOption != null)
                    {
                        if (option == DeliveryOptionType.Unknown && CheckNoDeliveryType(DeliveryType))
                        {
                            option = DeliveryOptionType.Shipping;
                        }
                        if (option == DeliveryOptionType.ShipToCourier)
                        {
                            option = DeliveryOptionType.Shipping;
                        }
                        pAddress.InnerHtml = ProductsBase.GetShippingProvider()
                                             .FormatShippingAddress(deliveryOption, option,
                                                                    ShoppingCart != null &&
                                                                    ShoppingCart.DeliveryInfo != null
                                                                                    ? ShoppingCart.DeliveryInfo
                                                                    .Description
                                                                                    : string.Empty, true);
                    }
                }
            }
        }