How to edit emails sent from cs-cart to the customer?

The title pretty much says it all. I am trying to figure out what files to edit in order to change what the customer receives upon checking the complete box in the admin tab.

You can change the email subject and header for the ‘Completed’ in Orders->Order statuses. If you want to make changes to the layout, you will need to modify /skins/YOURSKIN/mail/orders/invoice.tpl



Bob

I don’t see the editable text in the file. All I see is css tags.



I need to be able to add a message to the email that is sent to customers. Essentially, I need to add a

tag somewhere.

Depending on where you want the message to appear, you can do either of the following:



To change the header message (EASY)

=================================

In the admin area, go to Orders->Order statuses. Click the ‘edit’ link for the order status you want to change the message. You can enter your new email header (and subject, if you wish) and then click the “Save” button.



To add a message in the body of the invoice (More involved)

=================================================

Open /skins/YOURSKIN/mail/orders/invoice.tpl in a text editor. Work out where you want to add your new message and add the

tag there.



There are some hooks available in the TPL; if you can use those, you won’t need to reapply the change after each upgrade that changes the invoice.tpl. In particular, if you want to add your message at the bottom of the invoice, there is the following hook:

{hook name="orders:invoice"}



Bob

Thank you for the response, I will give it a try.



Somehow, something went terribly wrong and now I am unable to generate invoices for customers. Would it have to do with this file? I cannot move orders from processed to completed and I also cannot print the invoices in pdf or html.



Please help!

Thank you for the response, I will give it a try.



Somehow, something went terribly wrong and now I am unable to generate invoices for customers. Would it have to do with this file? I cannot move orders from processed to completed and I also cannot print the invoices in pdf or html.



Please help!


[QUOTE]{* $Id: invoice.tpl 8713 2010-01-28 08:59:03Z lexa $ *}



{if $order_info}

{literal}


.main-table {
background-color: #ffffff !important;
}


body,p,div {
color: #000000;
font: 10px Arial;
}
body {
padding: 0;
margin: 0;
}
a, a:link, a:visited, a:hover, a:active {
color: #000000;
text-decoration: underline;
}
a:hover {
text-decoration: none;
}
.main-table {
background-color: #f4f6f8;
}

{/literal}













{$settings.Company.company_name} {$lang.invoice_title}









{$settings.Company.company_name}


{$settings.Company.company_address}

{$settings.Company.company_city} {$settings.Company.company_state_descr} {$settings.Company.company_zipcode}

{$settings.Company.company_country_descr}

{if $settings.Company.company_phone}




{/if}
{if $settings.Company.company_phone_2}




{/if}
{if $settings.Company.company_fax}




{/if}
{if $settings.Company.company_website}




{/if}
{if $settings.Company.company_orders_department}




{/if}
{$lang.phone1_label}: {$settings.Company.company_phone}
{$lang.phone2_label}: {$settings.Company.company_phone_2}
{$lang.fax}: {$settings.Company.company_fax}
{$lang.web_site}: {$settings.Company.company_website}
{$lang.email}: {$settings.Company.company_orders_department}


{$lang.order} #{$order_info.order_id}















{if $order_info.shipping}




{if $tracking_number_exists}




{/if}
{/if}
{$lang.status}: {include file="common_templates/status.tpl" status=$order_info.status display="view"}
{$lang.date}: {$order_info.timestamp|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}
{$lang.payment_method}: {$order_info.payment_method.payment}
{$lang.shipping_method}:
{foreach from=$order_info.shipping item="shipping" name="f_shipp"}
{$shipping.shipping}
{if !$smarty.foreach.f_shipp.last}, {/if}
{if $shipping.tracking_number}{assign var="tracking_number_exists" value="Y"}{/if}
{/foreach}
{$lang.tracking_number}:
{foreach from=$order_info.shipping item="shipping" name="f_shipp"}
{if $shipping.tracking_number}{$shipping.tracking_number}
{if !$smarty.foreach.f_shipp.last},{/if}
{/if}
{/foreach}



{assign var="profile_fields" value='I'|fn_get_profile_fields}
{if $profile_fields}


{if $profile_fields.C}
{assign var="profields_c" value=$profile_fields.C|fn_fields_from_multi_level:"field_name":"field_id"}

{/if}
{if $profile_fields.B}
{assign var="profields_b" value=$profile_fields.B|fn_fields_from_multi_level:"field_name":"field_id"}

