Hi,
I want to see the tracking number in the shipments summary screen in the back-end (Orders–>Shipments) (./design/backend/templates/views/shipments/manage.tpl),
I found that the field shipments.tracking_number is not in the list, so I made a simple change in fn_get_shipments_info() function in ./app/functions/fn.cart.php as below:
I added a line '?:shipments.tracking_number as my_tracking_number', in the php code, now I can show the tracking number within manage.tpl.
My question is: Is this change safe without changing other part of cs-cart? Will it break something else?
I noticed that now the shipments API shows my new field as well, that's fine for me.
I am using cs-cart 4.1.2.
function fn_get_shipments_info($params, $items_per_page = 0)
{
// Init view params
$params = LastView::instance()->update('shipments', $params);
// Set default values to input params
$default_params = array (
'page' => 1,
'items_per_page' => $items_per_page
);
$params = array_merge($default_params, $params);
$fields_list = array(
'?:shipments.shipment_id',
'?:shipments.tracking_number as my_tracking_number',
'?:shipments.timestamp AS shipment_timestamp',
'?:shipments.comments',
'?:shipment_items.order_id',
'?:orders.timestamp AS order_timestamp',
'?:orders.s_firstname',
'?:orders.s_lastname',
'?:orders.user_id',
);
Hello yong2014,
Your change is completely safe and will not break other parts of CS-Cart, especially because you get the tracking number using the "my_tracking_number" alias and such a field is not used anywhere on shipments or order templates.
Best regards, Sergei
Thanks a lot Sergei !
I know that is not the best move to reply to a 4 year old post but first this is the only reference to my current problem and second I honestly cannot understand why I cannot make a new post into the forum (maybe because I've just register as a new user).
However, I'd like to retrieve a new column from the shipments table (the new column is created and populated in a different part of the code).
I don't think is a good idea to directly modify the core function fn_get_shipments_info but instead I'd like to use the hook "get_shipments", defined into the function.
Into my hook I add a new element into $fields_list but once the control goes back to the fn_get_shipments_info function, the variable $fields_list does not contain the added element.
my hook looks something like this:
Please add ampersand before $fields_list variable
function fn_myaddon_get_shipments($params, &$fields_list, $joins, $condition, $group) { $fields_list[] = '?:shipments.newcolumn'; }
It should help