private void AddItemToShoppingCart() { OptionItemValueCollection selectedOptions = uxOptionGroupDetails.GetSelectedOptions(); ProductKitItemValueCollection selectedKits = uxProductKitGroupDetails.GetSelectedProductKitItems(); CartItemGiftDetails giftDetails = CreateGiftDetails(); decimal customPrice = decimal.Parse(uxEnterAmountText.Text); customPrice = decimal.Divide(customPrice, Convert.ToDecimal(StoreContext.Currency.ConversionRate)); CartAddItemService addToCartService = new CartAddItemService( StoreContext.Culture, StoreContext.ShoppingCart); int currentStock; string errorOptionName; bool stockOK = addToCartService.AddToCart( CurrentProduct, selectedOptions, selectedKits, ConvertUtilities.ToInt32(uxQuantityText.Text), giftDetails, customPrice, out errorOptionName, out currentStock); if (stockOK) { Response.Redirect("ShoppingCart.aspx"); } else { DisplayOutOfStockError(currentStock, errorOptionName); } }
private void AddItemToShoppingCart(DataListItem item, out string errorMessage) { Components_OptionGroupDetails uxOptionGroupDetails = (Components_OptionGroupDetails)item.FindControl("uxOptionGroupDetails"); Components_GiftCertificateDetails uxGiftCertificateDetails = (Components_GiftCertificateDetails)item.FindControl("uxGiftCertificateDetails"); TextBox uxEnterAmountText = (TextBox)item.FindControl("uxEnterAmountText"); TextBox uxQuantityText = (TextBox)item.FindControl("uxQuantityText"); decimal customPrice = decimal.Divide(decimal.Parse(uxEnterAmountText.Text), Convert.ToDecimal(StoreContext.Currency.ConversionRate)); CartAddItemService addToCartService = new CartAddItemService( StoreContext.Culture, StoreContext.ShoppingCart); int currentStock; string errorOptionName; bool stockOK = addToCartService.AddToCart( CurrentProduct, uxOptionGroupDetails.GetSelectedOptions(), ProductKitItemValueCollection.Null, ConvertUtilities.ToInt32(uxQuantityText.Text), uxGiftCertificateDetails.GetCartItemGiftDetails(), customPrice, out errorOptionName, out currentStock); if (stockOK) { errorMessage = String.Empty; bool enableNotification = ConvertUtilities.ToBoolean(DataAccessContext.Configurations.GetValue("EnableAddToCartNotification", StoreContext.CurrentStore)); if (UrlManager.IsMobileDevice(Request)) { enableNotification = false; } if (enableNotification) { uxAddToCartNotification.Show(CurrentProduct, ConvertUtilities.ToInt32(uxQuantityText.Text), customPrice, uxGiftCertificateDetails.GetCartItemGiftDetails(), uxOptionGroupDetails.GetSelectedOptions(), ProductKitItemValueCollection.Null); uxAddtoCartUpdate.Update(); } else { Response.Redirect("ShoppingCart.aspx"); } } else { DisplayOutOfStockError(currentStock, errorOptionName, out errorMessage); } }
private void AddItemToShoppingCart() { OptionItemValueCollection selectedOptions = uxOptionGroupDetails.GetSelectedOptions(); ProductKitItemValueCollection selectedKits = uxProductKitGroupDetails.GetSelectedProductKitItems(); CartItemGiftDetails giftDetails = CreateGiftDetails(); decimal customPrice = decimal.Parse(uxEnterAmountText.Text); customPrice = decimal.Divide(customPrice, Convert.ToDecimal(StoreContext.Currency.ConversionRate)); CartAddItemService addToCartService = new CartAddItemService( StoreContext.Culture, StoreContext.ShoppingCart); int currentStock; string errorOptionName; bool stockOK = addToCartService.AddToCart( CurrentProduct, selectedOptions, selectedKits, ConvertUtilities.ToInt32(uxQuantityText.Text), giftDetails, customPrice, out errorOptionName, out currentStock); if (stockOK) { bool enableNotification = ConvertUtilities.ToBoolean(DataAccessContext.Configurations.GetValue("EnableAddToCartNotification", StoreContext.CurrentStore)); if (UrlManager.IsMobileDevice(Request)) { enableNotification = false; } if (enableNotification) { uxAddToCartNotification.Show(CurrentProduct, ConvertUtilities.ToInt32(uxQuantityText.Text), customPrice, giftDetails, selectedOptions, selectedKits); } else { Response.Redirect("ShoppingCart.aspx"); } } else { DisplayOutOfStockError(currentStock, errorOptionName); } }
private bool ReOrderToCart(Product product, OrderItem orderItem, string optionItemIDs, ProductKitItemValueCollection itemCollection) { string errorCurrentStock = string.Empty; int currentStock = 0; bool isAddToCartSuccess = false; OptionItemValueCollection optionCollection = new OptionItemValueCollection(StoreContext.Culture, optionItemIDs, product.ProductID); CartItemGiftDetails giftDetails = new CartItemGiftDetails(); if (product.IsGiftCertificate) { GiftCertificateProduct giftProduct = (GiftCertificateProduct)product; IList <GiftCertificate> giftCertificateList = DataAccessContext.GiftCertificateRepository.GetAllByOrderID(orderItem.OrderID); foreach (GiftCertificate giftCertificate in giftCertificateList) { if (orderItem.OrderItemID == giftCertificate.OrderItemID) { giftDetails = new CartItemGiftDetails( giftCertificate.Recipient, giftCertificate.PersonalNote, giftCertificate.NeedPhysical, giftCertificate.GiftValue); } } if (giftProduct.GiftAmount == 0) { giftProduct.GiftAmount = orderItem.UnitPrice; } product = (Product)giftProduct; CartAddItemService addToCartService = new CartAddItemService( StoreContext.Culture, StoreContext.ShoppingCart); isAddToCartSuccess = addToCartService.AddToCart( product, optionCollection, itemCollection, orderItem.Quantity, giftDetails, 0, out errorCurrentStock, out currentStock); } else if (product.IsCustomPrice) { CartAddItemService addToCartService = new CartAddItemService( StoreContext.Culture, StoreContext.ShoppingCart); isAddToCartSuccess = addToCartService.AddToCart( product, optionCollection, itemCollection, GetProductQuantity(product, orderItem), giftDetails, orderItem.UnitPrice, out errorCurrentStock, out currentStock); } else { CartAddItemService addToCartService = new CartAddItemService( StoreContext.Culture, StoreContext.ShoppingCart); isAddToCartSuccess = addToCartService.AddToCart( product, optionCollection, itemCollection, GetProductQuantity(product, orderItem), giftDetails, 0, out errorCurrentStock, out currentStock); } if (!isAddToCartSuccess) { StoreContext.ClearCheckoutSession(); string message = "<p class=\"ErrorHeader\">[$StockError]</p>"; ErrorMessage(message); return(false); } return(true); }