private void CreateShippingMethod(string name, decimal shippingFee, Currency currency, PriceGroup priceGroup) { var shippingMethod = ShippingMethod.SingleOrDefault(x => x.Name == name) ?? new ShippingMethodFactory().NewWithDefaults(name); var shippingMethodPrice = shippingMethod.ShippingMethodPrices.FirstOrDefault(p => p.PriceGroup.Currency.ISOCode == currency.ISOCode); if (shippingMethodPrice == null) { shippingMethodPrice = new ShippingMethodPrice() { PriceGroup = priceGroup }; shippingMethod.AddShippingMethodPrice(shippingMethodPrice); } shippingMethodPrice.Price = shippingFee; shippingMethodPrice.PriceGroup = priceGroup; shippingMethodPrice.Save(); shippingMethod.ClearEligibleCountries(); foreach (var country in _countries) { shippingMethod.AddEligibleCountry(country); } shippingMethod.ClearEligibilePaymentMethods(); foreach (var method in _paymentMethods) { shippingMethod.AddEligiblePaymentMethod(method); } shippingMethod.Save(); }
public ShippingMethodPrice ShippingMethodPrice(PriceGroup priceGroup, decimal price) { var shippingMethodPrice = _shippingMethodPrices.Value .SingleOrDefault(x => x.Currency == priceGroup.Currency && x.PriceGroup == priceGroup); if (shippingMethodPrice == null) { shippingMethodPrice = new ShippingMethodPrice(); } shippingMethodPrice.Currency = priceGroup.Currency; shippingMethodPrice.PriceGroup = priceGroup; shippingMethodPrice.Price = price; return(shippingMethodPrice); }
public ShippingMethodPrice ShippingMethodPrice(PriceGroup priceGroup, decimal price) { var shippingMethodPrice = _shippingMethodPrices.Value .SingleOrDefault(x => x.Currency == priceGroup.Currency && x.PriceGroup == priceGroup); if (shippingMethodPrice == null) shippingMethodPrice = new ShippingMethodPrice(); shippingMethodPrice.Currency = priceGroup.Currency; shippingMethodPrice.PriceGroup = priceGroup; shippingMethodPrice.Price = price; return shippingMethodPrice; }