Custom Tracking Notifications

Hey guys,

I’m in the process of modifying the following file: ```php


skins/{your store]/mail/shipments/shipment_products.tpl

<br />
I'm using some of the basic coding from the "invoice.tpl" file to create a custom looking tracking notification vs. the "ugly" one that comes with CS Cart by default. I'm currently running version 2.2.3.<br />
<br />
I have a good start, except I'm having trouble listing the "item shipped" in a "item_list_row" format. In other words, I want to list each item that has shipped within a nice table.<br />
<br />
The only problem is whenever I make a partial shipment.. say 1 out of 4 items have shipped, it will display the 1 item shipped correctly, but it will also create the tables for the other 3 items but just leave them blank. See attached image.<br />
<br />
Here's my code for the [b]shipment_products.tpl[/b] file:<br />
<br />
```php
<br />
{* $Id$ *}<br />
<p>{include file="letter_header.tpl"} {$lang.dear} {$order_info.firstname},<br /><br /><br />
{$lang.products_were_sent}<br />
<br><br />
</p><br />
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main-table" style="height: 100%; background-color: #f4f6f8; font-size: 12px; font-family: Arial;"><br />
<tr><br />
<td align="center" style="width: 100%; height: 100%;"><br />
<table cellpadding="0" cellspacing="0" border="0" style=" width: 602px; table-layout: fixed; margin: 24px 0 24px 0;"><br />
<tr><br />
  <td style="background-color: #ffffff; border: 1px solid #e6e6e6; margin: 0px auto 0px auto; padding: 0px 44px 0px 46px; text-align: left;"><br />
   <table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding: 27px 0px 0px 0px; border-bottom: 1px solid #868686; margin-bottom: 8px;"><br />
   <tr><br />
	<td align="left" style="padding-bottom: 3px;" valign="middle"><img border="0" alt="" src="image" width="300" height="56"></td><br />
	<td width="100%" valign="bottom" style="text-align: right;  font: bold 26px Arial; text-transform: uppercase;  margin: 0px;">SHIPMENT<br />
				  Notification</td><br />
   </tr><br />
   </table><br />
   <table cellpadding="0" cellspacing="0" border="0" width="100%"><br />
   <tr valign="top"><br />
	<td style="padding-top: 14px;"><br />
	 <table cellpadding="0" cellspacing="0" border="0" width="100%"><br />
	 <tr valign="top"><br />
	  <td style="color: #000000; padding-right: 10px; white-space: nowrap;"><h2 style="font: bold 17px Tahoma; margin: 0px;">Order&nbsp;#{$order_info.order_id}</h2><br />
				</td><br />
	  <td style="font-size: 12px; font-family: verdana, helvetica, arial, sans-serif; color: #000000; padding-right: 10px; white-space: nowrap;" rowspan="2"><br />
{hook name="orders:invoice_customer_info"}<br />
   {if !$profile_fields}<br />
   {assign var="profile_fields" value='I'|fn_get_profile_fields}<br />
   {/if}<br />
   {if $profile_fields}<br />
{/if}<br />
	{if $profile_fields.S}<br />
	{assign var="profields_s" value=$profile_fields.S|fn_fields_from_multi_level:"field_name":"field_id"}<br />
				</td><br />
	  <td style="color: #000000; padding-right: 10px; white-space: nowrap;"><br />
					<h2 style="font: bold 17px Tahoma; margin: 0px;">Ship to:</h2><br />
				</td><br />
	 </tr><br />
	 <tr valign="top"><br />
	  <td style="font-size: 12px; font-family: verdana, helvetica, arial, sans-serif; color: #000000; padding-right: 10px; white-space: nowrap;"><br />
