• Welcome to KonaKart Community Forum. Please login or sign up.
 

Changing order of getStatusTrail

Started by mtoon, April 07, 2008, 05:42:17 pm

Previous topic - Next topic

mtoon

Is there anyway to change the order of the status trail in $order.getStatusTrail()?

We'd like to show newest to oldest.  Thank you!

kate

Hi,

I'm not sure exactly what you mean...

Where are you trying to use that data?  (in a velocity template, a JSP etc ?)

Which API call are you using?

Why can't you just process the order status trail in reverse?

Regards,
Kate

mtoon

It's in the velocity template.  We'd like to show the latest order status at the top.
Thanks

         #foreach( $osh in $order.getStatusTrail() )
         <tr>
            <td width="100%"  colspan="2">
               $dateTool.format('d-MMM-yyyy HH:mm:ss',$osh.getDateAdded(),$locale) : $osh.getOrderStatus()
            </td>
         </tr>
#if ($osh.getComments() != null)
         <tr>
            <td width="100%"  colspan="2">
               $osh.getComments()
            </td>
         </tr>
#end
         #end

ming

Hi,

Whilst array handling is somewhat fiddly and unsophisticated in the 1.5 version of Velocity, it is still possible to modify the OrderDetails template to reverse the order of the order status history records.

In the next release of KonaKart we will add the ListTool Velocity Add-On class to the context of the OrderDetails merge making this task, and others, a little easier.

In a subsequent release (further off than the next release of KonaKart) we will most likely ship with a version of Velocity that includes inbuilt improved Array handling (likely to come in Velocity 1.6).

For now you can achieve what you want with code such as this:

## This first bit figures out how many items in the array:

#set( $shlen = -1 )
#foreach( $ost in $order.getStatusTrail() )
#set( $shlen = $shlen + 1 )
#end


## Then we loop through in the right direction (high to low index) and pick out the right item in the internal loop

#foreach( $iter in [$shlen..0] )
#set( $counter = 0 )
#foreach( $osh in $order.getStatusTrail() )
        #if ($iter == $counter)
        <tr>
            <td class="dataTableContent" align="center">$dateTool.format('d-MMM-yyyy HH:mm:ss',$osh.getDateAdded(),$locale)</td>

#if ( $osh.isCustomerNotified() )
        <td class="dataTableContent" align="center"><img src="tick.gif" border="0" alt="Yes" title=" Yes "></td>
#else
                <td class="dataTableContent" align="center"><img src="cross.gif" border="0" alt="No" title=" No "></td>
#end

<td class="dataTableContent" align="center">$osh.getOrderStatus()</td>
            <td class="dataTableContent">$!osh.getComments()&nbsp;</td>
</tr>
            #end
#set ($counter = $counter + 1)
#end
#end


Ming

mtoon

Great response.  I'll put it in in the morning and see if it works.  Thanks again!