コード例 #1
0
            public void Update(ShippingProviderMethod shippingProviderMethod, OrderInfo orderInfo)
            {
                if (orderInfo != null)
                {
                    // your logic here, and set the price at the end like this:

                    Log.Instance.LogDebug("Hoeveelheid artikelen totaal: " +
                                          orderInfo.OrderLines.Sum(x => x.ProductInfo.ItemCount));
                    Log.Instance.LogDebug("Hoeveel eerste artikel in mandje: " +
                                          orderInfo.OrderLines.First().ProductInfo.ItemCount);

                    // CALCULATE SHIPPING PRICE

                    int priceInCents;
                    var itemCount = orderInfo.OrderLines.Sum(line => line.ProductInfo.ItemCount.GetValueOrDefault(1));
                    if (itemCount == 1)
                        priceInCents = 500;
                    else if (itemCount == 2)
                        priceInCents = 400;
                    else
                        priceInCents = 0;
                    shippingProviderMethod.PriceInCents = priceInCents;

                    shippingProviderMethod.PriceInCents = 500;
                }
            }
コード例 #2
0
        public IEnumerable<ShippingProviderMethod> GetAllShippingMethods(int id)
        {
            //var provider = new ShippingProvider(id);
            //var helper = new ShippingConfigHelper(provider);
            //var request = new ShippingRequest();
            //var orderInfo = OrderHelper.GetOrderInfo();

            var vat = Store.GetStore().GlobalVat;

            var order = Basket.GetBasket();

            if (order != null)
            {
                vat = order.AverageOrderVatPercentage;
            }

            var issuerId = "0";
            var issuerName = "Example";

            var method = new ShippingProviderMethod
            {
                ShippingProviderUpdateService =
                    new ExampleShippingProviderShippingProviderUpdateService(),
                Id = issuerId,
                Description = issuerName,
                Title = issuerName,
                Name = issuerName,
                ProviderName = GetName(),
                Vat = vat,
                PriceInCents = 500
            };

            return new List<ShippingProviderMethod> { method };
        }
コード例 #3
0
		public ShippingMethodFulfillmentAdaptor(ShippingProviderMethod shippingProviderMethod, bool pricesIncludingVat, ILocalization localization, OrderInfo order)
		{
			_shippingProviderMethod = shippingProviderMethod;
			_pricesIncludingVat = pricesIncludingVat;
			_localization = localization;
			_order = order;
			Id = shippingProviderMethod.Id;
			Title = shippingProviderMethod.Title;
			Description = shippingProviderMethod.Description;
			Name = shippingProviderMethod.Name;
			Disabled = shippingProviderMethod.Disabled;
		}
コード例 #4
0
		public void HavingAnActiveFreeShippingDiscount_ShouldReflectThatOnOrderParts()
		{
			IOC.OrderDiscountRepository.SetupNewMock().Setup(m => m.GetAll(It.IsAny<ILocalization>())).Returns(new List<IOrderDiscount> { new OrderDiscount { DiscountType = DiscountType.FreeShipping, MinimalOrderAmount =10000, Localization = StoreHelper.CurrentLocalization, RequiredItemIds = new List<int>(), MemberGroups = new List<string>(), AffectedOrderlines  = new List<int>()} });
			var order = DefaultFactoriesAndSharedFunctionality.CreateIncompleteOrderInfo(
				DefaultFactoriesAndSharedFunctionality.CreateProductInfo(40000, 1, 10m));
			IOC.OrderService.Resolve().UseDatabaseDiscounts(order);

			//var orderDiscountService = IOC.OrderDiscountService.Resolve();
			//var orderDiscounts = orderDiscountService.GetAll(new StubLocalization());
			//var discount = orderDiscounts.Single();
			//Assert.AreEqual(DiscountType.FreeShipping, discount.Type);
			
			//var filteredOrderDiscounts = orderDiscounts.Where(orderDiscount => !orderDiscount.Disabled && 40000 >= orderDiscount.MinimumOrderAmount.ValueInCents() && (!orderDiscount.RequiredItemIds.Any() /*|| _orderService.OrderContainsItem(order, orderDiscount.RequiredItemIds)*/) && (!orderDiscount.CounterEnabled || orderDiscount.Counter > 0));
			//Assert.AreEqual(1, filteredOrderDiscounts.Count());

			//var applicableDiscounts = orderDiscountService.GetApplicableDiscountsForOrder(order, order.Localization);
			//Assert.True(applicableDiscounts.Any());
			//Assert.AreEqual(DiscountType.FreeShipping, applicableDiscounts.Single().Type);

			Assert.NotNull(order.OrderDiscountsFactory);
			Assert.True(order.OrderDiscounts.Any());
			//Assert.False(order.OrderDiscountsWithoutFreeShipping.Any());
			Assert.True(order.FreeShipping);

			var shippingProviderMethod = new ShippingProviderMethod {PriceInCents = 1000};
			var adaptor = new ShippingMethodFulfillmentAdaptor(shippingProviderMethod, true, StoreHelper.CurrentLocalization, order);

			// freeshipping so chardgedshippingcosts should be 0
			Assert.AreEqual(0, order.ChargedShippingCostsInCents);

			Assert.AreEqual(0, adaptor.Amount.WithVat.ValueInCents);
			Assert.AreEqual(1000, adaptor.Amount.BeforeDiscount.WithVat.ValueInCents);
			Assert.AreEqual(1000, adaptor.Amount.Discount.WithVat.ValueInCents);
			Assert.AreEqual(0, adaptor.Amount.WithVat.ValueInCents);
			//Assert.AreEqual(1000, adaptor.Amount.BeforeDiscount.WithVat.ValueInCents);// wtf

			var discountedRanged = Price.CreateDiscountedRanged(shippingProviderMethod.PriceInCents, null, true, order.AverageOrderVatPercentage, null, i => (order.FreeShipping) ? 0 : i, StoreHelper.CurrentLocalization);
			Assert.AreEqual(0, discountedRanged.WithVat.ValueInCents);
			Assert.AreEqual(1000, discountedRanged.BeforeDiscount.WithVat.ValueInCents);
		}