Beispiel #1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            int storeId = StoreContext.CurrentStore.Id.Value;

            ShipmentPackagingStrategy shipmentPackagingStrategy = WA.Enum <ShipmentPackagingStrategy> .TryParseOrDefault(StoreContext.CurrentStore.GetSetting(StoreSettingNames.ShipmentPackagingStrategy), ShipmentPackagingStrategy.SingleBox);

            ddlShipmentPackaging.SelectedValue = shipmentPackagingStrategy.ToString();

            //---- Custom Shipping
            shippingTablesService = DataModel.ShippingService.FindOrCreateNew(storeId, ShippingProviderType.CustomShipping);
            if (shippingTablesService.ShippingServiceRateTypeCollectionByShippingServiceId.Count == 0)
            {
                var defaultRateType = shippingTablesService.ShippingServiceRateTypeCollectionByShippingServiceId.AddNew();
                defaultRateType.Name        = "FREE Shipping";
                defaultRateType.DisplayName = "FREE Shipping";
                defaultRateType.IsEnabled   = true;
                defaultRateType.SortOrder   = 1;

                var defaultRate = defaultRateType.ShippingServiceRateCollectionByRateTypeId.AddNew();
                defaultRate.WeightMin = 0;
                defaultRate.WeightMax = 999999;
                defaultRate.Cost      = 0;

                shippingTablesService.Save();
            }
            //shippingTablesProvider = ShippingProviderFactory.Get(storeId, ShippingProviderType.CustomShipping);

            //--- FedEx
            fedExService = DataModel.ShippingService.FindOrCreateNew(storeId, ShippingProviderType.FedEx);
            //fedExProvider = ShippingProviderFactory.Get(storeId, ShippingProviderType.FedEx);
            // FedEx - Add RateTypes for this service if they don't exist
            List <ShippingServiceRateType> rateTypes = fedExService.GetAllRateTypes();

            string[] allRateTypes = WA.Enum <WA.Shipping.FedExServiceType> .GetNames();

            foreach (string rateType in allRateTypes)
            {
                if (!rateTypes.Exists(x => x.Name == rateType))
                {
                    var newRateType = fedExService.ShippingServiceRateTypeCollectionByShippingServiceId.AddNew();
                    newRateType.Name        = rateType;
                    newRateType.DisplayName = rateType;
                    newRateType.IsEnabled   = true;
                    newRateType.SortOrder   = 99;
                }
            }
            fedExService.Save();

            //--- UPS
            upsService = DataModel.ShippingService.FindOrCreateNew(storeId, ShippingProviderType.UPS);
            upsService.Save();
        }
Beispiel #2
0
 private void LoadShippingRates()
 {
     //rptShippingRateTypes.DataSource = StoreContext.CurrentStore.GetAllShippingRateTypes();
     rptShippingRateTypes.DataSource = shippingTablesService.GetAllRateTypes();
     rptShippingRateTypes.DataBind();
 }