Пример #1
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="localizationService">Localization service</param>
 /// <param name="logger">Logger</param>
 /// <param name="priceCalculationService">PriceCalculation service</param>
 /// <param name="productAttributeParser">Product Attribute Parser</param>
 /// <param name="productService">Product Service</param>
 /// <param name="settingService">Settings service</param>
 /// <param name="shippingByTotalService">ShippingByTotal service</param>
 /// <param name="shippingService">Shipping service</param>
 /// <param name="storeContext">Store Context</param>
 /// <param name="shippingByTotalSettings">ShippingByTotal settings</param>
 /// <param name="webHelper">Web Helper</param>
 /// <param name="shoppingCartService">Shopping Cart service</param>
 public ByTotalShippingComputationMethod(
     ILocalizationService localizationService,
     ILogger logger,
     IPriceCalculationService priceCalculationService,
     IProductAttributeParser productAttributeParser,
     IProductService productService,
     ISettingService settingService,
     IShippingByTotalService shippingByTotalService,
     IShippingService shippingService,
     IStoreContext storeContext,
     ShippingByTotalSettings shippingByTotalSettings,
     IWebHelper webHelper,
     IShoppingCartService shoppingCartService)
 {
     _localizationService = localizationService;
     _logger = logger;
     _priceCalculationService = priceCalculationService;
     _productAttributeParser  = productAttributeParser;
     _productService          = productService;
     _priceCalculationService = priceCalculationService;
     _settingService          = settingService;
     _shippingByTotalService  = shippingByTotalService;
     _shippingByTotalSettings = shippingByTotalSettings;
     _shippingService         = shippingService;
     _storeContext            = storeContext;
     _webHelper           = webHelper;
     _shoppingCartService = shoppingCartService;
 }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="shippingService">Shipping service</param>
 /// <param name="shippingByTotalService">ShippingByTotal service</param>
 /// <param name="shippingByTotalSettings">ShippingByTotal settings</param>
 /// <param name="objectContext">ShippingByTotal object context</param>
 /// <param name="priceCalculationService">PriceCalculation service</param>
 /// <param name="settingService">Settings service</param>
 /// <param name="logger">Logger</param>
 public ByTotalShippingComputationMethod(IShippingService shippingService,
     IStoreContext storeContext,
     IShippingByTotalService shippingByTotalService,
     ShippingByTotalSettings shippingByTotalSettings,
     ShippingByTotalObjectContext objectContext,
     IPriceCalculationService priceCalculationService,
     ILogger logger,
     ISettingService settingService)
 {
     this._shippingService = shippingService;
     this._storeContext = storeContext;
     this._shippingByTotalService = shippingByTotalService;
     this._shippingByTotalSettings = shippingByTotalSettings;
     this._objectContext = objectContext;
     this._priceCalculationService = priceCalculationService;
     this._logger = logger;
     this._settingService = settingService;
 }
        /// <summary>
        /// Install the plugin
        /// </summary>
        public override void Install()
        {
            var settings = new ShippingByTotalSettings
            {
                LimitMethodsToCreated = false
            };
            _settingService.SaveSetting(settings);

            _objectContext.Install();

            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.AddNewRecordTitle", "Add new 'Shipping By Total' record");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.Country", "Country");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.Country.Hint", "If an asterisk is selected, then this shipping rate will apply to all customers, regardless of the country.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.DisplayOrder", "Display Order");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.DisplayOrder.Hint", "The display order for the shipping rate. Rates with lower display order values will be used if multiple rates match. If display orders match, the older rate is used.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.From", "Order total From");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.From.Hint", "Order total from.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.LimitMethodsToCreated", "Limit shipping methods to configured ones");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.LimitMethodsToCreated.Hint", "If you check this option, your customers will be limited to the shipping options configured here. Unchecked and they'll be able to choose any existing shipping options even if it's not configured here (shipping methods not configured here will have shipping fees of zero).");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ShippingChargeAmount", "Charge amount");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ShippingChargeAmount.Hint", "Charge amount.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ShippingChargePercentage", "Charge percentage (of subtotal)");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ShippingChargePercentage.Hint", "Charge percentage (of subtotal).");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ShippingMethod", "Shipping method");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ShippingMethod.Hint", "The shipping method.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.StateProvince", "State / province");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.StateProvince.Hint", "If an asterisk is selected, then this shipping rate will apply to all customers from the given country, regardless of the state / province.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.Store", "Store");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.Store.Hint", "This shipping rate will apply to all stores if an asterisk is selected.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.To", "Order total To");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.To.Hint", "Order total to.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.UsePercentage", "Use percentage");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.UsePercentage.Hint", "Check to use 'charge percentage' value.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.Warehouse", "Warehouse");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.Warehouse.Hint", "This shipping rate will apply to all warehouses if an asterisk is selected.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ZipPostalCode", "ZIP / postal code");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Fields.ZipPostalCode.Hint", "If ZIP / postal code is empty, this shipping rate will apply to all customers from the given country or state / province, regardless of the ZIP / postal code. The ZIP / postal codes can be entered in multiple formats: single (11111), multiple comma separated (11111, 22222), wildcard characters (S4? ???), starts with wildcard (S4*), numeric ranges (10000:30000), or combinations of the preceding formats (11111, 100??, 11111:22222, 33333).");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.ManageShippingSettings.AccessDenied", "Access denied");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.ManageShippingSettings.AddFailed", "Failed to add record.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.ManageShippingSettings.Saved", "Saved");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.ManageShippingSettings.StatesFailed", "Failed to retrieve states.");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.Reset", "Reset");
            this.AddOrUpdatePluginLocaleResource("Plugins.Shipping.ByTotal.SettingsTitle", "Shipping By Total Settings");

            base.Install();

            _logger.Information(string.Format("Plugin installed: SystemName: {0}, Version: {1}, Description: '{2}'", PluginDescriptor.SystemName, PluginDescriptor.Version, PluginDescriptor.FriendlyName));
        }