Custom Tracking Notifications

Hey guys,

I'm in the process of modifying the following file:
skins/{your store]/mail/shipments/shipment_products.tpl




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.



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.



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.



Here's my code for the shipment_products.tpl file:


```php

{* $Id$ *}

{include file="letter_header.tpl"} {$lang.dear} {$order_info.firstname},


{$lang.products_were_sent}
















SHIPMENT
Notification
















Order #{$order_info.order_id}



{hook name="orders:invoice_customer_info"}
{if !$profile_fields}
{assign var="profile_fields" value='I'|fn_get_profile_fields}
{/if}
{if $profile_fields}
{/if}
{if $profile_fields.S}
{assign var="profields_s" value=$profile_fields.S|fn_fields_from_multi_level:"field_name":"field_id"}

Ship to:



{$lang.shipping_method}: {$shipment.shipping}

{$lang.shipment_date}: {$shipment.timestamp|date_format:"`$settings.Appearance.date_format`"}

{if $shipment.carrier}
{include file="common_templates/carriers.tpl" carrier=$shipment.carrier}

{/if}
{if $shipment.tracking_number}
{include file="common_templates/shipment_carriers.tpl" carrier=$shipment.carrier}
{foreach from=$order_info.shipping item="shipping" name="f_shipp"}

Tracking #
{$shipment.tracking_number}

{/foreach}
{/if}

{if $order_info.s_firstname && $profields_s.s_firstname || $order_info.s_lastname &&
$profields_s.s_lastname}


{if $profields_s.s_firstname}{$order_info.s_firstname}
{/if}{if $profields_s.s_lastname}{$order_info.s_lastname}{/if}


{/if}
{if $order_info.s_address && $profields_s.s_address || $order_info.s_address_2 && $profields_s.s_address_2}


{if $profields_s.s_address}{$order_info.s_address} {/if}{if $profields_s.s_address_2}
{$order_info.s_address_2}{/if}


{/if}
{if $order_info.s_city && $profields_s.s_city || $order_info.s_state_descr &&
$profields_s.s_state || $order_info.s_zipcode && $profields_s.s_zipcode}


{if $profields_s.s_city}{$order_info.s_city}{if $profields_s.s_state},{/if}
{/if}{if $profields_s.s_state}{$order_info.s_state_descr}
{/if}{if $profields_s.s_zipcode}{$order_info.s_zipcode}{/if}


{/if}
{if $order_info.s_country_descr && $profields_s.s_country}


{$order_info.s_country_descr}


{/if}
{if $order_info.s_phone && $profields_s.s_phone}


{if $profields_s.s_phone}{$order_info.s_phone} {/if}


{/if}
{include file="profiles/profiles_extra_fields.tpl"
fields=$profile_fields.S}


{/if}
{/hook}









{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}




{include file="letter_footer.tpl"}
```

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.

I need to make an adjustment near the this line (toward the bottom) ```php
{foreach from=$shipment.items key="hash" item="amount"}
```

Thanks in advance!

tracking_notification.jpg

– 

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}

```