Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsStoreStoreProduct increment/decrement by more than 1 itemProduct increment/decrement by more than 1 item
Previous
 
Next
New Post
11/17/2008 4:16 AM
 
It's very frustrating clicking 50 times to order 50 items of a product. Is there a solution to this problem? Thank you.
 
New Post
12/4/2008 7:00 AM
 

The following code allows to update item quantity straight to a desired number, by adding a textbox to the last column of the cart. LinkButton lnkAdd is used to confirm quantity.

So far this functionality is not apllied to mini-cart .

In CartDeatail.ascx in the last itemtemplate tag add:

<asp:textbox id="txtQuantity" runat="server" width="30" MaxLength="4" cssclass="NormalTextBox"></asp:textbox>

In CartDeatail.ascx.cs:

Change "if(lnkAdd != null){...}" to:

                if (lnkAdd != null)
                {
                    TextBox txtQuantity = (TextBox)e.Item.FindControl("txtQuantity");
                    if (txtQuantity != null)
                    {
                        txtQuantity.TextChanged += new EventHandler(OnQtyChanged);
                        txtQuantity.Attributes.Add("OnKeyDown", " if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + lnkAdd.ClientID + "').Click;" + Page.GetPostBackEventReference(lnkAdd, string.Empty) + ";return false;}} else {return true}; ");                       
                    }
                    // Traduction effectuйe
                    lnkAdd.Attributes.Add("title", Localization.GetString("AddAnother", this.LocalResourceFile) + " " + itemInfo.ProductTitle + " " + Localization.GetString("ToTheCart", this.LocalResourceFile));
                    lnkAdd.CommandName = itemInfo.ItemID.ToString();
                    lnkAdd.CommandArgument = itemInfo.Quantity.ToString();
                    lnkAdd.Command += new CommandEventHandler(btnAdd_Click);
                    lnkAdd.CausesValidation = false;                    
                }

Add event handler:

        private void OnQtyChanged(object sender, EventArgs e)
        {
            ((TextBox)(grdItems.Items[0].FindControl("txtQuantity"))).Text = ((TextBox)sender).Text;
        }

Change btnAdd_Click() to:

        private void btnAdd_Click(object sender, CommandEventArgs e)
        {
            int itemID = int.Parse(e.CommandName);
            int quantity;

            try
            {
                quantity = int.Parse(((TextBox)(grdItems.Items[0].FindControl("txtQuantity"))).Text);
                if (quantity == 0)
                {
                    CurrentCart.RemoveItem(itemID);
                }
                else if (quantity < 0)
                {
                    CurrentCart.UpdateItem(PortalId, itemID, -(quantity));
                }
                else
                {
                    CurrentCart.UpdateItem(PortalId, itemID, quantity);
                }

                updateCartGrid();
                this.invokeEditComplete();

            }
            catch(Exception ex) //does nothing, if quantity is not a positive integer
            {
                updateCartGrid();
                this.invokeEditComplete();
            }           
        }

 

 
New Post
12/4/2008 1:48 PM
 

Hi Pavel,

I tried to add this code.
I do not see a button/link to click tot confirm the quatity.

Can I get these both files from you so I can try this?

With regards, Ton Hermes


Art is hard work, inspiration is the cream on top of it. See my watercolors at www.watermansite.com and my enamel art at www.watermanshop.com
 
New Post
12/4/2008 10:52 PM
 

I forgot to mention it doesn't work with mini-cart. Though MiniCart.ascx and MiniCart.ascx.cs seem almost identical to CartDetail code, so I guess it would be simple to figure out how to paste the code into it.

Ton Hermes wrote

I do not see a button/link to click tot confirm the quatity.

The already existing "+" sign link button or pressing enter key confirms it. In localization settings (Local Resources > DesktopModules > Store > CartDetail.ascx > lnkAdd.Text) it can be renamed to "Ok" or whatever. Since there is no need for "-" sign link button, it can be commented out.

If no success, give me your email - I'll send you the source.

 
New Post
12/5/2008 2:35 AM
 

Hi Pavel,

I implemented the code.
pressing the + sign or enter does not increment the amount given in the box.
It does only clear the box.
Can you send the code to info add watermansite.com
Then I can compare what I have done wrong
Thanks

With regards, Ton Hermes


Art is hard work, inspiration is the cream on top of it. See my watercolors at www.watermansite.com and my enamel art at www.watermanshop.com
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsStoreStoreProduct increment/decrement by more than 1 itemProduct increment/decrement by more than 1 item


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out