Page 1 of 1
Abandoned Basket Email Needs Product.Summary
Posted: Tue May 24, 2011 8:42 am
by scooter85
I'm trying to edit the Abandoned Basket Email to show Product Summary instead of Name or Sku. How do I do this?
I've got example code to add Summary into Packing List but I'm not for sure where to add code for Abandoned Basket Email to pull from. Do I need to add code to BasketItemDetail.ascx.cs before pulling it into the email template?
Thanks,
Scott
Re: Abandoned Basket Email Needs Product.Summary
Posted: Tue May 24, 2011 9:13 am
by mazhar
You need to do it in NVelocity. I think something like this will work for you
Code: Select all
#foreach($basketItem in $basket.Items)
#if ($basketItem.OrderItemType == "Product")
<tr>
<td style="text-align:center;">$basketItem.Sku</td>
<td><b>$basketItem.Name</b></td>
<td>$basketItem.Quantity</td>
<td>$basketItem.Price.ToString("ulc")</td>
<td>
#if ($basketItem.Product != null)
$basketItem.Product.Summary
#end
</td>
</tr>
#end
#end
This code will print basket item information plus product summary.
Re: Abandoned Basket Email Needs Product.Summary
Posted: Tue May 24, 2011 9:16 am
by scooter85
Thanks for the help Mazhar I'll give it a try
Scott
Re: Abandoned Basket Email Needs Product.Summary
Posted: Tue May 24, 2011 9:43 am
by scooter85
I've got the Product.Summary to print out right now but if there are coupons or taxes or shipping it doesn't list the correct info for the description, see below. Is there and if then statement to put if it doesn't have a summary description to put name? I tried just putting Product.Summary instead of Name but now I can't go view any results because I get an error when trying to view the email. When I press the "SEND ALERT" button I get this error "We are sorry, but the page you are trying to access has experienced an error.
Please contact
Sales@DccCrafts.com to report this problem."
SKU Description Quantity Price
03-1596 03-1596 Tin Glass Candle Holder Butterfly w/Candle 6.25" (Each) 1 $6.99
24-8110 24-8110 Weathervane Bunny Candle/ Pot Holder Wood & Rusty Tin 20" (Each) 1 $34.99
1 $basketItem.Product.Summary 1 $1.28
20 $basketItem.Product.Summary 1 -$3.50
21 $basketItem.Product.Summary 1 -$20.99
$basketItem.Product.Summary 1 $6.95
Re: Abandoned Basket Email Needs Product.Summary
Posted: Tue May 24, 2011 1:04 pm
by scooter85
Mazhar, the code up above didn't work. It caused an error. Did you try that in a copy of Abandoned Baskets Email Template? I took out Sku in the first column td/ since we have sku in our Summary text. See the picture below for my problem. Do you know how to fix the $basketItem.Product.Summary problem in the last 4 lines. (Tax, Discount, Coupon, Shipping)
Thanks,
Scott
Re: Abandoned Basket Email Needs Product.Summary
Posted: Wed May 25, 2011 3:23 am
by mazhar
EDIT
Well basket item could be of different types. basketItem.Product will only work for items of type product. Try something like this
Code: Select all
#if ($basketItem.OrderItemType == "Product" && $basketItem.Product != null)
$basketItem.Product.Summary
#else
$basketItem.Name
#end
Re: Abandoned Basket Email Needs Product.Summary
Posted: Wed May 25, 2011 7:05 am
by scooter85
No I replace that code inside my <td> </td> in NVelocity and it doesn't work. Causes an error. This is how I added it. Is their some other syntax problem?
Code: Select all
#foreach($basketItem in $basket.Items)
<tr>
<td><b> #if ($basketItem.OrderItemType == "Product" && $basketItem.OrderItemType != null)
$basketItem.Product.Summary
#else
$basketItem.Name
#end</b></td>
<td style="text-align: center;">$basketItem.Quantity</td>
<td style="text-align: right;">$basketItem.Price.ToString("ulc")</td>
</tr>
#end
Re: Abandoned Basket Email Needs Product.Summary
Posted: Wed May 25, 2011 8:12 am
by mazhar
Yes there is an issue. Seems like I made that mistake. Try following code
Code: Select all
#foreach($basketItem in $basket.Items)
<tr>
<td><b> #if ($basketItem.OrderItemType == "Product" && $basketItem.Product != null)
$basketItem.Product.Summary
#else
$basketItem.Name
#end</b></td>
<td style="text-align: center;">$basketItem.Quantity</td>
<td style="text-align: right;">$basketItem.Price.ToString("ulc")</td>
</tr>
#end
Actually the statement saying $basketItem.OrderItemType != null was wrong. It was suppose to be $basketItem.Product != null
Re: Abandoned Basket Email Needs Product.Summary
Posted: Wed May 25, 2011 8:34 am
by scooter85
Nope, still doesn't work. Any Ideas?
Re: Abandoned Basket Email Needs Product.Summary
Posted: Thu May 26, 2011 2:38 pm
by scooter85
I figured there would be an easy solution for adding Summary for products but keeping Name for other items. Just wondering if anybody else has any ideas?
Thanks,
Scott
Re: Abandoned Basket Email Needs Product.Summary
Posted: Fri May 27, 2011 5:02 am
by mazhar
OK I made a mistake in last code. The product null check was not correct. Following code seems functional on my local install
Code: Select all
#if ($basketItem.OrderItemType == "Product" && $basketItem.Product != "")
$basketItem.Product.Summary
#else
$basketItem.Name
#end
Re: Abandoned Basket Email Needs Product.Summary
Posted: Fri May 27, 2011 6:49 am
by scooter85
Excellent!!! Thanks Mazhar!!!
Do you look through other C# code in able for examples of these #if #else statements for your ideas on how to do stuff. Just trying to get an idea how to go about solving these problems on my own in the future?