示例#1
0
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            bool result = false;

            if (selections == null)
            {
                return(false);
            }

            OptionSelection val = selections.FindByOptionId(item.OptionBvin);

            if (val == null)
            {
                return(result);
            }

            string[] vals = val.SelectionData.Split(',');
            foreach (string s in vals)
            {
                if (s == item.Bvin.Replace("-", ""))
                {
                    return(true);
                }
            }
            return(result);
        }
        public string RenderWithSelection(Option option, OptionSelectionList selections, string prefix = null, string className = null)
        {
            var sb   = new StringBuilder();
            var bvin = option.Bvin.Replace("-", string.Empty);

            foreach (var oi in option.Items)
            {
                sb.Append("<label>");
                if (!oi.IsLabel)
                {
                    var oiBvin = oi.Bvin.Replace("-", string.Empty);
                    sb.AppendFormat(CHECKBOX_MARKUP_FORMAT, className, bvin, prefix, oiBvin);
                    //sb.Append(
                    //    "<input type=\"checkbox\" style=\"display: inline !important;\" class=\"hcIsOption  check" +
                    //    bvin +
                    //    "\" name=\"opt" + prefix + bvin +
                    //    "\" value=\"" + oiBvin + "\"");

                    if (IsSelected(oi, selections))
                    {
                        sb.Append(" checked=\"checked\" ");
                    }

                    sb.Append("/>");
                }
                sb.Append(string.Concat(oi.Name, "</label><br />"));
            }

            return(sb.ToString());
        }
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            var result = false;

            if (selections == null || selections.Count < 1)
            {
                return(item.IsDefault);
            }

            var val = selections.FindByOptionId(item.OptionBvin);

            if (val == null)
            {
                return(result);
            }

            var vals = val.SelectionData.Split(',');

            foreach (var s in vals)
            {
                if (s == item.Bvin.Replace("-", string.Empty))
                {
                    return(true);
                }
            }
            return(result);
        }
示例#4
0
        public void SetSelectionsInPlaceholder(Option baseOption, PlaceHolder ph, OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            var ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", string.Empty));

            if (ddl != null)
            {
                if (ddl.Items.FindByValue(val.SelectionData) != null)
                {
                    ddl.ClearSelection();
                    ddl.Items.FindByValue(val.SelectionData).Selected = true;
                }
            }
        }
示例#5
0
        public void SetSelectionsInPlaceholder(Option baseOption, PlaceHolder ph, OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            var radioId = "opt" + val.SelectionData.Replace("-", string.Empty);
            var rb      = (HtmlInputRadioButton)ph.FindControl(radioId);

            if (rb != null)
            {
                rb.Checked = true;
            }
        }
示例#6
0
        public string RenderWithSelection(Option option, OptionSelectionList selections, string prefix = null)
        {
            var sb   = new StringBuilder();
            var bvin = option.Bvin.Replace("-", string.Empty);

            foreach (var oi in option.Items)
            {
                sb.Append("<label>");
                if (!oi.IsLabel)
                {
                    var oiBvin = oi.Bvin.Replace("-", string.Empty);
                    sb.Append("<input type=\"radio\" name=\"opt" + prefix + bvin + "\" value=\"" + oiBvin +
                              "\" style=\"display: inline !important;\"");
                    sb.Append(" class=\"hcIsOption radio" + bvin + "\" ");

                    if (IsSelected(oi, selections))
                    {
                        sb.Append(" checked=\"checked\" ");
                    }

                    sb.Append("/>");
                }
                sb.Append(oi.Name + "</label><br />");
            }

            return(sb.ToString());
        }
