Simple nVelocity Question

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
moustafa
Lieutenant (LT)
Lieutenant (LT)
Posts: 54
Joined: Wed Oct 19, 2011 9:54 pm

Simple nVelocity Question

Post by moustafa » Wed Oct 19, 2011 10:02 pm

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

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Simple nVelocity Question

Post by mazhar » Thu Oct 20, 2011 6:23 am

try it like

Code: Select all

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

moustafa
Lieutenant (LT)
Lieutenant (LT)
Posts: 54
Joined: Wed Oct 19, 2011 9:54 pm

Re: Simple nVelocity Question

Post by moustafa » Fri Oct 21, 2011 11:00 am

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?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Simple nVelocity Question

Post by mazhar » Mon Oct 24, 2011 8:10 am

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.

Post Reply