nVelocity - Convert Shipment Number to Letter

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

nVelocity - Convert Shipment Number to Letter

Post by ZLA » Mon Aug 17, 2009 10:47 am

Is it possible to convert the shipment number to a letter? For example if we have shipment numbers 1, 2, ... can we display that as A, B, ... using nVelocity in the vendor notification email template?

Thanks in advance.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: nVelocity - Convert Shipment Number to Letter

Post by Logan Rhodehamel » Mon Aug 17, 2009 3:55 pm

With nVelocity, usually the answer is yes. Toward the top find little code like:

Code: Select all

#set ($shipNo = 1)
Then change it to this:

Code: Select all

#set ($shipLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ")	
#set ($shipNo = 0)
Then a few lines down it shows the shipment label (like 1 of 2). Change that to this:

Code: Select all

<strong><u>Shipment ${shipLetters.Substring($shipNo, 1)}</u></strong>
So basically, I created a string variable then accessed the substring property. Warning, if you get more than 26 shipments in an order it will break.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: nVelocity - Convert Shipment Number to Letter

Post by ZLA » Tue Aug 18, 2009 8:37 am

Thank you Logan. I couldn't find a list of nVelocity String functions so I didn't know what I had to work with. Given substring, yours is the obvious solution. Thanks again.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: nVelocity - Convert Shipment Number to Letter

Post by Logan Rhodehamel » Tue Aug 18, 2009 8:49 am

In some ways it helps to think of nVelocity as .NET compiler - you get the full range of .NET methods and properties for any variable. Sometimes the trick is figuring out how to get the variable. Since I know we can create a string variable using the nVelocity set command, that would give you access to all of these:

http://msdn.microsoft.com/en-us/library ... mbers.aspx
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: nVelocity - Convert Shipment Number to Letter

Post by ZLA » Tue Aug 18, 2009 1:20 pm

Thanks.

Post Reply