示例#7
0
        private bool ValidateSelections(Product p, OptionSelectionList selections)
        {
            bool result = false;

            if ((p.HasOptions()))
            {
                if ((p.HasVariants()))
                {
                    Variant v = p.Variants.FindBySelectionData(selections, p.Options);
                    if ((v != null))
                    {
                        result = true;
                    }
                    else
                    {
                        this.litMessage.Text = "<div class=\"flash-message-warning\">The options you've selected aren't available at the moment. Please select different options.</div>";
                    }
                }
                else
                {
                    result = true;
                }

                // Price Modifiers Here
            }
            else
            {
                result = true;
            }

            return(result);
        }
        private void PriceForSelections(Catalog.Product p, OptionSelectionList selections)
        {
            this.IsValid = true;
            this.VariantId = string.Empty;
            this._ModifierAdjustments = 0;

            if (selections == null) return;
            if (p == null) return;

            // Check for Option Price Modifiers
            if (!p.HasOptions()) return;
            this._ModifierAdjustments = selections.GetPriceAdjustmentForSelections(p.Options);
            this.BasePrice += this._ModifierAdjustments;

            // Check for Variant Changes
            if (!p.HasVariants()) return;
            Variant v = p.Variants.FindBySelectionData(selections, p.Options);
            if (v == null)
            {
                this.IsValid = false;
                return;
            }

            // Assign Variant Attributes to this price data
            this.VariantId = v.Bvin;
            if (v.Sku.Trim().Length > 0) this.Sku = v.Sku;
            if (v.Price >= 0) this.BasePrice = v.Price + this._ModifierAdjustments;

        }
        /// <summary>
        ///     Used to show the option values in view order
        /// </summary>
        /// <param name="baseOption"></param>
        /// <param name="selections"></param>
        /// <returns></returns>
        public string CartDescription(Option baseOption, OptionSelectionList selections)
        {
            if (selections == null)
            {
                return(string.Empty);
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(string.Empty);
            }

            if (!string.IsNullOrWhiteSpace(val.SelectionData))
            {
                var files = val.SelectionData.Split('|').ToList();

                if (files.Count <= 0)
                {
                    return(string.Empty);
                }

                var downloadLinks = string.Empty;
                var strFormat     = "<li><a href=\"{0}\" target=\"_blank\" class=\"fileDownLoadLink\">{1}</a><span class=\"fileSize\"> ({2})</span></li>";

                foreach (var file in files)
                {
                    if (string.IsNullOrWhiteSpace(file))
                    {
                        continue;
                    }

                    var fileParam = file.Split('<');


                    //Temporary fix : Revert back of fix - Replace character ? (questionmark) with - (dash)
                    //See ParseFromForm function for root cause
                    var fileDownloadPath = fileParam[0].Replace('?', '-');


                    var fileSize = fileParam[1];
                    var fileName = Path.GetFileName(fileDownloadPath);
                    var fileHtml = string.Format(strFormat, fileDownloadPath, fileName, fileSize);

                    //var fileHtml = "<li>" +
                    //               "<a href=\"" + fileDownloadPath + "\" target=\"_blank\" class=\"fileDownLoadLink\" >" +
                    //               fileName + "</a><span class=\"fileSize\" > (" + fileSize + ")</span>" +
                    //               "</li>";

                    downloadLinks = string.Concat(downloadLinks, fileHtml);
                }

                var bvin = baseOption.Bvin.Replace("-", string.Empty);
                downloadLinks = string.Format("<br /><ul id=\"downloads-{0}\" class=\"fileDownLoadLinks\">{1}</ul>", bvin, downloadLinks);

                return(string.Concat(baseOption.Name, ": ", downloadLinks));
            }

            return(string.Empty);
        }
示例#10
0
        public void SetSelectionsInPlaceholder(Option baseOption, PlaceHolder ph, OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            var vals = val.SelectionData.Split(',');

            foreach (var s in vals)
            {
                var checkId = string.Concat("opt", s.Replace("-", string.Empty));
                var cb      = (HtmlInputCheckBox)ph.FindControl(checkId);
                if (cb != null)
                {
                    cb.Checked = true;
                }
            }
        }
示例#11
0
        /// <summary>
        ///     Used to show the option values in view order
        /// </summary>
        /// <param name="baseOption"></param>
        /// <param name="selections"></param>
        /// <returns></returns>
        public string CartDescription(Option baseOption, OptionSelectionList selections)
        {
            if (selections == null)
            {
                return(string.Empty);
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(string.Empty);
            }

            if (!string.IsNullOrWhiteSpace(val.SelectionData))
            {
                var files = val.SelectionData.Split('|').ToList();

                if (files.Count <= 0)
                {
                    return(string.Empty);
                }

                var downloadLinks = string.Empty;

                foreach (var file in files)
                {
                    if (string.IsNullOrWhiteSpace(file))
                    {
                        continue;
                    }

                    var fileParam = file.Split('<');


                    //Temporary fix : Revert back of fix - Replace character ? (questionmark) with - (dash)
                    //See ParseFromForm function for root cause
                    var fileDownloadPath = fileParam[0].Replace('?', '-');


                    var fileSize = fileParam[1];
                    var fileName = Path.GetFileName(fileDownloadPath);

                    var fileHtml = "<li>" +
                                   "<a href=\"" + fileDownloadPath + "\" target=\"_blank\" class=\"fileDownLoadLink\" >" +
                                   fileName + "</a><span class=\"fileSize\" > (" + fileSize + ")</span>" +
                                   "</li>";
                    downloadLinks += fileHtml;
                }

                var bvin = baseOption.Bvin.Replace("-", string.Empty);
                downloadLinks = "<br>" +
                                "<ul class=\"fileDownLoadLinks\" >" +
                                downloadLinks +
                                "</ul>";
                return(baseOption.Name + ": " + downloadLinks); //System.Web.HttpUtility.HtmlDecode(val.SelectionData);
            }

            return(string.Empty);
        }
示例#12
0
 public Variant()
 {
     this.StoreId = 0;
     this.Bvin = string.Empty;
     this.ProductId = string.Empty;
     this.Sku = string.Empty;
     this.Price = -1;
     this.Selections = new OptionSelectionList();
 }
示例#13
0
        public List <string> GetSelectionValues(Option option, OptionSelectionList selections)
        {
            var opSel = selections.FindByOptionId(option.Bvin);
            var data  = opSel != null ? opSel.SelectionData : null;
            var vals  = new List <string> {
                data
            };

            return(vals);
        }
示例#14
0
        public ActionResult Validate()
        {
            ProductValidateResponse result = new ProductValidateResponse();

            string  bvin = Request.Form["productbvin"];
            Product p    = MTApp.CatalogServices.Products.Find(bvin);

            if ((p != null))
            {
                OptionSelectionList selections = ParseSelections(p);



                UserSpecificPrice price = MTApp.PriceProduct(p, MTApp.CurrentCustomer, selections);

                result.Price    = MerchantTribe.Commerce.Utilities.HtmlRendering.UserSpecificPriceForDisplay(price);
                result.Sku      = price.Sku;
                result.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlMedium(MTApp, p.Bvin, p.ImageFileSmall, false);
                result.IsValid  = price.IsValid;
                if (result.IsValid)
                {
                    result.Message = string.Empty;
                }
                else
                {
                    result.Message = "<div class=\"flash-message-warning\">The combination of options you've selected isn't available at the moment. Please select different options.</div>";
                }
                if (price.VariantId.Length > 0)
                {
                    result.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductVariantImageUrlMedium(MTApp, p.Bvin, p.ImageFileSmall, price.VariantId, false);
                }

                // Make sure we have stock on the product or variant
                InventoryCheckData data = MTApp.CatalogServices.InventoryCheck(p, price.VariantId);
                result.StockMessage = data.InventoryMessage;
                if (result.IsValid)
                {
                    if (!data.IsAvailableForSale)
                    {
                        result.IsValid = false;
                        // Should this be here?
                        //result.Message = "Out of stock?";
                    }
                }

                // Make sure no "labels" are selected
                if (selections.HasLabelsSelected())
                {
                    result.IsValid = false;
                    result.Message = "<div class=\"flash-message-warning\">Please make all selections before adding to cart.</div>";
                }
            }

            return(new PreJsonResult(MerchantTribe.Web.Json.ObjectToJson(result)));
        }
示例#15
0
        private void AddProductBySku()
        {
            this.MessageBox1.ClearMessage();
            this.pnlProductChoices.Visible = false;

            Order o = MTApp.OrderServices.Orders.FindForCurrentStore(this.BvinField.Value);

            if (this.NewSkuField.Text.Trim().Length < 1)
            {
                this.MessageBox1.ShowWarning("Please enter a sku first.");
            }
            else
            {
                Product p = MTApp.CatalogServices.Products.FindBySku(this.NewSkuField.Text.Trim());

                if (p != null && p.Sku.Length > 0)
                {
                    if (p.HasOptions())
                    {
                        this.pnlAddControls.Visible         = false;
                        this.pnlProductChoices.Visible      = true;
                        this.AddProductSkuHiddenField.Value = p.Bvin;

                        // Render Options
                        this.phChoices.Controls.Clear();
                        this.phChoices.Controls.Add(new System.Web.UI.LiteralControl("<div id=\"options\">"));
                        MerchantTribe.Commerce.Utilities.HtmlRendering.ProductOptionsAsControls(p.Options, phChoices);
                        this.phChoices.Controls.Add(new System.Web.UI.LiteralControl("<div class=\"clear\"></div></div>"));
                        this.litProductInfo.Text = p.Sku + " | " + p.ProductName;
                    }
                    else
                    {
                        if (o != null)
                        {
                            int quantity = 1;
                            int.TryParse(this.NewProductQuantity.Text, out quantity);
                            OptionSelectionList selections = new OptionSelectionList();
                            LineItem            li         = MTApp.CatalogServices.ConvertProductToLineItem(p,
                                                                                                            selections,
                                                                                                            quantity,
                                                                                                            MTApp);
                            o.Items.Add(li);
                            MTApp.OrderServices.Orders.Update(o);
                            this.MessageBox1.ShowOk("Product Added!");
                        }
                    }
                }
                else
                {
                    this.MessageBox1.ShowInformation("That SKU could not be located. Please try again.");
                }
            }
            MTApp.OrderServices.Orders.Update(o);
            LoadOrder(o.bvin);
        }
示例#16
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections, string prefix = null, string className = null)
        {
            var selected = string.Empty;

            if (selections != null)
            {
                var sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            var sb = new StringBuilder();

            var cols = GetColumns(baseOption);

            if (string.IsNullOrEmpty(cols))
            {
                cols = DEFAULT_COLS;
            }

            var rows = GetRows(baseOption);

            if (string.IsNullOrEmpty(rows))
            {
                rows = DEFAULT_ROWS;
            }

            var optionNameId = string.Concat("opt", prefix, baseOption.Bvin.Replace("-", string.Empty));

            if (rows != DEFAULT_ROWS)
            {
                sb.AppendFormat(TEXTAREA_MARKUP_FORMAT, optionNameId, cols, rows, selected, className);
                //sb.Append("<textarea id=\"" + optionNameId + "\" cols=\"" + c + "\" rows=\"" + r + "\" ");
                //sb.Append(" name=\"" + optionNameId + "\" ");
                //sb.Append(">");
                //sb.Append(selected);
                //sb.Append("</textarea>");
            }
            else
            {
                var maxLength = GetMaxLength(baseOption);

                // HCC 03.03.00 ignoring the cols HTML attribute in <input type="text" />
                sb.AppendFormat(TEXTBOX_MARKUP_FORMAT, optionNameId, maxLength, selected, className);
                //sb.Append("<input type=\"text\" id=\"" + optionNameId + "\" cols=\"" + c + "\" maxlength=\"" +
                //          maxLength + "\"");
                //sb.Append(" name=\"" + optionNameId + "\" ");
                //sb.Append(" value=\"" + selected + "\"");
                //sb.Append("/>");
            }

            return(sb.ToString());
        }
示例#17
0
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            bool result = false;
            if (selections == null) return false;

            OptionSelection val = selections.FindByOptionId(item.OptionBvin);
            if (val == null) return result;

            if (val.SelectionData == item.Bvin.Replace("-","")) return true;
            
            return result;
        }
