Hey,Ive added columns to my invoice do that the price, discount (or coupon), and total will load in that order one after the other. Now I need to figure our where the data for these fields is being generated. Currently each discount is loading as a new line item so I think the data is first being loaded into the orderitemdetail page, and source but I cant seem to find it.
Additionally I want to remove the details from the Items without removing the item name.
Any help is greatly appreciated. The destination code is listed below.
Thanks!
<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Invoices" Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>
<%@ Register Src="../../UserControls/OrderItemDetail.ascx" TagName="OrderItemDetail" TagPrefix="uc" %>
<script runat="server">
private List<string> orderNumbers;
protected int OrderCount = 0;
private List<int> GetSelectedOrders()
{
//CHECK FOR QUERYSTRING PARAMETERS
List<int> selectedOrders = new List<int>();
string orderIdList = Request.QueryString["orders"];
if (!string.IsNullOrEmpty(orderIdList))
{
string[] numberTokens = orderIdList.Split(",".ToCharArray());
foreach (string numberToken in numberTokens)
{
int temp = AlwaysConvert.ToInt(numberToken);
if (temp > 0) selectedOrders.Add(temp);
}
}
return selectedOrders;
}
private string GetOrderNumbers(List<int> orders)
{
if (orderNumbers == null)
{
orderNumbers = new List<string>();
foreach (int orderId in orders)
{
orderNumbers.Add(orderId.ToString());
}
}
if (orderNumbers.Count == 0) return string.Empty;
return string.Join(", ", orderNumbers.ToArray());
}
/// <summary>
/// Gets a collection of orders from a list of order ids.
/// </summary>
/// <param name="orderIds">The orderIds to load.</param>
/// <returns>A collection of orders from the list of ids.</returns>
protected OrderCollection GetOrders(params int[] orderIds)
{
OrderCollection orders = new OrderCollection();
orderNumbers = new List<string>();
foreach (int orderId in orderIds)
{
Order order = OrderDataSource.Load(orderId);
if (order != null)
{
orderNumbers.Add(order.OrderId.ToString());
orders.Add(order);
}
}
OrderCount = orders.Count;
return orders;
}
protected OrderNoteCollection GetOrderNotes(Object dataItem)
{
OrderNoteCollection orderNotes = new OrderNoteCollection();
Order order = (Order)dataItem;
if (order != null)
{
if (order.Notes != null && order.Notes.Count > 0)
{
foreach (OrderNote on in order.Notes)
if(!on.IsPrivate)
orderNotes.Add(on);
}
}
return orderNotes;
}
protected void Page_Load(object sender, EventArgs e)
{
List<int> selectedOrders = GetSelectedOrders();
if ((selectedOrders == null) || (selectedOrders.Count == 0)) Response.Redirect("~/Admin/Orders/Default.aspx");
OrderRepeater.DataSource = GetOrders(selectedOrders.ToArray());
OrderRepeater.DataBind();
OrderList.Text = GetOrderNumbers(selectedOrders);
}
protected string GetShipMethods(Object dataItem)
{
Order order = (Order)dataItem;
string shippingMethods = string.Empty;
foreach (OrderShipment orderShipment in order.Shipments)
{
shippingMethods += orderShipment.ShipMethod.Name;
shippingMethods += ",";
}
if (!String.IsNullOrEmpty(shippingMethods))
shippingMethods = shippingMethods.Remove((shippingMethods.Length - 1), 1);
return shippingMethods;
}
protected OrderItemCollection GetProducts(object dataItem)
{
Order order = (Order)dataItem;
OrderItemCollection products = new OrderItemCollection();
foreach (OrderItem item in order.Items)
{
if (item.OrderItemType == OrderItemType.Product || item.OrderItemType == OrderItemType.Coupon || item.OrderItemType == OrderItemType.Discount)
{
products.Add(item);
}
}
products.Sort(new OrderItemComparer());
return products;
}
protected string GetBillToAddress(object dataItem)
{
return ((Order)dataItem).FormatAddress(true);
}
protected string GetShipToAddress(object dataItem)
{
Order order = (Order)dataItem;
List<string> addressList = new List<string>();
foreach (OrderShipment shipment in order.Shipments)
{
string shipTo = shipment.FormatToAddress();
if (!addressList.Contains(shipTo)) addressList.Add(shipTo);
}
if (addressList.Count == 0) return "n/a";
return string.Join("<hr />", addressList.ToArray());
}
protected LSDecimal GetTotal(object dataItem, params OrderItemType[] orderItems)
{
return ((Order)dataItem).Items.TotalPrice(orderItems);
}
protected LSDecimal GetTotalPayments(object dataItem)
{
return ((Order)dataItem).Payments.Total(true);
}
protected LSDecimal GetBalance(object dataItem)
{
return GetTotal(dataItem) - GetTotalPayments(dataItem);
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<div class="pageHeader noPrint">
<div class="caption">
<h1><asp:Localize ID="Caption" runat="server" Text="Invoices"></asp:Localize></h1>
</div>
<div class="content">
<h2><asp:Localize ID="OrderListLabel" runat="server" Text="Includes Order Numbers:"></asp:Localize></h2>
<asp:Label ID="OrderList" runat="server" Text=""></asp:Label><br />
<p><asp:Localize ID="PrintInstructions" runat="server" Text="This document includes a printable stylesheet. If you are using a modern browser (such as IE7, FF2, or Opera 7) this page will print with appropriate styles and page breaks if needed. Website headers, footers, and this message will not be printed."></asp:Localize></p>
</div>
</div>
<div class="noPrint">
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
<asp:Button ID="Back" runat="server" Text="Back" OnClientClick="window.history.go(-1);return false;" />
</div>
<asp:Repeater ID="OrderRepeater" runat="server">
<ItemTemplate>
<table align="center" class="form<%# (Container.ItemIndex < (OrderCount - 1)) ? " breakAfter" : string.Empty %>" cellpadding="0" cellspacing="0" border="1">
<tr>
<td colspan="4" valign="middle">
<div style="float:left">
<br />
<span style="font-size:150%;"><img src="/Images/ATL Address Logo copy.jpg" width="350px"/></span>
<br />
</div>
<div style="float:right">
<h1 class="invoice">INVOICE</h1>
<asp:Label ID="OrderNumberLabel" runat="server" Text="Order Number:" SkinID="FieldHeader"></asp:Label>
<asp:Label ID="OrderNumber" runat="server" Text='<%# Eval("OrderId") %>'></asp:Label><br />
<asp:Label ID="OrderDateLabel" runat="server" Text="Order Date:" SkinID="FieldHeader"></asp:Label>
<asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}") %>'></asp:Label><br />
<asp:Label ID="ShippingMethodsLabel" runat="server" SkinID="FieldHeader" Text="Shipping Medhods: "></asp:Label>
<asp:Label ID="ShippingMethods" runat="server" Text='<%# GetShipMethods(Container.DataItem) %>'></asp:Label>
</div>
</td>
</tr>
<tr>
<td style="width:10px;text-align:center;font-weight:bold" valign="top">
S O L D T O
</td>
<td valign="middle" width="50%">
<%# GetBillToAddress(Container.DataItem) %>
</td>
<td style="width:10px;text-align:center;font-weight:bold" valign="top">
S H I P T O
</td>
<td valign="middle" width="50%">
<%# GetShipToAddress(Container.DataItem) %>
</td>
</tr>
<tr>
<td colspan="4" class="dataSheet">
<asp:GridView ID="OrderItems" runat="server" ShowHeader="true"
AutoGenerateColumns="false" CellPadding=0 CellSpacing=0 GridLines="none"
Width="100%" DataSource='<%#GetProducts(Container.DataItem)%>' CssClass="dataSheet">
<Columns>
<asp:BoundField DataField="Quantity" HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="Sku" HeaderText="Sku" ItemStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderText="Item">
<ItemTemplate>
<uc:OrderItemDetail ID="OrderItemDetail1" runat="server" OrderItem='<%#(OrderItem)Container.DataItem%>' ShowAssets="False" LinkProducts="False" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price">
<ItemStyle HorizontalAlign="right" width="80px" />
<ItemTemplate>
<asp:Label ID="Price" runat="server" Text='<%#Eval("ExtendedPrice", "{0:lc}")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Discount">
<ItemStyle HorizontalAlign="right" width="80px" />
<ItemTemplate>
<asp:Label ID="Price" runat="server" Text='<%#Eval("ExtendedPrice", "{0:lc}")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total">
<ItemStyle HorizontalAlign="right" width="80px" />
<ItemTemplate>
<asp:Label ID="Price" runat="server" Text='<%#Eval("ExtendedPrice", "{0:lc}")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<table width="100%" cellpadding="0" cellspacing="0" class="dataSheet">
<tr>
<th align="right">
<asp:Label ID="SubtotalLabel" runat="server" Text="Subtotal:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetTotal(Container.DataItem)) %>
</td>
</tr>
<tr>
<th align="right">
<asp:Label ID="ShippingTotalLabel" runat="server" Text="Shipping:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Shipping, OrderItemType.Handling)) %>
</td>
</tr>
<tr>
<th align="right">
<asp:Label ID="TaxTotalLabel" runat="server" Text="Tax:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Tax)) %>
</td>
</tr>
<tr id="trOther" runat="server" visible='<%# GetTotal(Container.DataItem, OrderItemType.Charge, OrderItemType.Coupon, OrderItemType.Credit, OrderItemType.Discount, OrderItemType.GiftCertificate, OrderItemType.GiftWrap) > 0 %>'>
<th align="right">
<asp:Label ID="OtherTotalLabel" runat="server" Text="Other:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Charge, OrderItemType.Coupon, OrderItemType.Credit, OrderItemType.Discount, OrderItemType.GiftCertificate, OrderItemType.GiftWrap)) %>
</td>
</tr>
<tr class="totalRow">
<th align="right">
<asp:Label ID="TotalLabel" runat="server" Text="Total:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetTotal(Container.DataItem)) %>
</td>
</tr>
<%--
<tr>
<th align="right">
<asp:Label ID="PaymentsLabel" runat="server" Text="Payments:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetTotalPayments(Container.DataItem)) %>
</td>
</tr>
<tr>
<th align="right">
<asp:Label ID="BalanceLabel" runat="server" Text="Balance:" />
</th>
<td align="right" width="80px">
<%# string.Format("{0:lc}", GetBalance(Container.DataItem)) %>
</td>
</tr>
--%>
</table>
</td>
</tr>
<tr >
<td colspan="4" valign="middle">
<asp:GridView ID="OrderNotesRepeater" runat="server" AutoGenerateColumns="false" CellPadding=0 CellSpacing=0 GridLines="none" CssClass="dataSheet" DataSource='<%# GetOrderNotes(Container.DataItem) %>' ShowHeader="true" Width="100%">
<HeaderStyle HorizontalAlign="Left" />
<Columns>
<asp:TemplateField HeaderText="Order Notes" >
<ItemStyle Wrap="true" />
<ItemTemplate>
<asp:Label ID="CommentLabel" runat="server" Text='<%#Eval("Comment") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
<tr>
<div align="center"><br />
<b>If you have any questions concerning your order please contact us at 1(877) 405-6107 or email us at Orders@beadworks.com<br />
Thank you for shopping at Beadworks.com!</b>
</div>
</tr>
</ItemTemplate>
</asp:Repeater>
</asp:Content>
Invoice Customization Question
-
- Ensign (ENS)
- Posts: 3
- Joined: Fri Sep 11, 2009 2:16 pm