Quantity in packing slip

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Quantity in packing slip

Post by William_firefold » Thu Oct 02, 2008 2:24 pm

Sorry for all the posts today, but I have one more for the day.
We want a item count label on our packing slip(admin/print/packslips.aspx) and I have been unable to make one from the orderShipment field that the packing slips use.
Could I get some code that will count the items in each order and put the number into a label?

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Quantity in packing slip

Post by William_firefold » Thu Oct 02, 2008 2:46 pm

May have solved my own problem but if you can(or want to) write better code, Ill use it.
I just cloned the getproducts method and added my counter variable:

Code: Select all

    protected OrderItemCollection GetProducts2(object dataItem)
    {
		itemCount=0;
        OrderShipment shipment = (OrderShipment)dataItem;
        Order order = shipment.Order;
        OrderItemCollection products = new OrderItemCollection();
        foreach (OrderItem item in order.Items)
        {
            if ((item.OrderItemType == OrderItemType.Product) && (item.OrderShipmentId == shipment.OrderShipmentId))
            {
				
                products.Add(item);
itemCount+=item.Quantity;
				
            }
        }
        products.Sort(new OrderItemComparer());		
        return products;
    }
Then I can use the method like so without worrying about what its counting and when.

Code: Select all

<asp:Label ID="qtylabel" runat="server" Text="Total QTY Shipped:"></asp:Label>    
<asp:Label ID="Qty" DataSource='<%#GetProducts2(Container.DataItem)%>' runat="server" Text='<%#(itemCount)%>'></asp:Label>

Post Reply