示例#18
0
        public List <string> GetSelectionValues(Option option, OptionSelectionList selections)
        {
            var opSel = selections.FindByOptionId(option.Bvin);
            var data  = opSel != null ? opSel.SelectionData : null;
            var vals  = new List <string>();

            if (!string.IsNullOrEmpty(data))
            {
                vals = option.Items.Where(i => data == i.Bvin.Replace("-", string.Empty)).Select(i => i.Name).ToList();
            }

            return(vals);
        }
示例#19
0
        public List <string> GetSelectionValues(Option baseOption, OptionSelectionList selections)
        {
            var retVal = new List <string>();

            if (selections == null)
            {
                return(retVal);
            }

            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(retVal);
            }

            if (!string.IsNullOrWhiteSpace(val.SelectionData))
            {
                var files = val.SelectionData.Split('|').ToList();

                if (files.Count <= 0)
                {
                    return(retVal);
                }
                var downloadLinks = string.Empty;

                foreach (var file in files)
                {
                    if (string.IsNullOrWhiteSpace(file))
                    {
                        continue;
                    }

                    var fileParam = file.Split('<');

                    //Temporary fix : Revert back of fix - Replace character ? (questionmark) with - (dash)
                    //See ParseFromForm function for root cause
                    var fileDownloadPath = fileParam[0].Replace('?', '-');

                    var fileSize = fileParam[1];
                    var fileName = Path.GetFileName(fileDownloadPath);

                    var fileDetails = string.Concat(fileName, " (", fileSize, ") ");
                    retVal.Add(fileDetails);
                }

                return(retVal);
            }

            return(retVal);
        }
示例#20
0
 public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
 {
     StringBuilder sb = new StringBuilder();
     foreach (OptionItem o in baseOption.Items)
     {
         sb.Append("<input type=\"radio\" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" value=\"" + o.Bvin.Replace("-", "") + "\"");                
         sb.Append(" class=\"isoption radio" + baseOption.Bvin.Replace("-", "") + "\" ");                                
         if (IsSelected(o, selections))
         {
             sb.Append(" checked=\"checked\" ");
         }
         sb.Append("/>" + o.Name + "<br />");
     }
     return sb.ToString();
 }
示例#21
0
        private OptionSelectionList ParseSelections(Product p)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in p.Options)
            {
                OptionSelection selected = opt.ParseFromPlaceholder(this.phChoices);
                if (selected != null)
                {
                    result.Add(selected);
                }
            }

            return(result);
        }
示例#22
0
        private void ParseSelections(ProductPageViewModel model)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in model.LocalProduct.Options)
            {
                OptionSelection selected = opt.ParseFromForm(Request.Form);
                if (selected != null)
                {
                    result.Add(selected);
                }
            }

            model.Selections = result;
        }
示例#23
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections, string prefix = null)
        {
            var selected = string.Empty;

            if (selections != null)
            {
                var sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            var sb = new StringBuilder();
            var c  = GetColumns(baseOption);

            if (string.IsNullOrEmpty(c))
            {
                c = "20";
            }
            var r = GetRows(baseOption);

            if (string.IsNullOrEmpty(r))
            {
                r = "1";
            }

            var optionNameId = "opt" + prefix + baseOption.Bvin.Replace("-", string.Empty);

            if (r != "1")
            {
                sb.Append("<textarea id=\"" + optionNameId + "\" cols=\"" + c + "\" rows=\"" + r + "\" ");
                sb.Append(" name=\"" + optionNameId + "\" ");
                sb.Append(">");
                sb.Append(selected);
                sb.Append("</textarea>");
            }
            else
            {
                sb.Append("<input type=\"text\" id=\"" + optionNameId + "\" cols=\"" + c + "\" maxlength=\"" +
                          GetMaxLength(baseOption) + "\"");
                sb.Append(" name=\"" + optionNameId + "\" ");
                sb.Append(" value=\"" + selected + "\"");
                sb.Append("/>");
            }

            return(sb.ToString());
        }
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections, string prefix = null, string className = null)
        {
            string selected = null;

            if (selections != null)
            {
                var sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            var sb    = new StringBuilder();
            var oBvin = baseOption.Bvin.Replace("-", string.Empty);

            sb.AppendFormat(DROPDOWN_MARKUP_FORMAT, prefix, oBvin, className);

            //sb.Append("<select id=\"opt" + prefix + oBvin + "\" ");
            //sb.Append(" name=\"opt" + prefix + oBvin + "\" ");
            //sb.Append(" class=\"hcIsOption\" >");

            foreach (var o in baseOption.Items)
            {
                if (o.IsLabel)
                {
                    sb.Append("<option value=\"\" disabled");

                    if (string.IsNullOrEmpty(selected) && o.IsDefault)
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(string.Concat(">", o.Name, "</option>"));
                }
                else
                {
                    sb.Append(string.Concat("<option value=\"", o.Bvin.Replace("-", string.Empty), "\""));
                    if (o.Bvin.Replace("-", string.Empty) == selected || (string.IsNullOrEmpty(selected) && o.IsDefault))
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(string.Concat(">", o.Name, "</option>"));
                }
            }
            sb.Append("</select>");

            return(sb.ToString());
        }
示例#25
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            StringBuilder sb = new StringBuilder();

            foreach (OptionItem o in baseOption.Items)
            {
                sb.Append("<input type=\"radio\" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" value=\"" + o.Bvin.Replace("-", "") + "\"");
                sb.Append(" class=\"isoption radio" + baseOption.Bvin.Replace("-", "") + "\" ");
                if (IsSelected(o, selections))
                {
                    sb.Append(" checked=\"checked\" ");
                }
                sb.Append("/>" + o.Name + "<br />");
            }
            return(sb.ToString());
        }
        public UserSpecificPrice(Product initialProduct, OptionSelectionList selections)
        {
            if (initialProduct == null) throw new ArgumentNullException("Initial Product can not be null");

            // init
            this.IsValid = true;
            this.DiscountDetails = new List<Marketing.DiscountDetail>();
            this.VariantId = string.Empty;

            // Load from Product
            this.ListPrice = initialProduct.ListPrice;
            this.Sku = initialProduct.Sku;
            this.BasePrice = initialProduct.SitePrice;
            this.OverrideText = initialProduct.SitePriceOverrideText;

            PriceForSelections(initialProduct, selections);
        }