{/if}
{if $profile_fields.S}
{assign var="profields_s" value=$profile_fields.S|fn_fields_from_multi_level:"field_name":"field_id"}

{/if}


{$lang.customer}:


{if $profields_c.firstname}{$order_info.firstname} {/if}{if $profields_c.lastname}{$order_info.lastname}{/if}


{if $profields_c.email}

{$order_info.email}

{/if}
{if $profields_c.phone}

{$lang.phone}: {$order_info.phone}

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

{$lang.bill_to}:


{if $order_info.b_firstname && $profields_b.b_firstname || $order_info.b_lastname && $profields_b.b_lastname}


{if $profields_b.b_firstname}{$order_info.b_firstname} {/if}{if $profields_b.b_lastname}{$order_info.b_lastname}{/if}


{/if}
{if $order_info.b_address && $profields_b.b_address || $order_info.b_address_2 && $profields_b.b_address_2}


{if $profields_b.b_address}{$order_info.b_address} {/if}{if $profields_b.b_address_2}{$order_info.b_address_2}{/if}


{/if}
{if $order_info.b_city && $profields_b.b_city || $order_info.b_state_descr && $profields_b.b_state || $order_info.b_zipcode && $profields_b.b_zipcode}


{if $profields_b.b_city}{$order_info.b_city} {/if}{if $profields_b.b_state}{$order_info.b_state_descr} {/if}{if $profields_b.b_zipcode}{$order_info.b_zipcode}{/if}


{/if}
{if $order_info.b_country_descr && $profields_b.b_country}


{$order_info.b_country_descr}


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

{$lang.ship_to}:


{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}{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}
{include file="profiles/profiles_extra_fields.tpl" fields=$profile_fields.S}

{/if}
{* Customer info *}


{* Ordered products *}






{if $order_info.use_discount}

{/if}
{if $order_info.taxes}

{/if}


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




{if $order_info.use_discount}

{/if}
{if $order_info.taxes}

{/if}



{/if}
{/hook}
{/foreach}
{hook name="orders:extra_list"}
{/hook}
{$lang.product} {$lang.quantity} {$lang.unit_price} {$lang.discount} {$lang.tax} {$lang.subtotal}

{$oi.product|unescape|default:$lang.deleted_product}
{hook name="orders:product_info"}
{if $oi.product_code}

{$lang.code}: {$oi.product_code}

{/if}
{/hook}
{if $oi.product_options}
{include file="common_templates/options_info.tpl" product_options=$oi.product_options}{/if}
{$oi.amount} {if $oi.extra.exclude_from_calculate}{$lang.free}{else}{include file="common_templates/price.tpl" value=$oi.original_price}{/if} {if $oi.extra.discount|floatval}{include file="common_templates/price.tpl" value=$oi.extra.discount}{else} - {/if} {if $oi.tax_value}{include file="common_templates/price.tpl" value=$oi.tax_value}{else} - {/if} {if $oi.extra.exclude_from_calculate}{$lang.free}{else}{include file="common_templates/price.tpl" value=$oi.display_subtotal}{/if}


{hook name="orders:ordered_products"}
{/hook}
{* /Ordered products *}

{* Order totals *}










{if $order_info.discount|floatval}




{/if}


{if $order_info.subtotal_discount|floatval}




{/if}

{if $order_info.coupons}
{foreach from=$order_info.coupons item="coupon" key="key"}




{/foreach}
{/if}
{if $order_info.taxes}




{foreach from=$order_info.taxes item=tax_data}




{/foreach}
{/if}
{if $order_info.tax_exempt == 'Y'}




{/if}

{if $order_info.payment_surcharge|floatval}




{/if}


{if $order_info.shipping}




{/if}
{hook name="orders:totals"}
{/hook}








{$lang.subtotal}: {include file="common_templates/price.tpl" value=$order_info.display_subtotal}
{$lang.including_discount}:
{include file="common_templates/price.tpl" value=$order_info.discount}
{$lang.order_discount}:
{include file="common_templates/price.tpl" value=$order_info.subtotal_discount}
{$lang.coupon}: {$key}
{$lang.taxes}:
{$tax_data.description} {include file="common_templates/modifier.tpl" mod_value=$tax_data.rate_value mod_type=$tax_data.rate_type}{if $tax_data.price_includes_tax == "Y" && $settings.Appearance.cart_prices_w_taxes != "Y"} {$lang.included}{/if}{if $tax_data.regnumber} ({$tax_data.regnumber}){/if}: {include file="common_templates/price.tpl" value=$tax_data.tax_subtotal}
{$lang.tax_exempt}
{$lang.payment_surcharge}: {include file="common_templates/price.tpl" value=$order_info.payment_surcharge}
{$lang.shipping_cost}: {include file="common_templates/price.tpl" value=$order_info.display_shipping_cost}

