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; } }
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; }
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); }
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 }); }
private void ContentOnAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs documentCacheEventArgs) { //if (sender.ContentType.Alias.StartsWith("uwbs") && sender.ContentType.Alias != Order.NodeAlias) //todo: work with aliasses from config var alias = sender.ContentType.Alias; // todo: make a nice way for this block if (Product.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (ProductVariant.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (Category.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (PaymentProvider.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (PaymentProviderMethod.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (DiscountProduct.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (DiscountOrder.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (ShippingProvider.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (ShippingProviderMethod.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (Store.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (alias.StartsWith("uwbs") && alias != Order.NodeAlias) { ResetAll(sender.Id, alias); } var storePickerProperty = sender.getProperty(Constants.StorePickerAlias); if (storePickerProperty != null) { int storeId; if (storePickerProperty.Value != null && int.TryParse(storePickerProperty.Value.ToString(), out storeId)) { var storeService = StoreHelper.StoreService; var storeById = storeService.GetById(storeId, null); if (storeById != null) { storeService.TriggerStoreChangedEvent(storeById); } } } if (alias.StartsWith(Settings.NodeAlias)) { IO.Container.Resolve <ISettingsService>().TriggerSettingsChangedEvent(SettingsLoader.GetSettings()); } if (alias.StartsWith(Store.NodeAlias)) { //todo: naar nieuwe v6+ API omzetten var storeService = StoreHelper.StoreService; storeService.TriggerStoreChangedEvent(storeService.GetById(sender.Id, null)); var node = new Node(sender.Id); if (!sender.Text.Equals(node.Name)) { StoreHelper.RenameStore(node.Name, sender.Text); } } }
public void Update(ShippingProviderMethod shippingProviderMethod, OrderInfo order) { Implementation(shippingProviderMethod); }
public void Setup() { _shippingProviderMethod = new ShippingProviderMethod(); _mock = new Mock <IShippingProviderUpdateService>(); }