示例#27
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections, string prefix = null)
        {
            string selected = null;

            if (selections != null)
            {
                var sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            var sb = new StringBuilder();

            sb.Append("<select id=\"opt" + prefix + baseOption.Bvin.Replace("-", string.Empty) + "\" ");
            sb.Append(" name=\"opt" + prefix + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" class=\"hcIsOption\" >");

            foreach (var o in baseOption.Items)
            {
                if (o.IsLabel)
                {
                    sb.Append("<option value=\"\" disabled");
                    //sb.Append("<option value=\"systemlabel\" disabled");

                    if (string.IsNullOrEmpty(selected) && o.IsDefault)
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(">" + o.Name + "</option>");
                }
                else
                {
                    sb.Append("<option value=\"" + o.Bvin.Replace("-", string.Empty) + "\"");
                    if (o.Bvin.Replace("-", string.Empty) == selected || (string.IsNullOrEmpty(selected) && o.IsDefault))
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(">" + o.Name + "</option>");
                }
            }
            sb.Append("</select>");

            return(sb.ToString());
        }
示例#28
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            string selected = string.Empty;

            if (selections != null)
            {
                OptionSelection sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            StringBuilder sb = new StringBuilder();
            string        c  = this.GetColumns(baseOption);

            if (c == "")
            {
                c = "20";
            }
            string r = this.GetRows(baseOption);

            if (r == "")
            {
                r = "1";
            }

            if (r != "1")
            {
                sb.Append("<textarea id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" cols=\"" + c + "\" rows=\"" + r + "\" ");
                sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
                sb.Append(">");
                sb.Append(selected);
                sb.Append("</textarea>");
            }
            else
            {
                sb.Append("<input type=\"text\" id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" cols=\"" + c + "\" maxlength=\"" + this.GetMaxLength(baseOption) + "\"");
                sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
                sb.Append(" value=\"" + selected + "\"");
                sb.Append("/>");
            }

            return(sb.ToString());
        }
示例#29
0
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            bool result = false;
            if (selections == null) return false;

            OptionSelection val = selections.FindByOptionId(item.OptionBvin);
            if (val == null) return result;

            string[] vals = val.SelectionData.Split(',');
            foreach (string s in vals)
            {
                if (s == item.Bvin.Replace("-", ""))
                {
                    return true;
                }                
            }                       
            return result;
        }
示例#30
0
        public string CartDescription(Option baseOption, OptionSelectionList selections)
        {
            if (selections == null)
            {
                return(string.Empty);
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(string.Empty);
            }

            if (val.SelectionData.Trim().Length > 0)
            {
                return(string.Concat(baseOption.Name, ": ", HttpUtility.HtmlEncode(val.SelectionData)));
            }

            return(string.Empty);
        }
        private bool SelectionDataMatches(OptionSelectionList variantSelections, List<VariantOptionDataDTO> options)
        {
            if (variantSelections.Count != options.Count)
            {
                return false;
            }

            int expectedMatched = options.Count;
            int actualMatches = 0;
            foreach (var opt in options)
            {
                var match = variantSelections.Where(y => y.OptionBvin.Replace("-", "").ToLowerInvariant() == opt.ChoiceId.Replace("-", "").ToLowerInvariant()
                    && y.SelectionData.Replace("-", "").ToLowerInvariant() == opt.ChoiceItemId.Replace("-", "").ToLowerInvariant()).FirstOrDefault();
                if (match != null)
                {
                    actualMatches++;
                }
            }

            return actualMatches == expectedMatched;            
        }
