Page 1 of 1

Simple nVelocity Question

Posted: Wed Oct 19, 2011 10:02 pm
by moustafa
Hi,

I'm trying to do something very simple but it's not working. :)

Inside the "Order Shipped" email, we reference $trackingNumber.TrackingNumberData, which is the tracking number for the order. I want to put in some conditional code to check if the string is blank. In all of the below cases, the condition evaluates to false whether the tracking number is blank or set. In other words, the email is printing out:
bp2
bp4
bp6

Regardless of the value of the tracking number. Any thoughts?



#if($trackingNumber.TrackingNumberData.length() > 0)
<b>bp1</b><br>
#else
<b>bp2</b><br>
#end

#if($trackingNumber.TrackingNumberData.Length > 0)
<b>bp3</b><br>
#else
<b>bp4</b><br>
#end

#if($trackingNumber.TrackingNumberData == "")
<b>bp5</b><br>
#else
<b>bp6</b><br>
#end

Re: Simple nVelocity Question

Posted: Thu Oct 20, 2011 6:23 am
by mazhar
try it like

Code: Select all

#if($trackingNumber.TrackingNumberData !="")
your text here
#end

Re: Simple nVelocity Question

Posted: Fri Oct 21, 2011 11:00 am
by moustafa
Hi Mazhar,

Thanks for the response. However, this didn't work:


#if($trackingNumber.TrackingNumberData !="")
<strong>Tracking Number:</strong> $trackingNumber.TrackingNumberData
#end

What I got in both cases was literally:

Tracking Number: $trackingNumber.TrackingNumberData

Not only did the conditional evaluate to true in both cases, it also didn't render the data in this case.

Is there any readable tutorial or language reference for nVelocity?

Re: Simple nVelocity Question

Posted: Mon Oct 24, 2011 8:10 am
by mazhar
this means most probably $trackingNumber is not available in context where you are attempting to use it. Have a look at this thread viewtopic.php?f=42&t=9329

You can attempt to get tracking number information by doing something like this.