<strong>{$lang.shipping_method}</strong>:&nbsp;{$shipment.shipping}<br /><br />
<strong>{$lang.shipment_date}</strong>:&nbsp;{$shipment.timestamp|date_format:"`$settings.Appearance.date_format`"}<br /><br />
{if $shipment.carrier}<br />
{include file="common_templates/carriers.tpl" carrier=$shipment.carrier}<br />
<!-- <strong>{$lang.carrier}</strong>:&nbsp;{$smarty.capture.carrier_name}<br /> --><br />
{/if}<br />
{if $shipment.tracking_number}<br />
{include file="common_templates/shipment_carriers.tpl" carrier=$shipment.carrier}<br />
				{foreach from=$order_info.shipping item="shipping" name="f_shipp"}<strong><br><br />
						  Tracking #</strong>:&nbsp;<a class="underlined" {if $smarty.capture.carrier_url|strpos:"://"}target="_blank" href="{$smarty.capture.carrier_url}" {/if}>{$shipment.tracking_number}</a><br /><br />
						  {/foreach}<br />
						  {/if}<br />
				</td><br />
	  <td style="font-size: 12px; font-family: arial; color: #000000; padding-right: 10px; white-space: nowrap;"><br />
{if $order_info.s_firstname && $profields_s.s_firstname || $order_info.s_lastname &&<br />
$profields_s.s_lastname}<br />
	 <p style="margin: 2px 0px 3px 0px;"><br />
	  {if $profields_s.s_firstname}{$order_info.s_firstname}<br />
						{/if}{if $profields_s.s_lastname}{$order_info.s_lastname}{/if}<br />
	 </p><br />
	 {/if}<br />
	 {if $order_info.s_address && $profields_s.s_address || $order_info.s_address_2 && $profields_s.s_address_2}<br />
	 <p style="margin: 2px 0px 3px 0px;"><br />
	  {if $profields_s.s_address}{$order_info.s_address} {/if}{if $profields_s.s_address_2}<br />{$order_info.s_address_2}{/if}<br />
	 </p><br />
	 {/if}<br />
	 {if $order_info.s_city && $profields_s.s_city || $order_info.s_state_descr &&<br />
$profields_s.s_state || $order_info.s_zipcode && $profields_s.s_zipcode}<br />
	 <p style="margin: 2px 0px 3px 0px;"><br />
	  {if $profields_s.s_city}{$order_info.s_city}{if $profields_s.s_state},{/if}<br />
						{/if}{if $profields_s.s_state}{$order_info.s_state_descr}<br />
						{/if}{if $profields_s.s_zipcode}{$order_info.s_zipcode}{/if}<br />
	 </p><br />
	 {/if}<br />
	 {if $order_info.s_country_descr && $profields_s.s_country}<br />
	 <p style="margin: 2px 0px 3px 0px;"><br />
						{$order_info.s_country_descr}<br />
	 </p><br />
	 {/if}<br />
	 {if $order_info.s_phone && $profields_s.s_phone}<br />
	 <p style="margin: 2px 0px 3px 0px;"><br />
	  {if $profields_s.s_phone}{$order_info.s_phone} {/if}<br />
	 </p><br />
	 {/if}<br />
	 {include file="profiles/profiles_extra_fields.tpl"<br />
fields=$profile_fields.S}<br />
					<p><br />
   {/if}<br />
   {/hook}				</td><br />
	 </tr><br />
	 </table><br />
	</td><br />
   </tr><br />
   </table><br />
<br />
   <table width="100%" cellpadding="0" cellspacing="1" style="background-color: #dddddd;"><br />
   <tr><br />
	<th width="70%" style="background-color: #eeeeee; padding: 6px 10px; white-space: nowrap; font-size: 12px; font-family: Arial;">{$lang.product}</th><br />
	<th style="background-color: #eeeeee; padding: 6px 10px; white-space: nowrap; font-size: 12px; font-family: Arial;">Quantity<br />
				  shipped</th><br />
   </tr><br />
			{foreach from=$shipment.items key="hash" item="amount"}<br />
			{hook name="orders:items_list_row"}<br />
	{if !$oi.extra.parent}<br />
	<tr><br />
	 <td style="padding: 5px 10px; background-color: #ffffff; font-size: 12px; font-family: Arial;"><br />
  <br />
	{if $amount > 0}<br />
	{$order_info.items.$hash.product}<br /><br />
  {if $order_info.items.$hash.product_options}<br />
   {include file="common_templates/options_info.tpl" product_options=$order_info.items.$hash.product_options}<br /><br />
  {/if}<br />
  <strong>{$lang.code}:</strong>&nbsp;{$order_info.items.$hash.product_code}{/if}<br />
	 </td><br />
	 <td style="padding: 5px 10px; background-color: #ffffff; text-align: center; font-size: 12px; font-family: Arial;"> {if $amount > 0}{$amount}{/if}<br />
	   </td><br />
	 </tr><br />
		{/if}<br />
   {/hook} {/foreach}<br />
   </table><br />
			<table border="0" width="100%" cellspacing="0" cellpadding="3"><br />
			  <tr><br />
				<td style="padding: 5px 10px; background-color: #ffffff; font-size: 12px; font-family: Arial;"><br />
				<br>{if $shipment.comments}<br />