示例#32
0
        private OptionSelectionList ParseSelections(Product p)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in p.Options)
            {
                // No need to parse HTML or Input Fields as they do not affect the ajax
                // updates on products
                if (opt.OptionType == OptionTypes.Html ||
                    opt.OptionType == OptionTypes.TextInput ||
                    opt.OptionType == OptionTypes.FileUpload)
                {
                    continue;
                }

                string strippeddata = Request.Form["opt" + opt.Bvin.Replace("-", "")];
                // stuff value into a guid to restore dashes which are invalid for
                // asp.net control ids
                if (strippeddata == "" || strippeddata == "undefined" || strippeddata == null)
                {
                    continue;
                }
                else
                {
                    System.Guid g = System.Guid.NewGuid();

                    if (System.Guid.TryParse(strippeddata, out g))
                    {
                        result.Add(new OptionSelection(opt.Bvin, g.ToString()));
                    }
                    else
                    {
                        result.Add(new OptionSelection(opt.Bvin, strippeddata));
                    }
                }
            }

            return(result);
        }
示例#33
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            string selected = string.Empty;

            if (selections != null)
            {
                OptionSelection sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("<select id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" class=\"isoption\" >");

            foreach (OptionItem o in baseOption.Items)
            {
                if (o.IsLabel)
                {
                    sb.Append("<option value=\"systemlabel\">" + o.Name + "</option>");
                }
                else
                {
                    sb.Append("<option value=\"" + o.Bvin.Replace("-", "") + "\"");
                    if (o.Bvin.Replace("-", "") == selected)
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(">" + o.Name + "</option>");
                }
            }
            sb.Append("</select>");

            return(sb.ToString());
        }
示例#34
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            string selected = string.Empty;
            if (selections != null)
            {
                OptionSelection sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("<select id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" class=\"isoption\" >");

            foreach (OptionItem o in baseOption.Items)
            {
                if (o.IsLabel)
                {
                    sb.Append("<option value=\"systemlabel\">" + o.Name + "</option>");
                }
                else
                {
                    sb.Append("<option value=\"" + o.Bvin.Replace("-", "") + "\"");
                    if (o.Bvin.Replace("-","") == selected)
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(">" + o.Name + "</option>");
                }
            }
            sb.Append("</select>");

            return sb.ToString();
        }
示例#35
0
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            bool result = false;

            if (selections == null)
            {
                return(false);
            }

            OptionSelection val = selections.FindByOptionId(item.OptionBvin);

            if (val == null)
            {
                return(result);
            }

            if (val.SelectionData == item.Bvin.Replace("-", ""))
            {
                return(true);
            }

            return(result);
        }
示例#36
0
        public void SetSelectionsInPlaceholder(Option baseOption, PlaceHolder ph, OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            var tb = (TextBox)ph.FindControl(string.Concat("opt", baseOption.Bvin.Replace("-", string.Empty)));

            if (tb != null)
            {
                tb.Text = val.SelectionData;
            }
        }
示例#37
0
        public string CartDescription(Option baseOption, OptionSelectionList selections)
        {
            if (selections == null)
            {
                return(string.Empty);
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(string.Empty);
            }

            foreach (var oi in baseOption.Items)
            {
                var cleaned = OptionSelection.CleanBvin(oi.Bvin);
                if (cleaned == val.SelectionData)
                {
                    return(baseOption.Name + ": " + oi.Name);
                }
            }

            return(string.Empty);
        }
示例#38
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            string selected = string.Empty;
            if (selections != null)
            {
                OptionSelection sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            StringBuilder sb = new StringBuilder();
            string c = this.GetColumns(baseOption);
            if (c == "") c = "20";
            string r = this.GetRows(baseOption);
            if (r == "") r = "1";
            
            if (r != "1")
            {
                sb.Append("<textarea id=\"opt" + baseOption.Bvin.Replace("-","") + "\" cols=\"" + c + "\" rows=\"" + r + "\" ");
                sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
                sb.Append(">");
                sb.Append(selected);
                sb.Append("</textarea>");
            }
            else
            {                
                sb.Append("<input type=\"text\" id=\"opt" + baseOption.Bvin.Replace("-","") + "\" cols=\"" + c + "\" maxlength=\"" + this.GetMaxLength(baseOption) + "\"");
                sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
                sb.Append(" value=\"" + selected + "\"");
                sb.Append("/>");
            }

            return sb.ToString();
        }
示例#39
0
        public string CartDescription(Option baseOption, OptionSelectionList selections)
        {
            if (selections == null)
            {
                return(string.Empty);
            }
            var val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(string.Empty);
            }
            var vals = val.SelectionData.Split(',');

            var result = string.Concat(baseOption.Name, ": ");
            var first  = true;

            foreach (var oi in baseOption.Items)
            {
                var cleaned = OptionSelection.CleanBvin(oi.Bvin);
                if (vals.Contains(cleaned))
                {
                    if (!first)
                    {
                        result += ", ";
                    }
                    else
                    {
                        first = false;
                    }
                    result += oi.Name;
                }
            }

            return(result);
        }
