Hi Don,
The problem occurs because you have more than on textbox with the same id. I solved this by adding the product id. Now, I'm at my office and I do not have my pc. In some hours (~5), I will edit this post with sample code.
Gilles
Edit: Here my solution.
Open the file ProductDetail.ascx.resx and add this resource:
Name: Quantity.Text
Value: Quantity:
Open ProductDetail.ascx.cs then inside processToken add this code:
case "ADDQUANTITY:
Label lblQuantity = new Label();
LiteralControl litQuantity = new LiteralControl(Localization.GetString("Quantity", this.LocalResourceFile)); // Here we use the resource, more simple for modify and translate
TextBox txtAddToCartQty = new TextBox();
txtAddToCartQty.ID = "txtQuantity" + productInfo.ProductID.ToString(); // Here is the key! ;-)
txtAddToCartQty.CssClass = "Store-QuantityTextBox"; // It's better to use a cssclass instead the Width property, because you can change it without rebuild
txtAddToCartQty.Text = "1";
lblQuantity.Controls.Add(litQuantity);
lblQuantity.Controls.Add(txtAddToCartQty);
return lblQuantity;
Replace Puchase by:
private void Purchase(int productID, int quantity)
{
CurrentCart.AddItem(PortalId, productID, quantity);
CartNavigation cartnav = new CartNavigation();
StoreController storeController = new StoreController();
StoreInfo storeInfo = storeController.GetStoreInfo(PortalId);
cartnav.TabId = storeInfo.ShoppingCartPageID;
Response.Redirect(cartnav.GetNavigationUrl(), false);
}
Add this procedure:
private int GetQuantity(string quantityID)
{
int quantity = 1;
TextBox txtQuantity = (TextBox)this.FindControl(quantityID);
if (txtQuantity != null)
{
if (!int.TryParse(txtQuantity.Text, out quantity)) quantity = 1;
}
return quantity;
}
Inside btnPurchase_Click and btnPurchaseImg_Click replace the call to Purchase by
Purchase(int.Parse(button.Attributes["ProductID"]), GetQuantity(("txtQuantity" + button.Attributes["ProductID"])));
Replace AddToCart by:
private void AddToCart(int productID, int quantity)
{
CurrentCart.AddItem(PortalId, productID, quantity);
Response.Redirect(catalogNav.GetNavigationUrl(), false);
}
Inside btnAddToCart_Click and btnAddToCartImg_Click replace the call to AddItem by:
CurrentCart.AddItem(PortalId, productID, quantity);
Rebuild the solution. It's work!
Open the file ...\DesktopModules\Store\Templates\StyleSheet\Common.css and add:
.Store-QuantityTextBox { width: 30px }
Gilles