Coupons 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

Coupons in Packing Slip

Post by William_firefold » Thu Oct 30, 2008 3:14 pm

How would I go about putting any coupon codes used into the packing slip.

The format i am using is a label:

Code: Select all

<asp:Label ID="CouponCode" runat="server" Text='<%#((OrderShipment)Container.DataItem).Order.Coupons%>'  Font-Size="18px"></asp:Label>
Im stuck there though. Id appreciate any help.

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

Re: Coupons in Packing Slip

Post by mazhar » Fri Oct 31, 2008 12:45 am

You can use the following code to get all the coupons with the order.

Code: Select all

private OrderItemCollection GetCoupons(Object dataItem)
    {
        OrderShipment shipment = (OrderShipment)dataItem;
        Order order = shipment.Order;
        OrderItemCollection coupons = new OrderItemCollection();
        foreach (OrderItem item in order.Items)
        {
            if (item.OrderItemType == OrderItemType.Coupon)
            {
                coupons.Add(item);
            }
        }
        coupons.Sort(new OrderItemComparer());
        return coupons;
    }

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

Re: Coupons in Packing Slip

Post by William_firefold » Fri Oct 31, 2008 8:00 am

This was very helpful, but not quite what I needed. I modified your code to return a string instead. Here it is:

Code: Select all

	private String GetCoupons(Object dataItem)
    {
        OrderShipment shipment = (OrderShipment)dataItem;
        Order order = shipment.Order;
        String coupons = "";
        foreach (OrderItem item in order.Items)
        {
            if (item.OrderItemType == OrderItemType.Coupon)
            {
                coupons+= (item).Name +"<br />";
            }
        }        
        return coupons;
    }
This is how I Called it:

Code: Select all

                <asp:Label ID="CouponLabel" runat="server" Text="Coupon:" SkinID="fieldheader" Visible='<%# (GetCoupons(Container.DataItem)!="") %>'></asp:Label>
                <asp:Label ID="CouponCode" runat="server" Text='<%# GetCoupons(Container.DataItem)%>'  Font-Size="18px"></asp:Label>      

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

Re: Coupons in Packing Slip

Post by mazhar » Fri Oct 31, 2008 8:04 am

That's great. I just tried to provide you an idea that how to get coupon information.

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Coupons in Packing Slip

Post by bobr2k » Fri Oct 31, 2008 8:26 am

I think it's great that you each "chipped in" -- a great help to those of us who are less talented in this field.
Thanks!
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

Post Reply