示例#40
0
        private bool ValidateSelections(Product p, OptionSelectionList selections)
        {
            bool result = false;

            if ((p.HasOptions()))
            {
                if ((p.HasVariants()))
                {
                    Variant v = p.Variants.FindBySelectionData(selections, p.Options);
                    if ((v != null))
                    {
                        result = true;
                    }
                    else
                    {
                        this.litMessage.Text = "<div class=\"flash-message-warning\">The options you've selected aren't available at the moment. Please select different options.</div>";
                    }
                }
                else
                {
                    result = true;
                }

                // Price Modifiers Here

            }
            else
            {
                result = true;
            }

            return result;
        }
        public UserSpecificPrice PriceProduct(Catalog.Product p, Membership.CustomerAccount currentUser, OptionSelectionList selections)
        {
            if (p == null) return null;
            UserSpecificPrice result = new UserSpecificPrice(p, selections);
            AdjustProductPriceForUser(result, p, currentUser);
            ApplySales(result, p, currentUser);
            CheckForPricesBelowZero(result);

            return result;
        }
示例#42
0
 public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
 {
     return Render(baseOption);
 }
示例#43
0
        // Loop through all possible variants and generate selection data
        private void GenerateVariantSelections(List<OptionSelectionList> data,
                                                List<Option> options,
                                                int optionIndex,
                                                OptionSelectionList tempSelections)
        {
            if (optionIndex > (options.Count - 1))
            {
                // we've hit all options so add the selections to the data
                OptionSelectionList temp = new OptionSelectionList();
                temp.AddRange(tempSelections);
                //tempSelections.RemoveAt(tempSelections.Count() - 1);
                //tempSelections.Clear();
                data.Add(temp);

            }
            else
            {
                Option opt = options[optionIndex];
                foreach (OptionItem oi in opt.Items)
                {
                    if (oi.IsLabel == false)
                    {
                        OptionSelectionList localList = new OptionSelectionList();
                        localList.AddRange(tempSelections);
                        localList.Add(new OptionSelection(opt.Bvin, oi.Bvin));
                        GenerateVariantSelections(data, options, optionIndex + 1, localList);
                    }
                }

            }
        }
示例#44
0
        private void AddProductBySku()
        {
            this.MessageBox1.ClearMessage();
            this.pnlProductChoices.Visible = false;

            Order o = MTApp.OrderServices.Orders.FindForCurrentStore(this.BvinField.Value);

            if (this.NewSkuField.Text.Trim().Length < 1)
            {
                this.MessageBox1.ShowWarning("Please enter a sku first.");
            }
            else
            {
                Product p = MTApp.CatalogServices.Products.FindBySku(this.NewSkuField.Text.Trim());

                if (p != null && p.Sku.Length > 0)
                {
                    if (p.HasOptions())
                    {
                        this.pnlAddControls.Visible = false;
                        this.pnlProductChoices.Visible = true;
                        this.AddProductSkuHiddenField.Value = p.Bvin;

                        // Render Options
                        this.phChoices.Controls.Clear();
                        this.phChoices.Controls.Add(new System.Web.UI.LiteralControl("<div id=\"options\">"));
                        MerchantTribe.Commerce.Utilities.HtmlRendering.ProductOptionsAsControls(p.Options, phChoices);
                        this.phChoices.Controls.Add(new System.Web.UI.LiteralControl("<div class=\"clear\"></div></div>"));
                        this.litProductInfo.Text = p.Sku + " | " + p.ProductName;
                    }
                    else
                    {
                        
                        if (o != null)
                        {
                            int quantity = 1;
                            int.TryParse(this.NewProductQuantity.Text, out quantity);
                            OptionSelectionList selections = new OptionSelectionList();
                            LineItem li = MTApp.CatalogServices.ConvertProductToLineItem(p,
                                                                                    selections,
                                                                                    quantity,
                                                                                    MTApp);
                            o.Items.Add(li);
                            MTApp.OrderServices.Orders.Update(o);
                            this.MessageBox1.ShowOk("Product Added!");
                        }
                    }
                }
                else
                {
                    this.MessageBox1.ShowInformation("That SKU could not be located. Please try again.");
                }
            }
            MTApp.OrderServices.Orders.Update(o);
            LoadOrder(o.bvin);
        }
示例#45
0
 public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("<div class=\"radioSet\">");
     foreach (OptionItem o in baseOption.Items)
     {
         sb.Append("<input id=\"" + baseOption.Name + "-" + o.Name + "\" type=\"radio\" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" value=\"" + o.Bvin.Replace("-", "") + "\"");
         sb.Append(" class=\"isoption radio" + baseOption.Bvin.Replace("-", "") + "\" ");
         if (IsSelected(o, selections))
         {
             sb.Append(" checked=\"checked\" ");
         }
         sb.Append("/>");
         if (!String.Equals(baseOption.Name, "Size", StringComparison.InvariantCultureIgnoreCase))
             sb.Append(o.Name);
         else
             sb.Append("<label for=\"" + baseOption.Name + "-" + o.Name + "\">" + o.Name + "</label>");
     }
     sb.Append("</div>");
     return sb.ToString();
 }
        public UserSpecificPrice PriceProduct(Catalog.Product p, Membership.CustomerAccount currentUser, OptionSelectionList selections, List<Marketing.Promotion> currentSales)
        {
            var profiler = MiniProfiler.Current;

            if (p == null) return null;
            UserSpecificPrice result = new UserSpecificPrice(p, selections);
            using (profiler.Step("Adjust Price for User"))
            {
                AdjustProductPriceForUser(result, p, currentUser);
            }
            using (profiler.Step("Apply Sales"))
            {
                ApplySales(result, p, currentUser, currentSales);
            }
            using (profiler.Step("Check for < 0 prices"))
            {
                CheckForPricesBelowZero(result);
            }

            return result;
        }
