// Product Pricing public UserSpecificPrice PriceProduct(string productBvin, string userId, OptionSelections selections) { var p = CatalogServices.Products.FindWithCache(productBvin); var customer = MembershipServices.Customers.Find(userId); return(PriceProduct(p, customer, selections, CurrentlyActiveSales)); }
private void ValidateInventory(ProductValidateResponse validateResult, Product product, OptionSelections selections) { // Make sure we have stock on the product or variant var data = HccApp.CatalogServices.InventoryCheck(product, selections); validateResult.StockMessage = data.InventoryMessage; validateResult.IsValid &= data.IsAvailableForSale; }
private OptionSelections ParseSelections(Product product, bool allOptions) { var result = new OptionSelections(); if (!product.IsBundle) { foreach (var opt in product.Options) { if (!allOptions) { if (opt.OptionType == OptionTypes.Html || opt.OptionType == OptionTypes.TextInput) { continue; } } var selected = opt.ParseFromForm(Request.Form); if (selected != null) { result.OptionSelectionList.Add(selected); } } } else { foreach (var bundledProductAdv in product.BundledProducts) { var bundledProduct = bundledProductAdv.BundledProduct; if (bundledProduct == null) { continue; } foreach (var opt in bundledProduct.Options) { if (!allOptions) { if (opt.OptionType == OptionTypes.Html || opt.OptionType == OptionTypes.TextInput) { continue; } } var selected = opt.ParseFromForm(Request.Form, bundledProductAdv.Id.ToString()); if (selected != null) { result.AddBundleSelections(bundledProductAdv.Id, selected); } } } } return(result); }
private void ValidateSelections(ProductValidateResponse validateResult, Product product, OptionSelections selections) { string message; if (!ValidateSelections(product, selections, out message)) { validateResult.IsValid = false; validateResult.Message = message; } }
public PurchasableSnapshot() { ProductId = string.Empty; VariantId = string.Empty; Name = string.Empty; Sku = string.Empty; Description = string.Empty; BasePrice = 0m; IsTaxExempt = false; TaxScheduleId = 0; SelectionData = new OptionSelections(); ShippingDetails = new ShippableItem(); IsBundle = false; IsGiftCard = false; IsRecurring = false; }
/// <summary> /// Set default values /// </summary> public ProductPageViewModel() { LocalProduct = new Product(); IsAvailableForSale = true; StockMessage = string.Empty; Quantity = 1; Selections = new OptionSelections(); PreRenderedTypeValues = string.Empty; RelatedItems = new List <SingleProductViewModel>(); BundledItems = new List <BundledProductViewModel>(); ValidationMessage = string.Empty; LineItemId = null; IsAvailableForWishList = false; SwatchHtml = string.Empty; AlternateImageUrls = new List <ProductImageUrls>(); }
public LineItem() { Id = 0; StoreId = 0; LastUpdatedUtc = DateTime.UtcNow; BasePricePerItem = 0m; DiscountDetails = new List <DiscountDetail>(); OrderBvin = string.Empty; ProductId = string.Empty; VariantId = string.Empty; ProductName = string.Empty; ProductSku = string.Empty; ProductShortDescription = string.Empty; Quantity = 1; QuantityReserved = 0; QuantityReturned = 0; QuantityShipped = 0; ShippingPortion = 0m; StatusCode = string.Empty; StatusName = string.Empty; TaxRate = 0; TaxPortion = 0m; SelectionData = new OptionSelections(); IsNonShipping = false; TaxSchedule = 0; ProductShippingHeight = 0m; ProductShippingLength = 0m; ProductShippingWeight = 0m; ProductShippingWidth = 0m; CustomProperties = new CustomPropertyCollection(); ShipFromAddress = new Address(); ShipFromMode = ShippingMode.ShipFromSite; ShippingCharge = ShippingChargeType.ChargeShippingAndHandling; ShipFromNotificationId = string.Empty; ShipSeparately = false; ExtraShipCharge = 0; IsTaxExempt = false; FreeShippingMethodIds = new List <string>(); RecurringBilling = new RecurringBilling(this); }
private bool ValidateSelections(Product product, OptionSelections selections, out string message) { message = null; var result = product.ValidateSelections(selections); switch (result) { case ValidateSelectionsResult.RequiredOptionNotSelected: message = Localization.GetString("RequiredOptions"); return(false); case ValidateSelectionsResult.LabelsSelected: message = Localization.GetString("AllSelectionsError"); return(false); case ValidateSelectionsResult.OptionsNotAvailable: message = Localization.GetString("OptionsNotAvailable"); return(false); } return(true); }
private OptionSelections ParseSelections(Product product) { var result = new OptionSelections(); if (!product.IsBundle) { foreach (var opt in product.Options) { var selected = opt.ParseFromPlaceholder(phChoices); if (selected != null) { result.OptionSelectionList.Add(selected); } } } else { foreach (var bundledProductAdv in product.BundledProducts) { var bundledProduct = bundledProductAdv.BundledProduct; if (bundledProduct == null) { continue; } foreach (var opt in bundledProduct.Options) { var selected = opt.ParseFromPlaceholder(phChoices, bundledProductAdv.Id.ToString()); if (selected != null) { result.AddBundleSelections(bundledProductAdv.Id, selected); } } } } return(result); }
private bool ValidateSelections(Product p, OptionSelections selections) { var result = p.ValidateSelections(selections); return(result == ValidateSelectionsResult.Success); }
public UserSpecificPrice PriceProduct(Product p, CustomerAccount currentUser, OptionSelections selections, List <Promotion> currentSales) { if (p == null) { return(null); } var result = new UserSpecificPrice(p, selections, CurrentStore.Settings); AdjustProductPriceForUser(result, p, currentUser); ApplySales(result, p, currentUser, currentSales); CheckForPricesBelowZero(result); return(result); }
private void AddProductBySku() { SwitchProductPicker(false); if (string.IsNullOrWhiteSpace(NewSkuField.Text)) { ucMessageBox.ShowWarning("Please enter a sku first."); return; } var p = HccApp.CatalogServices.Products.FindBySku(NewSkuField.Text.Trim()); if (p != null && p.Sku.Length > 0) { if (CurrentOrder.Items.Count > 0 && p.IsRecurring != CurrentOrder.IsRecurring) { ucMessageBox.ShowError( "You can not mix recurring products with regular products within the same order"); return; } if (p.HasOptions() || p.IsUserSuppliedPrice || p.IsBundle) { ShowProductOptions(p); } else { if (CurrentOrder != null) { var quantity = 1; if (!p.HideQty) { int.TryParse(NewProductQuantity.Text, out quantity); } var selections = new OptionSelections(); var li = p.ConvertToLineItem(HccApp, quantity, selections); if (!CheckValidQty(CurrentOrder, li)) { return; } if (li.IsGiftCard) { if (IsGiftCardView.Value.ToLower() != "true") { RenderGiftCardDetails(li); IsGiftCardView.Value = "true"; btnAddProductBySku.Visible = false; return; } li.CustomPropGiftCardEmail = GiftCardRecEmail.Text; li.CustomPropGiftCardName = GiftCardRecName.Text; li.CustomPropGiftCardMessage = GiftCardMessage.Text; decimal gcAmount = 0; if (string.IsNullOrEmpty(lstAmount.SelectedValue)) { if (decimal.TryParse(GiftCardAmount.Text, out gcAmount)) { li.BasePricePerItem = Money.RoundCurrency(gcAmount); } } else { if (decimal.TryParse(lstAmount.SelectedValue, out gcAmount)) { li.BasePricePerItem = Money.RoundCurrency(gcAmount); } } } foreach (var item in CurrentOrder.Items) { item.QuantityReserved = item.Quantity; } HccApp.OrderServices.AddItemToOrder(CurrentOrder, li); HccApp.CalculateOrder(CurrentOrder); HccApp.OrderServices.EvaluatePaymentStatus(CurrentOrder); HccApp.OrderServices.Orders.Upsert(CurrentOrder); // Update Inventory only. li.Quantity = quantity; HccApp.CatalogServices.InventoryLineItemReserveInventory(li); ucMessageBox.ShowOk("Product Added!"); ProductAdded(this, EventArgs.Empty); IsGiftCardView.Value = "false"; ClearGiftCardDetails(); } } } else { ucMessageBox.ShowWarning("That SKU could not be located. Please try again."); } }