Which Function Should I Use To Insert Tracking Number And Send It To Customer As Email?

I have shipping tracking number that belongs to orders. I don’t want to insert these tracking numbers manually. I want to save theseautomatically by using correct function. Which function should I use to insert tracking numbers and send it to customer as emails?

What is the correct method to save this data?

Not: my codes is in [color=#282828][font=arial, verdana, tahoma, sans-serif]app/addons/MY_ADDON/controllers/frontend/[/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]shipping_statuses.php[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]I think I should use fn_update_shipment() [/font][/color]function. BUt I don’t know how to use this function.

I tired this but didn’t work :(

<br />
$order_info = fn_get_order_info($IDs);<br />
$shipments_info = fn_get_shipments_info($order_info['order_id']);<br />
<br />
$shipment = array(<br />
                        'shipment_id' => $shipments_info[0][0]['shipment_id'], <br />
                        'timestamp' => time(), <br />
                        'shipping' => $order_info['shipping'],<br />
                        'shipping_id' => $order_info['shipping_ids'], <br />
                        'carrier' => "ups", <br />
                        'comments' => 'blablabla', <br />
                        'items' => $order_info['products'],<br />
                        'order_id' => $IDs,<br />
                        'tracking_number' => $XMLTakipNo[1],<br />
                        'products' => $order_info['products'],<br />
                        //'amount' => "1",<br />
                    );<br />
<br />
<br />
fn_update_shipment($shipment, $shipments_info[0][0]['shipment_id'],0,false,true);<br />
<br />

I found that problem is about fn_check_shipped_products() function. This function is used in fn_update_shipment() function. Because I cannot execute this fn_check_shipped_products() function data cannot be saved in DB.

How can I fix this?

I found that problem is about “amount field”. When I remove fn_check_shipped_products() checking from fn_update_shipment() function in fn.cart.php the data is saved into the DB. But after saving I checked “cscart_shipment_items” table and I saww that “amount” column is “0”. That's why while fn_check_shipped_products() function checks amounts fn_update_shipment() doesn't save data to DB.

Below is fn_check_shipped_products function in fn.cart.php

function fn_check_shipped_products($products)
$allow = true;
$total_amount = 0;
if (!empty($products) && is_array($products)) {
foreach ($products as $key => $amount) {
$total_amount += empty($amount) ? 0 : $amount;
if ($total_amount == 0) {
$allow = false;
} else {
$allow = false;
return $allow;

So, how can I send amounts of products correctly?

I found that problem is not about fn_check_shipped_products() function. I found that problem is about “$all_products = false” parameter in fn_update_shipment function or about “$use_shipments” variable.

Here is :

function fn_update_shipment($shipment_data, $shipment_id = 0, $group_key = 0, $all_products = false, $force_notification = array())

There is a code part in fn_update_payment:

if (!$use_shipments && $all_products) {
foreach ($order_info['product_groups'] as $group) {
foreach ($group['products'] as $item_key => $product) {
if (!empty($product['extra']['group_key'])) {
if ($group_key == $product['extra']['group_key']) {
$shipment_data['products'][$item_key] = $product['amount'];
} elseif ($group_key == 0) {
$shipment_data['products'][$item_key] = $product['amount'];

When I remove “if (!$use_shipments && $all_products) {” everything works correctly. [color=#282828][font=arial, verdana, tahoma, sans-serif]I checked “cscart_shipment_items” table. Values in “amount” are correct, not “0”.[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]So I need to understand what is “[/font][/color]$all_products”. What is the job of [color=#282828][font=arial, verdana, tahoma, sans-serif]“[/font][/color]$all_products”? What should I do?

Here is the part of my code:

fn_update_shipment($shipment, $shipments_info[0][0]['shipment_id'],0,false,true);

I changed


fn_update_shipment($shipment_data, $shipments_info[0][0]['shipment_id'],0,false,true);


fn_update_shipment($shipment_data, $shipments_info[0][0]['shipment_id'],0,true,true);

in my codes ([color=#282828][font=arial, verdana, tahoma, sans-serif]shipping_statuses.php[/font][/color])

and remove “!$use_shipments”


if (!$use_shipments && $all_products) { in fn_update_shipment function in fn.cart.php

I worked. All data saved. So I found it's about $use_shipments.

Here is the part of code in fn_update_shipment:

$order_info = fn_get_order_info($shipment_data['order_id'], false, true, true);
$use_shipments = (Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) == 'Y') ? true : false;

if (empty($shipment_data['tracking_number']) && empty($shipment_data['tracking_number'])) {
return false;

if (!$use_shipments && $all_products) {

if I turn OFF (unchecked) “Allow multiple shipments for a single order:” field in Settings->General, I can send data to DB.

Do I have to turn OFF to send data to DB? Isn't there any other ways to send data without disabled "Allow multiple shipments for a single order: " ?

don't know what you mean by “send data to DB”.