<strong>{$lang.comments}</strong>: {$shipment.comments}<br />
{/if} </td><br />
			  </tr><br />
			  <tr><br />
				<td style="padding: 5px 10px; background-color: #ffffff; font-size: 12px; font-family: Arial;" height="30"><br />
</td><br />
			  </tr><br />
			</table><br />
  </table><br />
  </td><br />
</tr><br />
</table><br />
{include file="letter_footer.tpl"}<br />

```<br />
<br />
Does anyone know how to modify code for the table so the items list correctly? I think it something fairly easy to fix... I just dont see it.<br />
<br />
I need to make an adjustment near the this line (toward the bottom) ```php
<br />
{foreach from=$shipment.items key="hash" item="amount"}<br />

```<br />
<br />
Thanks in advance!<p><a href="127.0.0.1/uploads/monthly_02_2014/post-18361-0-54855600-1392522245.jpg">tracking_notification.jpg</a></p>

– 

Assuming it needs to be bracketed within an if statement with some condition. It would take some study to advise the actual details, but hopefully you've stared at it long enough that a hint is all you need.

Well here is the block of code that needs adjusting. This is the table that would contain the product information:

```php






{foreach from=$shipment.items key="hash" item="amount"}
{hook name="orders:items_list_row"}
{if !$oi.extra.parent}




{/if}
{/hook} {/foreach}
{$lang.product} Quantity
shipped


{if $amount > 0}
{$order_info.items.$hash.product}

{if $order_info.items.$hash.product_options}
{include file="common_templates/options_info.tpl" product_options=$order_info.items.$hash.product_options}

{/if}
{$lang.code}: {$order_info.items.$hash.product_code}{/if}
{if $amount > 0}{$amount}{/if}










{if $shipment.comments}
{$lang.comments}: {$shipment.comments}
{/if}






```

And if you paste that code into a web program like dreamweaver or frontpage, you get the following. [b]See attached image. [/b]This will help show you what I'm trying to acheive. So far it does work and the notifications are sent fine, however, I just can't figure out why it's putting in all rows for products even though they didnt ship yet.

table_web_editor_view.jpg

EDIT I was able to resolve the issue :) Just a simple code move as I thought. Literally took 1 sec to fix once I found it.



Thanks for anyone who view this.

So why don't you share what you had to change so others can benefit from your experience?

[quote name='tbirnseth' timestamp='1392583819' post='177610']

So why don't you share what you had to change so others can benefit from your experience?

[/quote]



Sorry, I didn't post my changes becuase it wasn't a “cart issue”… it was just my own personal issue playing around with code to customize my notification file.



Anyway, here's the line of code that I needed to move:


{if $amount > 0}


Shown here originally:

```php






{foreach from=$shipment.items key="hash" item="amount"}
{hook name="orders:items_list_row"}
{if !$oi.extra.parent}




{/if}
{/hook} {/foreach}
{$lang.product} Quantity
shipped


{if $amount > 0}
{$order_info.items.$hash.product}

{if $order_info.items.$hash.product_options}
{include file="common_templates/options_info.tpl" product_options=$order_info.items.$hash.product_options}

{/if}
{$lang.code}: {$order_info.items.$hash.product_code}{/if}
{if $amount > 0}{$amount}{/if}










{if $shipment.comments}
{$lang.comments}: {$shipment.comments}
{/if}






```

[b]Moved up higher next to:[/b]
```php
{foreach from=$shipment.items key="hash" item="amount"}
```
[b]As shown here:[/b]
```php





{foreach from=$shipment.items key="hash" item="amount"}{if $amount > 0}






{/if}
{/foreach}
{$lang.product} Quantity
shipped


{$order_info.items.$hash.product}

{if $order_info.items.$hash.product_options}
{include file="common_templates/options_info.tpl"
product_options=$order_info.items.$hash.product_options}

{/if} {$lang.code}: {$order_info.items.$hash.product_code}
{$amount}



{if $shipment.comments}










{$lang.comments}: {$shipment.comments}

```