How To Add A New Carrier

You should edit the following files:

design/themes/YOUR_THEME/mail/templates/orders/order_notification.tpl

design/backendmail/templates/orders/order_notification.tpl

Replace:

{$order_header}:

{include file=“orders/invoice.tpl”}

with something similar to:

{if $order_info.status == 'P' || $order_info.status == 'C'}
{$order_header}:

{include file=“orders/invoice.tpl”}
{/if}

Do not forget to clear cache

In 4.3.4 we had to create language variable without prefix "carrier_". Otherwise "_rolay_mail" was displayed everywhere.

How to deal with the situation if we have different tracking links for different languages?

i.e.

For English

gls-group.eu/EN/en/tracking?match=1234

For German

gls-group.eu/DE/de/paketverfolgung?match=1234

In 4.3.4 we had to create language variable without prefix "carrier_". Otherwise "_rolay_mail" was displayed everywhere.

How to deal with the situation if we have different tracking links for different languages?

i.e.

For English

gls-group.eu/EN/en/tracking?match=1234

For German

gls-group.eu/DE/de/paketverfolgung?match=1234

Try this code:

{elseif $carrier == "royal_mail"}
    {if $order_info.lang_code == 'de'}
        {$url = "http://gls-group.eu/DE/de/paketverfolgung?match=`$tracking_number`"}
        {$carrier_name = __("royal_mail")}
    {else}
	{$url = "http://gls-group.eu/EN/en/tracking?match=`$tracking_number`"}
	{$carrier_name = __("royal_mail")}
    {/if}
{else}

(!) Not tested

Hmm, doesn't seem to work or maybe I did sth somehow wrong. I get blank page after I click on "save" beeing in shipment view. There is neither notification displayed nor email sent. Is variable $order_info.lang_code available at that stage?

Hmm, doesn't seem to work or maybe I did sth somehow wrong. I get blank page after I click on "save" beeing in shipment view. There is neither notification displayed nor email sent. Is variable $order_info.lang_code available at that stage?

It should work. Please PM me temporary FTP access so that our specialists can examine the issue.

I finally found some time to check it again and it works the way you sugessted.

I did it for more languages with elseif etc. and I forgot to colse {/if} tag a the end.

T H A N K Y O U

I finally found some time to check it again and it works the way you sugessted.

I did it for more languages with elseif etc. and I forgot to colse {/if} tag a the end.

T H A N K Y O U

We are glad to hear that the issue is solved!

I made a new carrier called "cpost" and everything works as intended.

I click the link in the invoice sent to Customer, it opens the correct Carrier tracking page.

I click the link in the shipments email sent to Customer, it opens the correct Carrier tracking page.

But when I click on the tracking link within an order (Admin side) it doesn't open to the Carrier tracking page like it should, it just opens the same order page.

I've double checked everything, cleared cache, searched the database etc to try and figure it out but can't make it work.

Any ideas?

2016-06-14_21h51_38.png

I found the problem. The new Carrier needs to be added to /app/schemas/shippings/carriers.php

I found the problem. The new Carrier needs to be added to /app/schemas/shippings/carriers.php

Yes, you right. You can do it through addon. For example create app/addons/my_changes/schemas/shippings/carriers.post.php file with the following code:

$schema['new_currier'] = array(
        'tracking_url_template' => 'http://tracking.url?id=[tracking_number]',
    );

return $schema;

I have added my new Carriers and all works well. Now I want to remove the old Carriers from the dropdown.

I have double checked my files, cleared cache, template cache, manually cleared var/cache yet they still persist.

Is the most elegant way to remove it to just delete the language variable?

By 'elegant' I mean to make them cosmetically disappear without ripping them from the core, I don't want to throw too many errors in future upgrades :)

2016-07-01_16h52_54.png

The list of carriers depends on the cscart_shipping_services table. But we do not recommend to change it. Please delete unused carriers in the fn_get_carriers function (app/functions/fn.cart.php)

Unfortunately it does not have hooks

Ok I opened the file fn.cart.php and found

/**
 * Get all available carriers
 *
 * @return array List of available carrier codes
 */
function fn_get_carriers()
{
    $carriers = db_get_fields('SELECT module FROM ?:shipping_services GROUP BY module');
return $carriers;

}

I see it pulls all the carriers from the db and puts them in an array.

But now I am stuck. Do I exclude (remove) the unwanted Carriers from the array, or do I need to re-write the db query to select only the wanted Carriers?

If so what would the query look like?

If you check example from the 1st page, please use the following query:

$carriers = db_get_fields('SELECT module FROM ?:shipping_services WHERE module = ?s GROUP BY module', 'royal_mail');

This information should be already there. Try the following tracking URL:

{$url = "https:///www.internationalparceltracking.com/Main.aspx#/track/`$tracking_number`/`$order_info.s_country`/`$order_info.s_zipcode`"}

I am trying to do the same, also for PostNL. However the format in cscart changed with the recent version.

'tracking_url_template' => 'https://jouw.postnl.nl/#!/track-en-trace/[tracking_number]/{country}/{zipcode}',
 

Do you know how I can edit {country} and {zipcode} to the shipping country / zipcode in carriers.tpl?

In this case, please use the following format:

'tracking_url_template' => 'https://jouw.postnl.nl/#!/track-en-trace/[tracking_number]/[country]/[zipcode]',

then open the design/themes/responsive/templates/common/carriers.tpl and add the following code

{$url = $url|replace:"[country]":$order_info.s_country}
{$url = $url|replace:"[zipcode]":$order_info.s_zipcode}

after the following line:

{$url = $carriers_schema.$carrier.tracking_url_template|replace:"[tracking_number]":$tracking_number}

You can also use the carriers:list hook in this file

Thanks a lot, the first part went fine but I am doing something wrong with the url replace. My edits seem to be ignored even though I clear the cache every time i edit something. I tried it both in the theme responsive as in our customized theme, which is a copy of responsive with some small edits.

I even edited to

    {$url = $carriers_schema.$carrier.tracking_url_template|replace:"[tracking_number]":"hihi"}

and the tracking number is not becoming hihi. So this part of the code is being completely ignored somehow. Any idea what I could be doing wrong?

For the store-front another file should be edited:

design/themes/YOUR_THEME/templates/common/carriers.tpl

Yes ive edited it there as well, but where should i see the effect? When i check the shipments of an order, nothing changes. I attached a screenshot to show which block i mean.

trackinglink.png

Please PM me temporary FTP access, we will check the issue