Developer forum

Forum » Rapido » Customer Center Order download

Customer Center Order download

Peter Leleulya
Peter Leleulya
Reply

Hi guys,

The order list header in the customer center (B2C) contains an order download button, which targets an aspx page in the admin.
When clicking it provides an Exel document.

My question, is this output somehow configurable?
 

  1. Our customer doesn't want to see the Currency Rate column.
    When using just one currency in the application this value is useless and confusing.
  2. The date output seems to be inconsistent in format, so now I can't be sure if it is May 1st or January 5th ...
    The way us Dutchies read 5-1-2019 (see attachment) is January 5th, but the value actually is May 1st.
    I tried to set the column settings to date in the Excel, but nothing changed.
  3. The date output seems to be the order creation date, I would like to change this to the order complete date which is more usefull to the customer (or add this value as a column)

 

 

Capture_OrderDownload1.PNG Capture_OrderDownload2.PNG

Replies

 
Peter Leleulya
Peter Leleulya
Reply

Hmmm ...
I downloaded the same orders again and the formatting is as I would expect.
Not sure if I used a different browser or downloaded from another language area ... but perhaps the formatting is not an issue ...

 

See capture for differences between downloads ...

Capture_OrderDownload3.PNG
 
Peter Leleulya
Peter Leleulya
Reply

Anyone ???

 
Nicolai Pedersen
Reply

That is hardcoded I am affraid.

Here is the code - you can easily convert it to C# and add it to the razor template file and customize it:

Public Shared Sub RenderExcel(ByVal shopId As String, orderContextId As String)
            Dim response = Context.Current.Response
            Dim uid As Integer = (Security.UserManagement.User.GetCurrentExtranetUser()?.ID).GetValueOrDefault
            Dim isQuote As Boolean = Converter.ToString(Context.Current.Request("OrderType")) = "quotes"
            Dim isLedgerEntry As Boolean = String.Equals(Context.Current.Request("OrderType"), "LedgerEntries", StringComparison.CurrentCultureIgnoreCase)

            If uid = 0 Then response.End()

            With response
                .Clear()
                .ContentType = "application/vnd.ms-excel; charset=" & Text.Encoding.UTF32.WebName
            End With
            response.AddHeader("content-disposition", "attachment;filename=MyOrders.xls")

            Dim orderType As OrderType = OrderType.Order
            If isQuote Then
                orderType = OrderType.Quote
            ElseIf isLedgerEntry Then
                orderType = OrderType.LedgerEntry
            End If
            Dim customerOrders = New CustomerOrderCollection()
            customerOrders.Load(uid, shopId, orderType, 0, False, orderContextId)

            customerOrders.Sort("OrderID", SortOrderType.Asc)

            Dim sb As New Text.StringBuilder()

            '// Write headers
            With sb
                .Append("Date" + vbTab)
                .Append("Order ID" + vbTab)
                .Append("Product ID" + vbTab)
                .Append("Product Number" + vbTab)
                .Append("Variant ID" + vbTab)
                .Append("Variant Text" + vbTab)
                .Append("Product Name" + vbTab)
                .Append("Quantity" + vbTab)
                .Append("Unit Price" + vbTab)
                .Append("Currency" + vbTab)
                .Append("Currency Rate" + vbTab)
                .Append(vbCrLf)
            End With

            For Each enumOrder As Order In customerOrders
                For Each orderLine As OrderLine In enumOrder.OrderLines
                    With sb
                        .Append(enumOrder.Date.ToShortDateString() + vbTab)
                        .Append(enumOrder.Id + vbTab)
                        .Append(orderLine.ProductId + vbTab)
                        .Append(orderLine.ProductNumber + vbTab)
                        .Append(orderLine.ProductVariantId + vbTab)
                        .Append(orderLine.ProductVariantText + vbTab)
                        .Append(orderLine.ProductName + vbTab)
                        .Append(orderLine.Quantity.ToString() + vbTab)
                        .Append(orderLine.Price.Price.ToString() + vbTab)
                        .Append(enumOrder.CurrencyCode + vbTab)
                        .Append(enumOrder.CurrencyRate.ToString() + vbTab)
                        .Append(vbCrLf)
                    End With
                Next
            Next

            response.BinaryWrite(Text.Encoding.UTF32.GetPreamble())
            response.BinaryWrite(Text.Encoding.UTF32.GetBytes(sb.ToString()))
            response.Flush()
            response.End()
        End Sub

 
Peter Leleulya
Peter Leleulya
Reply

Thanks Nicolai, I'll give it a try ;)

 

You must be logged in to post in the forum