Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }