nVelocity - Adding comments to emails

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

nVelocity - Adding comments to emails

Post by WylieE » Tue May 12, 2009 2:08 pm

Hi everyone,

I am trying to add code to our order confirmation emails based on shipment weight. Depending on the total weight of the order, we need to include additional instructions to our order packers. Just a simple if statement, but I'm having problems with the syntax. I've read through the Commercebuilder library docs.

I've tried $shipment.TotalWeight, $orderitem.TotalWeight and order.Items.TotalWeight.

Code: Select all

#if($shipment.TotalWeight() < 4)
First Class Instructions
#end
Does this need to be encapsulated in some sort of #foreach statement?

Thanks!
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

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

Re: nVelocity - Adding comments to emails

Post by mazhar » Wed May 13, 2009 3:15 am

You need to port following code to NVelocity

Code: Select all

LSDecimal orderWeight;
            foreach (OrderShipment orderShipment in _Order.Shipments)
            {
                LSDecimal shipmentWeight = orderShipment.OrderItems.TotalWeight();
                orderWeight += shipmentWeight;
            }

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: nVelocity - Adding comments to emails

Post by nickc » Wed May 13, 2009 9:48 am

$shipment.OrderItems.TotalWeight()

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: nVelocity - Adding comments to emails

Post by WylieE » Wed May 13, 2009 11:00 am

Thanks guys.

I tried Nick's string and couldn't get it to work.

Mazhar's code would imply I need to generate a total weight. If this is the case, what is the purpose of TotalWeight() and under what conditions can it be used?

I'll work on Mazhar's code. Any other suggestions folks?
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: nVelocity - Adding comments to emails

Post by nickc » Wed May 13, 2009 12:56 pm

Hmm. My string definitely returns a value. You might be running into a problem with your comparison - there's a known issue with Able's LSDecimal class in respect to nVelocity - see viewtopic.php?f=42&t=8717 for a workaround.

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: nVelocity - Adding comments to emails

Post by WylieE » Wed May 13, 2009 1:41 pm

Got it to work. Just re-keyed it. nVelocity mojo, I suppose.

Thanks everyone.
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

Post Reply