Obtaining the name of the order item which is parent..

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Obtaining the name of the order item which is parent..

Post by jmestep » Tue Nov 25, 2008 5:05 pm

I need to be able to take an orderitem input field and display the name of the parent orderitem for that. I know there has to be a way I can do this, like you can show the parent category for a product. I'm just not seeing it.
Can anyone help?
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: Obtaining the name of the order item which is parent..

Post by nickc » Tue Nov 25, 2008 6:40 pm

Code: Select all

        OrderItemInputCollection inputs = OrderItemInputDataSource.LoadForOrderItem(orderId);
        foreach (OrderItemInput input in inputs)
        {
            Response.Write(input.OrderItem.Name, input.Name, input.InputValue);
        }

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Obtaining the name of the order item which is parent..

Post by jmestep » Wed Nov 26, 2008 7:21 am

Thank you, Nick. I thought I was going to have to go with a custom query and you saved me from doing that.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Obtaining the name of the order item which is parent..

Post by jmestep » Wed Nov 26, 2008 8:22 am

I'm still stumped, I should have given more details earlier. I worked with the above and I'm still having problems.
I'm trying to populate a DropDownList with the DataTextField for each selection being the input name concatenated with the parent order item name and the DataKey field being OrderItemInputId.
I was able to get the dropdown populated when I used the following on an order that had only one item, but I want the dropdown to include all the items in the order that have inputs grouped into one ddl.
Here is my current code. The object is for the customer to select a print location of something like the front of a business card, then upload an image file is to be used at that location. The file is then saved with the order item name and the input name as part of the file name. Like BusinessCard-Front-thisfile.jpg.
The following works for one item. I know I would need to get rid of the foreach OrderItem.

Code: Select all

protected void Page_Prerender()
    {

        //SHOW INPUTS IN DROPDOWN LIST

        foreach (OrderItem item in _Order.Items)
        {

            if (item.Inputs.Count > 0)
            {
               
                DropDownListTemplateFields.DataSource = item.Inputs;
                DropDownListTemplateFields.DataBind();
                DropDownListTemplateFields.DataTextField = "Name";
                DropDownListTemplateFields.Items.Insert(0, " - Select Print Location From List - ");
                DropDownListTemplateFields.Items.Add("One File for all Print locations");
                DropDownListTemplateFields.Items.Add("Sound File(s)");

            }
        }
    }
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Obtaining the name of the order item which is parent..

Post by mazhar » Wed Nov 26, 2008 11:02 am

Judy use the following code

Code: Select all

 OrderItemInputCollection orderItemInputs = new OrderItemInputCollection();
        foreach (OrderItem item in _Order.Items)
        {

            if (item.Inputs.Count > 0)
                orderItemInputs.AddRange(item.Inputs);
        }

        DropDownListTemplateFields.DataTextField = "Name";
        DropDownListTemplateFields.DataValueField = "InputValue";

        DropDownListTemplateFields.DataSource = orderItemInputs;
        DropDownListTemplateFields.DataBind();
        
        DropDownListTemplateFields.Items.Insert(0, " - Select Print Location From List - ");
        DropDownListTemplateFields.Items.Add("One File for all Print locations");
        DropDownListTemplateFields.Items.Add("Sound File(s)");

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Obtaining the name of the order item which is parent..

Post by jmestep » Wed Nov 26, 2008 3:40 pm

Thank you mazhar, that puts me a step closer. Now I need to concatenate the orderitem name and the input name.
Do you have a quick fix for that? (I haven't tried yet)
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Obtaining the name of the order item which is parent..

Post by mazhar » Thu Nov 27, 2008 5:32 am

For concatenation it could be something like

Code: Select all

OrderItemInputCollection orderItemInputs = new OrderItemInputCollection();
        foreach (OrderItem item in _Order.Items)
        {
            foreach (OrderItemInput orderItemInput in item.Inputs)
            {
                OrderItemInput aOrderItemInput = new OrderItemInput();
                aOrderItemInput.Name = string.Format("{0}({1})", item.Name, orderItemInput.Name);
                aOrderItemInput.InputValue = orderItemInput.InputValue;
                orderItemInputs.Add(aOrderItemInput);
            }
        }

        DropDownListTemplateFields.DataTextField = "Name";
        DropDownListTemplateFields.DataValueField = "InputValue";

        DropDownListTemplateFields.DataSource = orderItemInputs;
        DropDownListTemplateFields.DataBind();
        
        DropDownListTemplateFields.Items.Insert(0, " - Select Print Location From List - ");
        DropDownListTemplateFields.Items.Add("One File for all Print locations");
        DropDownListTemplateFields.Items.Add("Sound File(s)");

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Obtaining the name of the order item which is parent..

Post by jmestep » Thu Nov 27, 2008 8:23 am

Thank you again. It will be good to get over this hump and on to other things.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply