Add a Make Offer Button and price textbox

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 лет назад
I want to add a button to the product page that allows the customer to make an offer on an item. The Customer Enters price selection is not suitable because I do not want the customer to see what the price range is. I would like to be able to let the program decide if the price that is entered by the customer is acceptable without showing the customer the price range. I would then like to display the price that the customer entered and allow the customer to click the Add To Cart button if the price is acceptable to the system.

Can someone lead me to the correct modules to make the necessary changes?
13 лет назад
Hey guys,

I'm trying to modify nopCommerce so that the customer can make an offer on a product without the minimumCustomerEnteredPrice and the maximumCustomerEnteredPrice being visible to the customer. In the ProductBox1.ascs.cs code, I added in a command button to handle the offer along with a numerictextbox control for the input. In the code, I have the follow code to handle the Make Offer button click;


        protected void btnMakeOffer_Click(object sender, CommandEventArgs e)
        {
            int productId = Convert.ToInt32(e.CommandArgument);
            var product = ProductManager.GetProductById(productId);
            int productVariantId = 0;
            var productVariantCollection = product.ProductVariants;
            var productVariant = productVariantCollection[0]; //Get the product variant
            decimal CustomerOffer = txtMakeAnOffer.Value;
            decimal CurrentPrice = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
            decimal Discount = 0.10m;
            //string attributes = "";// productVariantAttributes;
            decimal customerEnteredPriceConverted = CurrencyManager.ConvertCurrency(CustomerOffer, NopContext.Current.WorkingCurrency, CurrencyManager.PrimaryStoreCurrency);
            if (CustomerOffer < CurrentPrice - (CurrentPrice * Discount))
            {
                lblOfferWarning.Visible = true;
                lblOfferWarning.Text = "Offer too low, enter a higher amount!";
            }
            else
            {
                lblOfferWarning.Visible = false;
                if (ProductManager.DirectAddToCartAllowed(productId, out productVariantId))
                {
                    string sep = "<br />";
                    List<string> addToCartWarnings = ShoppingCartManager.AddToCart(
                        ShoppingCartTypeEnum.ShoppingCart,
                        productVariantId,
                        string.Empty,
                        customerEnteredPriceConverted,
                        1);
                    if (addToCartWarnings.Count == 0)
                    {
                        Response.Redirect("~/shoppingcart.aspx");
                    }
                    else
                    {
                        StringBuilder addToCartWarningsSb = new StringBuilder();
                        for (int i = 0; i < addToCartWarnings.Count; i++)
                        {
                            addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i]));
                            if (i != addToCartWarnings.Count - 1)
                            {
                                addToCartWarningsSb.Append(sep);
                            }
                        }
                        string errorFull = addToCartWarningsSb.ToString();
                        lblOfferWarning.Text = errorFull;
                        if (SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes"))
                        {
                            this.DisplayAlertMessage(errorFull.Replace(sep, "\\n"));
                        }
                    }
                }
            }
        }

However, no matter what value I enter into the customerEnteredPrice box, when the shopping cart comes up, it displays the original price of the product not the customer entered price. Can somebody tell me what I'm doing wrong?

Thanks.
13 лет назад
With the help of the nopCommerce team, I was able to find what I was looking for in the NumericTextBox.ascx control. I now have the program working just the way I want it to.

Thanks guys.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.