public IViewComponentResult Invoke(bool?prepareAndDisplayOrderReviewData) { var cart = _shoppingCartService.GetShoppingCart(_workContext.CurrentCustomer, ShoppingCartType.ShoppingCart, _storeContext.CurrentStore.Id); var model = _shoppingCartModelFactory.PrepareEstimateShippingModel(cart); if (!model.Enabled) { return(Content("")); } return(View(model)); }
public IViewComponentResult Invoke(bool?prepareAndDisplayOrderReviewData) { var cart = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList(); var model = _shoppingCartModelFactory.PrepareEstimateShippingModel(cart); if (!model.Enabled) { return(Content("")); } return(View(model)); }
public IViewComponentResult Invoke(int productId) { var product = _productService.GetProductById(productId); if (product == null) { return(Content("")); } var wrappedProduct = new ShoppingCartItem() { StoreId = _storeContext.CurrentStore.Id, ShoppingCartTypeId = (int)ShoppingCartType.ShoppingCart, CustomerId = _workContext.CurrentCustomer.Id, ProductId = product.Id, CreatedOnUtc = DateTime.UtcNow }; var model = _shoppingCartModelFactory.PrepareEstimateShippingModel(new[] { wrappedProduct }); if (!model.Enabled) { return(Content("")); } var wrappedModel = new ProductEstimateShippingModel() { ProductId = product.Id, Enabled = model.Enabled, CountryId = model.CountryId, StateProvinceId = model.StateProvinceId, ZipPostalCode = model.ZipPostalCode, AvailableCountries = model.AvailableCountries, AvailableStates = model.AvailableStates }; return(View(wrappedModel)); }