{$lang.total_cost}: {include file="common_templates/price.tpl" value=$order_info.total}



{* /Order totals *}

{if $order_info.notes}





{$lang.notes}:
{$order_info.notes|wordwrap:85:"\n":false|nl2br}

{/if}

{if $content == "invoice"}






{include file="buttons/continue_shopping.tpl" but_href=$continue_url|default:$index_script but_arrow="on" skin_area="customer"}

{include file="buttons/button_popup.tpl" but_text=$lang.print_invoice but_href="`$index_script`?dispatch=orders.print_invoice&order_id=`$order_info.order_id`" width="800" height="600" skin_area="customer"}

{/if}
{/if}

{hook name="orders:invoice"}
{/hook}


on" skin_area="customer"}

{include file="buttons/button_popup.tpl" but_text=$lang.print_invoice but_href="`$index_script`?dispatch=orders.print_invoice&order_id=`$order_info.order_id`" width="800" height="600" skin_area="customer"}


{/if}
{/if}

{hook name="orders:invoice"}
{/hook}




[/QUOTE]

[quote name=‘zackstark’]Somehow, something went terribly wrong and now I am unable to generate invoices for customers. Would it have to do with this file? I cannot move orders from processed to completed and I also cannot print the invoices in pdf or html.

[/QUOTE]

If this was the only change you made then this is likely the reason it is not working - you probably placed the edit in the wrong place. Just restore from your backup.



It sounds like you are editing your live site. You should be applying and testing your changes on a test setup.



Bob

I don’t even remember editing the file. It just happened all of a sudden. I know i was looking at the file on my computer, but I don’t think I made any changes.

Restore the file from the skins repository. If it fixes the problem, then something was changed.



Bob

I am sorry, I am rather ignorant to cs-cart in general. Where is the skins repository located?

I actually found it in the var folder, but there are no tpl files in there, just images.

I found it. For future reference it can be found at:



Fastest Web Hosting Services | Buy High Quality Hosting

Has anyone had success completely customizing their email invoices? I modified the following files and saw only minor changes, certainly not what I wanted.



/TEMPLATE_NAME/mail/letter_header.tpl

/TEMPLATE_NAME/mail/orders/order_notification.tpl

/TEMPLATE_NAME/mail/orders/invoice.tpl



Specifically I am trying to change the body font to something more pleasing, such as Century Gothic or another sans serif font - the default Times Roman is rather boring.



Just want to know if I am looking at the correct files, maybe that is why the emails do not appear to change.

You’re changing the right files… make sure you’re adjusting the ones under the skin you are using … and maybe try clearing your cache and compiled folders

Cache did it - so hate that and always forget. Thanks.

One thing to keep in mind when creating/editing invoice templates is that many email clients dont handle html very well. And especially CSS!. Ive done extensive invoice.tpl and other mods and have completely removed CSS , replacing it with the tedious in-line formatting.



Q: How to reset the margins for the PDF version of the invoice? The pdf function uses the same invoice.tpl file but about a 1" border is around the whole thing. And now that Ive set made the invoice template wider, there is some of the invoice missing on the rhs of the pdf invoice.I want to set that border to zero for PDF invoices.



Answer:

Find this code under the “fn_html_to_pdf” function in the /core/fn.common.php

$media->set_margins(array('left' => 20, 'right' => 20, 'top' => 20, 'bottom' => 0));
$media->set_pixels(600);


replace it with: $media->set_margins(array('left' => 2, 'right' => 2, 'top' => 2, 'bottom' => 2));
$media->set_pixels(820);


This works well for invoice widths of 600-800 px.

The issue with the original settings is that if your invoice.tpl file uses a width of >600px then the pdf file is expanded by the ratio = invoice width/set_pixels !

The rule of thumb here is to set the set_pixels value about 10% higher than the width setting of your invoice template and set the set_margins values to about 2.



Which begs the question? Why has cs-cart hard-coded the margins and page scale into a core.php function?

This needs to scale corectly for any invoice width setting IMHO.