Price in Kit Items Dropdown

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
boycec
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Tue Aug 12, 2008 4:54 pm

Price in Kit Items Dropdown

Post by boycec » Tue Aug 19, 2008 10:40 pm

Is there a way to make the dropdown for a kit item not show the ($0.00)?

This was asked a while back in this thread: viewtopic.php?f=44&t=5969&p=24032&hilit ... ice#p24032

I have searched but I haven't found the answer

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Price in Kit Items Dropdown

Post by AbleMods » Sun Aug 24, 2008 11:24 pm

This revision is for AC7 Final. It will work on all the multi-select controls of a kit.

Edit your ~/App_Code/ProductHelper.cs file. Find the BuildKitOptions function and replace just that function with this code:

Code: Select all

    public static List<int> BuildKitOptions(Product product, PlaceHolder phOptions)
    {
        List<int> selectedChoices = new List<int>();
        foreach (ProductKitComponent pkc in product.ProductKitComponents)
        {
            KitComponent component = pkc.KitComponent;
            if (component.InputType != KitInputType.IncludedHidden && component.KitProducts.Count > 0)
            {
                // CREATE A LABEL FOR THE ATTRIBUTE
                phOptions.Controls.Add(new LiteralControl("<tr><th class=\"rowHeader\">" + component.Name + ":</th>"));
                // ADD THE CONTROL TO THE PLACEHOLDER
                phOptions.Controls.Add(new LiteralControl("<td align=\"left\">"));
                WebControl o = component.GetControl();
                if (o != null)
                {
                    Type oType = o.GetType();
                    if (oType.Equals(typeof(RadioButtonList)))
                    {
                        ((RadioButtonList)o).AutoPostBack = true;
                        for (int i = 0; i < ((RadioButtonList)o).Items.Count; i++)
                        {
                            ((RadioButtonList)o).Items[i].Text = ((RadioButtonList)o).Items[i].Text.Replace(" - ($0.00)", "");
                        }
                    }
                    else if (oType.Equals(typeof(DropDownList)))
                    {
                        ((DropDownList)o).AutoPostBack = true;
                        for (int i = 0; i < ((DropDownList)o).Items.Count; i++)
                        {
                            ((DropDownList)o).Items[i].Text = ((DropDownList)o).Items[i].Text.Replace(" - ($0.00)", "");
                        }
                    }
                    else if (oType.Equals(typeof(CheckBoxList)))
                    {
                        ((CheckBoxList)o).AutoPostBack = true;
                        for (int i = 0; i < ((CheckBoxList)o).Items.Count; i++)
                        {
                            ((CheckBoxList)o).Items[i].Text = ((CheckBoxList)o).Items[i].Text.Replace(" - ($0.00)", "");
                        }
                    }
                    phOptions.Controls.Add(o);
                    // SEE WHETHER A VALID VALUE FOR THIS FIELD IS PRESENT IN FORM POST
                    List<int> theseOptions = component.GetControlValue(o);
                    selectedChoices.AddRange(theseOptions);
                }
                phOptions.Controls.Add(new LiteralControl("</td></tr>"));
            }
        }
        return selectedChoices;
    }
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

boycec
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Tue Aug 12, 2008 4:54 pm

Re: Price in Kit Items Dropdown

Post by boycec » Mon Aug 25, 2008 9:24 pm

That makes sense, I will give it a try.

Thanks

Post Reply