示例#47
0
        private OptionSelectionList ParseSelections(Product p)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in p.Options)
            {
                OptionSelection selected = opt.ParseFromPlaceholder(this.phChoices);
                if (selected != null)
                {
                    result.Add(selected);
                }
            }

            return result;
        }
示例#48
0
 public string RenderWithSelection(OptionSelectionList selections)
 {
     return this.Processor.RenderWithSelection(this, selections);
 }
示例#49
0
        // Products and Line Items
        public Orders.LineItem ConvertProductToLineItem(Orders.IPurchasable p, OptionSelectionList selections, int quantity, MerchantTribeApplication app)
        {
            Orders.LineItem li = new Orders.LineItem();
            
            if (p != null)
            {
                Orders.PurchasableSnapshot snapshot = p.AsPurchasable(selections, app, true);
                if (snapshot != null)
                {
                    li.BasePricePerItem = snapshot.BasePrice;
                    li.ProductId = snapshot.ProductId;
                    li.ProductName = snapshot.Name;
                    li.ProductShippingHeight = snapshot.ShippingDetails.Height;
                    li.ProductShippingLength = snapshot.ShippingDetails.Length;
                    li.ProductShippingWeight = snapshot.ShippingDetails.Weight;
                    li.ProductShippingWidth = snapshot.ShippingDetails.Width;
                    li.ProductShortDescription = snapshot.Description;
                    li.ProductSku = snapshot.Sku;
                    li.Quantity = quantity;
                    li.SelectionData = snapshot.SelectionData;
                    li.ShippingSchedule = snapshot.ShippingDetails.ShippingScheduleId;
                    li.VariantId = snapshot.VariantId;
                    li.TaxSchedule = snapshot.TaxScheduleId;
                    li.ShipFromAddress = snapshot.ShippingDetails.ShippingSourceAddress;
                    li.ShipFromMode = snapshot.ShippingDetails.ShippingSource;
                    li.ShipFromNotificationId = snapshot.ShippingDetails.ShippingSourceId;
                    li.ShipSeparately = snapshot.ShippingDetails.ShipSeparately;
                    li.ExtraShipCharge = snapshot.ShippingDetails.ExtraShipFee;
                }
            }

            return li;
        }
        private void ParseSelections(ProductPageViewModel model)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in model.LocalProduct.Options)
            {
                OptionSelection selected = opt.ParseFromForm(Request.Form);
                if (selected != null)
                {
                    result.Add(selected);
                }
            }

            model.Selections = result;
        }
示例#51
0
        public List<OptionSelectionList> VariantsGenerateAllPossibleSelections(OptionList options)
        {
            List<OptionSelectionList> data = new List<OptionSelectionList>();

            List<Option> variantOptions = options.VariantsOnly();
            if (variantOptions == null) return data;
            if (variantOptions.Count < 1) return data;

            OptionSelectionList selections = new OptionSelectionList();
            GenerateVariantSelections(data, variantOptions, 0, selections);

            return data;
        }
        private OptionSelectionList ParseSelections(Product p)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in p.Options)
            {

                // No need to parse HTML or Input Fields as they do not affect the ajax
                // updates on products
                if (opt.OptionType == OptionTypes.Html ||
                    opt.OptionType == OptionTypes.TextInput ||
                    opt.OptionType == OptionTypes.FileUpload)
                {
                    continue;
                }

                string strippeddata = Request.Form["opt" + opt.Bvin.Replace("-", "")];
                // stuff value into a guid to restore dashes which are invalid for
                // asp.net control ids
                if (strippeddata == "" || strippeddata == "undefined" || strippeddata == null)
                {
                    continue;
                }
                else
                {
                    System.Guid g = System.Guid.NewGuid();

                    if (System.Guid.TryParse(strippeddata, out g))
                    {
                        result.Add(new OptionSelection(opt.Bvin, g.ToString()));
                    }
                    else
                    {
                        result.Add(new OptionSelection(opt.Bvin, strippeddata));
                    }
                }
            }

            return result;
        }
示例#53
0
 public bool SaveProductToWishList(Orders.IPurchasable p, OptionSelectionList selections, int quantity, MerchantTribeApplication app)
 {
     WishListItem wi = new WishListItem();            
     if (p != null)
     {
         Orders.PurchasableSnapshot snapshot = p.AsPurchasable(selections, app, true);
         if (snapshot != null)
         {                    
             wi.ProductId = snapshot.ProductId;
             wi.Quantity = quantity;
             wi.SelectionData = snapshot.SelectionData;
             wi.CustomerId = app.CurrentCustomerId; 
         }
     }
     return WishListItems.Create(wi);
 }
 // Product Pricing
 public UserSpecificPrice PriceProduct(string productBvin, string userId, OptionSelectionList selections)
 {
     Product p = CatalogServices.Products.FindWithCache(productBvin);
     Membership.CustomerAccount customer = MembershipServices.Customers.Find(userId);            
     return PriceProduct(p, customer, selections, this.CurrentlyActiveSales);
 }