public ActionResult CheckoutReviewPage(ContentModel model) { var crm = new CheckoutReviewModel(model.Content); crm.CurrentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); crm.Order = crm.CurrentCart.GetOrder(); if (!crm.Order.PaymentMethodId.HasValue) { return(Redirect(string.Concat("/", CurrentUser.LanguageCode, "/cart/checkout-payment"))); } crm.CartItems = crm.CurrentCart.GetCartItemsByCookieId(); var productIds = crm.CartItems.Where(c => c.ProductId.HasValue).Select(c => c.ProductId); if (productIds.Any()) { crm.Products = UvendiaContext.Products.All(productIds.ToArray()); } var ticketSaleIds = crm.CartItems.Where(c => c.TicketSaleId.HasValue).Select(c => c.TicketSaleId); if (ticketSaleIds.Any()) { crm.TicketsSale = UvendiaContext.TicketSales.All(ticketSaleIds.ToArray()); } return(CurrentTemplate(crm)); }
/// <summary> /// Removes the product from the cart /// </summary> /// <param name="viewModel">The view model of the product row viewer to remove the product</param> public void RemoveFromCart(ProductRowViewerViewModel viewModel) { // Removing it from the (Items) list if there is no searching now if (!mIsSearching) { foreach (OrderRowViewerViewModel item in Items) { if (item.ProductViewModel.Equals(viewModel)) { Items.Remove(item); break; } } } // Removing it from the cart foreach (OrderRowViewerViewModel item in CurrentCart) { if (item.ProductViewModel.Equals(viewModel)) { CurrentCart.Remove(item); break; } } }
public ActionResult BuyTickets(EventDetailModel model, string imageId) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); var tickets = model.Event.TicketsSale.ToList(); model.Event.LazyLoadProperties(); for (int i = 0; i < tickets.Count; i++) { string dropdownName = string.Concat("TicketType", i); int ticketsQuantityToBuy = !Request.Form[dropdownName].IsNullOrEmpty() ? int.Parse(Request.Form[dropdownName]) : 0; ViewData[dropdownName] = ticketsQuantityToBuy; if (ticketsQuantityToBuy > 0) { currentCart.AddTicket( tickets[i].Id, model.Event.DisplayName(), ticketsQuantityToBuy, metaData: imageId); } } return(Redirect($"/{CurrentUser.LanguageCode}/cart/")); }
public HttpResponseMessage UpdateCart(ItemCmdDTO item) { try { int portalID = PortalController.Instance.GetCurrentPortalSettings().PortalId; StoreInfo storeSettings = StoreController.GetStoreInfo(portalID); if (storeSettings.InventoryManagement && storeSettings.AvoidNegativeStock) { ProductController controler = new ProductController(); ProductInfo currentProduct = controler.GetProduct(portalID, item.ID); if (currentProduct.StockQuantity < item.Quantity) { return(Request.CreateResponse(HttpStatusCode.Conflict, LocalizeString("NotEnoughProducts"))); } } CurrentCart.UpdateItem(portalID, storeSettings.SecureCookie, item.ID, item.Quantity); return(Request.CreateResponse(HttpStatusCode.OK)); } catch { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("Unexpected.Error"))); } }
/// <summary> /// Adds the specified product to cart /// </summary> /// <param name="productViewModel">The view model of the product row viewer to add product</param> public void AddToCart(ProductRowViewerViewModel productViewModel) { var viewModel = new OrderRowViewerViewModel ( CurrentCart.Count + 1, Order.CurrentOrder.ID, "1", "0", productViewModel ); viewModel.CanDelete = true; // Updates the list price viewModel.TotalPriceChanged += () => OnPropertyChanged(nameof(TotalPrice)); viewModel.Deleted += DeleteItem; if (!mIsSearching) { CurrentCart.Add(viewModel); Items.Add(viewModel); } else { CurrentCart.Add(viewModel); } // Make the product not available to be added to the cart again // Because the qunatity of the product can be specified in the (CartPage) productViewModel.IsOutFromCart = false; OnPropertyChanged(nameof(TotalPrice)); }
protected void Page_Load(object sender, EventArgs e) { if (StoreSettings != null) { string templatePath = CssTools.GetTemplatePath(this, StoreSettings.PortalTemplates); // Read module settings and define cart properties MainCartSettings cartSettings = new ModuleSettings(ModuleId, TabId).MainCart; cartControl.ShowThumbnail = cartSettings.ShowThumbnail; cartControl.ThumbnailWidth = cartSettings.ThumbnailWidth; cartControl.GIFBgColor = cartSettings.GIFBgColor; cartControl.EnableImageCaching = cartSettings.EnableImageCaching; cartControl.CacheImageDuration = cartSettings.CacheImageDuration; cartControl.ProductColumn = cartSettings.ProductColumn.ToLower(); cartControl.LinkToDetail = cartSettings.LinkToDetail; cartControl.IncludeVAT = cartSettings.IncludeVAT; cartControl.TemplatePath = templatePath; cartControl.ModuleConfiguration = ModuleConfiguration; cartControl.StoreSettings = StoreSettings; cartControl.EditComplete += cartControl_EditComplete; _itemsCount = CurrentCart.GetInfo(PortalId, StoreSettings.SecureCookie).Items; if (IsPostBack == false) { CheckState(_itemsCount); } } }
private void UpdateCartGrid() { _cartTotal = 0; _itemsCount = 0; List <ItemInfo> cartItems = CurrentCart.GetItems(PortalId, StoreSettings.SecureCookie); if (cartItems.Count == 0) { grdItems.Visible = false; lblCartEmpty.Visible = true; } else { grdItems.Visible = true; if (_showThumbnail) { grdItems.Columns[0].Visible = true; } else { grdItems.Columns[0].Visible = false; } grdItems.DataSource = cartItems; grdItems.DataBind(); lblCartEmpty.Visible = false; } }
public ActionResult AddToCart(Dictionary <string, string> item) { if (!item["culture"].IsNullOrEmpty()) { Thread.CurrentThread.CurrentCulture = new CultureInfo(item["culture"]); } Product product_to_add = UvendiaContext.Products.Single <long>(long.Parse(item["p"])); string size = item["size"]; if (product_to_add.HasVariant) { if (size.IsNullOrEmpty()) { product_to_add = product_to_add.Variants.First(); } else { product_to_add = product_to_add.Variants.First(x => string.Equals(x["Size"] as string, size, StringComparison.InvariantCultureIgnoreCase)); } } var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); currentCart.AddProduct(product_to_add, int.Parse(item["qnty"]), SnuffoSettings.GetCurrency(), 0, item["thumb"]); return(PartialView("~/views/partials/_CartShop.cshtml", new CartShopModel())); }
public ActionResult CartPage(ContentModel model) { var cartModel = new CartPageModel(); var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); cartModel.CartItems = currentCart.GetCartItemsByCookieId().OrderBy(c => c.Name).ToList(); if (!cartModel.CartItems.IsNullOrEmpty()) { var productIds = cartModel.CartItems.Where(c => c.ProductId.HasValue).Select(c => c.ProductId); if (productIds.Any()) { cartModel.Products = UvendiaContext.Products.All(productIds.ToArray()).ToList(); } var ticketSaleIds = cartModel.CartItems.Where(c => c.TicketSaleId.HasValue).Select(c => c.TicketSaleId); if (ticketSaleIds.Any()) { cartModel.TicketsSale = UvendiaContext.TicketSales.All(ticketSaleIds.ToArray()).ToList(); } cartModel.Subtotal = currentCart.CalculateSubtotal(cartModel.CartItems); } var checkoutUrl = $"/{CurrentUser.LanguageCode}/cart/checkout-address/"; cartModel.CheckoutUrl = (!CurrentUser.IsAuthenticated) ? $"/{CurrentUser.LanguageCode}/cart/checkout-login/?returnUrl={checkoutUrl}" : checkoutUrl; return(CurrentTemplate(cartModel)); }
private OrderInfo CreateOrder() { // Get current cart ID string cartID = CurrentCart.GetInfo(PortalId, StoreSettings.SecureCookie).CartID; // Associate cart with this user or with impersonated user CartController cartController = new CartController(); if (IsLogged) { cartController.UpdateCart(cartID, UserId); } else { cartController.UpdateCart(cartID, StoreSettings.ImpersonatedUserID); } // Create order from cart content OrderInfo order = _orderController.CreateOrder(cartID); if (order != null) { SetOrderIdCookie(order.OrderID); // Create billing and shipping addresses BillingAddress = _addressProvider.GetAddress(Null.NullInteger); ShippingAddress = _addressProvider.GetAddress(Null.NullInteger); } return(order); }
protected void valCustQuantity_ServerValidate(object source, ServerValidateEventArgs args) { CustomValidator valCustQuantity = (CustomValidator)source; int quantity; if (StoreSettings.InventoryManagement && StoreSettings.AvoidNegativeStock && int.TryParse(args.Value, out quantity)) { string itemID = valCustQuantity.Attributes["ItemID"]; ItemInfo itemInfo = CurrentCart.GetItem(int.Parse(itemID)); ProductController controler = new ProductController(); ProductInfo currentProduct = controler.GetProduct(PortalId, itemInfo.ProductID); if (currentProduct.StockQuantity < quantity) { if (quantity > 1) { valCustQuantity.ErrorMessage = string.Format(Localization.GetString("ErrorQuantityPlural", LocalResourceFile), currentProduct.StockQuantity, currentProduct.ProductTitle); } else if (quantity == 1) { valCustQuantity.ErrorMessage = string.Format(Localization.GetString("ErrorQuantitySingular", LocalResourceFile), currentProduct.ProductTitle); } else { valCustQuantity.ErrorMessage = string.Format(Localization.GetString("ErrorQuantityNegative", LocalResourceFile), currentProduct.ProductTitle); } args.IsValid = false; } } }
protected void btnPayNow_Click(object sender, EventArgs e) { int orderID; if (Int32.TryParse(((Button)sender).CommandArgument, out orderID)) { // Get order details List <OrderDetailInfo> details = _orderController.GetOrderDetails(orderID); if (details != null) { bool secureCookies = StoreSettings.SecureCookie; // Populate cart with order details foreach (OrderDetailInfo detail in details) { CurrentCart.AddItem(PortalId, secureCookies, detail.ProductID, detail.Quantity); } // Set cookie and redirect to checkout page SetOrderIdCookie(orderID); _customerNav = new CustomerNavigation { PageID = "checkout" }; Response.Redirect(_customerNav.GetNavigationUrl(), true); } } }
public ActionResult AddCoupon() { var code = Request["couponcode"] ?? string.Empty; CurrentCart.AddCouponCode(code.Trim()); HccApp.CalculateOrderAndSave(CurrentCart); return(Redirect(Url.RouteHccUrl(HccRoute.Cart))); }
public ActionResult ClearCart() { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); currentCart.ClearCart(); return(PartialView("~/views/partials/_CartShop.cshtml", new CartShopModel())); }
public ActionResult RemoveFromCart(Guid ci) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); currentCart.DeleteCartItem(ci); currentCart.UpdateCartQuantityCount(); return(PartialView("~/views/partials/_CartShop.cshtml", new CartShopModel())); }
public ActionResult CheckoutPaymentPage(ContentModel model) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); var order = currentCart.GetOrder(); if (order.HasOrderProductDetails() && !order.ShippingMethodId.HasValue) { return(Redirect(string.Concat("/", CurrentUser.LanguageCode, "/cart/checkout-shipping"))); } var cpm = new CheckoutPaymentModel(model.Content); cpm.PaymentMethods = UvendiaContext.PaymentMethods.All().Where(p => p.Enabled).ToList(); cpm.SelectedPaymentMethodId = order.PaymentMethodId; cpm.iDealIssuerId = order.MetaData; try { var ideal = cpm.PaymentMethods.Single(x => x.Name.Equals("ideal", StringComparison.InvariantCultureIgnoreCase)); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Connector connector = new Connector(); connector.MerchantId = ideal["MerchantID"]; connector.SubId = ideal["SubID"]; connector.ExpirationPeriod = ideal["ExpirationPeriod"]; connector.MerchantReturnUrl = new Uri(string.Format(ideal["MerchantReturnURL"], CurrentUser.LanguageCode)); ING.iDealAdvanced.Data.Issuers issuers = connector.GetIssuerList(); foreach (var country in issuers.Countries) { foreach (var issuer in country.Issuers) { cpm.iDealIssuerList.Add(new SelectListItem() { Text = issuer.Name, Value = issuer.Id.ToString() }); } } } catch (ING.iDealAdvanced.Data.IDealException iex) { // request consumerMessage MailController.Instance(Request, model.Content, CurrentUser.LanguageCode).MailError(new HandleErrorInfo(iex, "CheckoutPaymentPage", "LoadIssueList")).SendAsync(); } catch (Exception ex) { MailController.Instance(Request, model.Content, CurrentUser.LanguageCode).MailError(new HandleErrorInfo(ex, "CheckoutPaymentPage", "LoadIssueList")).SendAsync(); //throw; } return(CurrentTemplate(cpm)); }
public ActionResult UpdateCart(CartPageModel model) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); foreach (var item in model.CartItems) { currentCart.UpdateQuantity(item.Id, item.Quantity); } currentCart.UpdateCartQuantityCount(); return(Redirect($"/{CurrentUser.LanguageCode}/cart")); }
public ActionResult RemoveCoupon() { var couponid = Request["couponid"] ?? string.Empty; long tempid = 0; long.TryParse(couponid, out tempid); CurrentCart.RemoveCouponCode(tempid); HccApp.CalculateOrderAndSave(CurrentCart); return(Redirect(Url.RouteHccUrl(HccRoute.Cart))); }
/// <summary> /// Adds the specified product to the cart /// </summary> /// <param name="productId">The product id</param> /// <param name="quantity">The product's quantity to be added to the cart</param> /// <exception cref="ProductIsNotForSaleException">Thrown if the product is not for sale</exception> public void AddProductToCart(int productId, int quantity) { var product = ActiveContext.Products .Where(p => p.Id == productId) .SingleOrDefault(); if (product == null || product.IsDiscontinued) { throw new ProductIsNotForSaleException(); } CurrentCart.AddProduct(product.Id, quantity, product.UnitPrice.Value); }
public RedirectToActionResult AddToCurrentCart(int productId, string returnUrl) { Product product = repository.Products .FirstOrDefault(p => p.Id == productId); if (product != null) { CurrentCart currentCart = GetCurrentCart(); currentCart.AddItem(product, 1); SaveCurrentCart(currentCart); } return(RedirectToAction("Index", new { returnUrl })); }
/// <summary> /// Deletes the specified item from the list /// </summary> /// <param name="viewModel">The view model of the item to delete</param> protected override void DeleteItem(BaseRowViewerViewModel viewModel) { OrderRowViewerViewModel vm = viewModel as OrderRowViewerViewModel; // Delete from the items list Items.Remove(viewModel); CurrentCart.Remove(viewModel); vm.ProductViewModel.IsOutFromCart = true; for (int i = ((OrderRowViewerViewModel)viewModel).RowNumber - 1; i < Items.Count; i++) { ((OrderRowViewerViewModel)Items[i]).RowNumber--; } OnPropertyChanged(nameof(TotalPrice)); }
public async Task AddItemToCart(CartItemDTO item, Guid userId) { ShoppingCart CurrentCart = await _unit.Carts.GetCartByUserId(userId); if (CurrentCart is null) { CurrentCart = new ShoppingCart(userId); await _unit.Carts.CreateCart(CurrentCart); } CurrentCart.AddItem(_mapper.Map <CartItem>(item)); _unit.Carts.Update(CurrentCart); }
public ActionResult UpdateOrderCheckoutShipping(CheckoutShippingModel model) { if (ModelState.IsValid) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); var order = currentCart.GetOrder(); order.ShippingMethodId = model.SelectedShippingMethodId.Value; currentCart.SaveOrder(order); return(Redirect($"/{CurrentUser.LanguageCode}/cart/checkout-payment")); } return(CurrentUmbracoPage()); }
/// <summary> /// This event should occur each time a change is made to the cart. /// All of the Checkout controls should be updated with the new cart information and the /// order updated. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void cartControl_EditComplete(object sender, EventArgs e) { CartInfo cart = CurrentCart.GetInfo(PortalId, StoreSettings.SecureCookie); if (cart != null && cart.Items > 0) { Order = _orderController.UpdateOrderDetails(Order.OrderID, cart.CartID); CalculateTaxAndShipping(null); UpdateCheckoutOrder(); } else { Response.Redirect(Globals.NavigateURL(StoreSettings.StorePageID)); } }
protected void ShoppingCartList_OnDataBound(object sender, EventArgs e) { if (CurrentCart.Items.Count() == 0) { return; } Literal SubTotal = (Literal)ShoppingCartList.FindControl("SubTotal"); var ShoppingCartTax = (Literal)ShoppingCartList.FindControl("ShoppingCartTax"); Literal Total = (Literal)ShoppingCartList.FindControl("Total"); SubTotal.Text = CurrentCart.GetSubTotal().ToString(); Total.Text = CurrentCart.GetTotal().ToString(); ShoppingCartTax.Text = SettingsMapper.GetSettings().ShoppingCartTax.ToString(); }
public HttpResponseMessage IsInCart(int productID) { try { int portalID = PortalController.Instance.GetCurrentPortalSettings().PortalId; StoreInfo storeSettings = StoreController.GetStoreInfo(portalID); bool isInCart = CurrentCart.ProductIsInCart(portalID, storeSettings.SecureCookie, productID); return(Request.CreateResponse(HttpStatusCode.OK, isInCart)); } catch { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("Unexpected.Error"))); } }
public ActionResult LanguageCurrencySelect(LanguageCurrencySelectModel model) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); if (!currentCart.HasCartItems()) { SnuffoSettings.SetCurrency(model.SelectedCurrency); } else { base.ShowAlertMessage("Multiple Currencies Detected", "It is not allowed to add multiple type of currencies to your shopping cart", AlertMessageType.Error); } return(CurrentUmbracoPage()); }
protected void Page_Load(object sender, EventArgs e) { if (StoreSettings != null) { try { string templatePath = CssTools.GetTemplatePath(this, StoreSettings.PortalTemplates); CssTools.AddCss(Page, templatePath, StoreSettings.StyleSheet); // Read module settings and define cart properties Core.Cart.MiniCartSettings cartSettings = new ModuleSettings(ModuleId, TabId).MiniCart; cartControl.ShowThumbnail = cartSettings.ShowThumbnail; cartControl.ThumbnailWidth = cartSettings.ThumbnailWidth; cartControl.GIFBgColor = cartSettings.GIFBgColor; cartControl.EnableImageCaching = cartSettings.EnableImageCaching; cartControl.CacheImageDuration = cartSettings.CacheImageDuration; cartControl.ProductColumn = cartSettings.ProductColumn.ToLower(); cartControl.LinkToDetail = cartSettings.LinkToDetail; cartControl.IncludeVAT = cartSettings.IncludeVAT; cartControl.TemplatePath = templatePath; cartControl.ModuleConfiguration = ModuleConfiguration; cartControl.StoreSettings = StoreSettings; cartControl.EditComplete += cartControl_EditComplete; _itemsCount = CurrentCart.GetItems(PortalId, StoreSettings.SecureCookie).Count; if (_itemsCount == 0) { phlViewCart.Visible = false; } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } } else { if (UserInfo.IsSuperUser) { string ErrorSettings = Localization.GetString("ErrorSettings", LocalResourceFile); string ErrorSettingsHeading = Localization.GetString("ErrorSettingsHeading", LocalResourceFile); UI.Skins.Skin.AddModuleMessage(this, ErrorSettingsHeading, ErrorSettings, UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning); } divControls.Visible = false; } }
public ActionResult CheckoutShippingPage(ContentModel model) { var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); var order = currentCart.GetOrder(); if (!order.InvoiceAddressId.HasValue) { return(Redirect(string.Concat("/", CurrentUser.LanguageCode, "/cart/checkout-address"))); } var csm = new CheckoutShippingModel(model.Content); csm.ShippingMethods = UvendiaContext.ShippingMethods.All().Where(s => s.Enabled).ToList(); csm.SelectedShippingMethodId = order.ShippingMethodId; return(CurrentTemplate(csm)); }
public CartShopModel() { CurrentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME); if (CurrentCart.HasCartItems()) { var items = CurrentCart.GetCartItemsByCookieId(); if (!items.IsNullOrEmpty()) { CartItems = items.OrderBy(c => c.Name); var productIds = items.Select(x => x.ProductId); Subtotal = items.Sum(x => (x.Quantity * x.UnitPrice)); } var checkoutUrl = $"/{CurrentUser.LanguageCode}/cart/checkout-address/"; CheckoutUrl = (!CurrentUser.IsAuthenticated) ? $"/{CurrentUser.LanguageCode}/cart/checkout-login/?returnUrl={checkoutUrl}" : checkoutUrl; } }