Changing The Email "from" Name

Hey guys,

I'm running MV and want to change it so that all emails related to orders show our store name (Arteeni) as the From name, not the name of the Vendor.

While playing around with this, I was able to accomplish this for the Shipment notification by deleting

'company_id' => $order_info['company_id'],

from the "fn_update_shipment" function in fn.cart.php.

So, a few questions:

1.) Is doing it that way fine, or could it cause issues?

2.) If it could cause issues, is there a better way to do it?

3.) Lastly, is it possible to make this change (whether my approach or an alternative) "globally", or would

it have to be done to each mailer call?

Thanks,

Jason

To make global changes please use the send_mail_pre hook in the sendMail function (app/Tygh/Mailer.php)

To make global changes please use the send_mail_pre hook in the sendMail function (app/Tygh/Mailer.php)

Hi eComLabs. I took a look in the file, but it's not obvious to me what needs to be modified. Can you please let me know what needs to be changed?

Thanks,

Jason

Hi eComLabs. I took a look in the file, but it's not obvious to me what needs to be modified. Can you please let me know what needs to be changed?

Thanks,

Jason

For example, you can change the $params['company_id'] parameter there if the mail is related to order

As I understand you want to change the e-mail address which is displayed in the new shipment e-mail notification. In order to do that, please replace the following part of code in the fn.cart.php file located in the app/functions directory of your CS-Cart installation :

fn_set_hook('create_shipment_post', $shipment_data, $order_info, $group_key, $all_products, $shipment_id);

if (!empty($force_notification[‘C’])) {
$shipment = array(
‘shipment_id’ => $shipment_id,
‘timestamp’ => $shipment_data[‘timestamp’],
‘shipping’ => db_get_field(‘SELECT shipping FROM ?:shipping_descriptions WHERE shipping_id = ?i AND lang_code = ?s’, $shipment_data[‘shipping_id’], $order_info[‘lang_code’]),
‘tracking_number’ => $shipment_data[‘tracking_number’],
‘carrier’ => $shipment_data[‘carrier’],
‘comments’ => $shipment_data[‘comments’],
‘items’ => $shipment_data[‘products’],
);

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'company_orders_department',
    'data' => array(
        'shipment' => $shipment,
        'order_info' => $order_info,
    ),
    'tpl' => 'shipments/shipment_products.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

}

with this one:

fn_set_hook('create_shipment_post', $shipment_data, $order_info, $group_key, $all_products, $shipment_id);

if (!empty($force_notification[‘C’])) {
$shipment = array(
‘shipment_id’ => $shipment_id,
‘timestamp’ => $shipment_data[‘timestamp’],
‘shipping’ => db_get_field(‘SELECT shipping FROM ?:shipping_descriptions WHERE shipping_id = ?i AND lang_code = ?s’, $shipment_data[‘shipping_id’], $order_info[‘lang_code’]),
‘tracking_number’ => $shipment_data[‘tracking_number’],
‘carrier’ => $shipment_data[‘carrier’],
‘comments’ => $shipment_data[‘comments’],
‘items’ => $shipment_data[‘products’],
);

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'default_company_orders_department',
    'data' => array(
        'shipment' => $shipment,
        'order_info' => $order_info,
    ),
    'tpl' => 'shipments/shipment_products.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

}

And

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'company_orders_department',
    'data' => array(
        'order_info' => $order_info,
        'shipments' => $shipments,
        'use_shipments' => $use_shipments,
        'order_status' => $order_status,
        'payment_method' => $payment_method,
        'status_settings' => $status_settings,
        'profile_fields' => $profile_fields,
        'secondary_currency' => $secondary_currency,
        'take_surcharge_from_vendor' => $take_surcharge_from_vendor
    ),
    'tpl' => 'orders/order_notification.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

if (!empty($edp_data)) {
Mailer::sendMail(array(
‘to’ => $order_info[‘email’],
‘from’ => ‘company_orders_department’,
‘data’ => array(
‘order_info’ => $order_info,
‘edp_data’ => $edp_data,
),
‘tpl’ => ‘orders/edp_access.tpl’,
‘company_id’ => $order_info[‘company_id’],
), ‘C’, $order_info[‘lang_code’]);
}

with this one

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'default_company_orders_department',
    'data' => array(
        'order_info' => $order_info,
        'shipments' => $shipments,
        'use_shipments' => $use_shipments,
        'order_status' => $order_status,
        'payment_method' => $payment_method,
        'status_settings' => $status_settings,
        'profile_fields' => $profile_fields,
        'secondary_currency' => $secondary_currency,
        'take_surcharge_from_vendor' => $take_surcharge_from_vendor
    ),
    'tpl' => 'orders/order_notification.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

if (!empty($edp_data)) {
Mailer::sendMail(array(
‘to’ => $order_info[‘email’],
‘from’ => ‘default_company_orders_department’,
‘data’ => array(
‘order_info’ => $order_info,
‘edp_data’ => $edp_data,
),
‘tpl’ => ‘orders/edp_access.tpl’,
‘company_id’ => $order_info[‘company_id’],
), ‘C’, $order_info[‘lang_code’]);
}

its will be solve this issue :) :D

Deleted

As I understand you want to change the e-mail address which is displayed in the new shipment e-mail notification. In order to do that, please replace the following part of code in the fn.cart.php file located in the app/functions directory of your CS-Cart installation :

fn_set_hook('create_shipment_post', $shipment_data, $order_info, $group_key, $all_products, $shipment_id);

if (!empty($force_notification[‘C’])) {
$shipment = array(
‘shipment_id’ => $shipment_id,
‘timestamp’ => $shipment_data[‘timestamp’],
‘shipping’ => db_get_field(‘SELECT shipping FROM ?:shipping_descriptions WHERE shipping_id = ?i AND lang_code = ?s’, $shipment_data[‘shipping_id’], $order_info[‘lang_code’]),
‘tracking_number’ => $shipment_data[‘tracking_number’],
‘carrier’ => $shipment_data[‘carrier’],
‘comments’ => $shipment_data[‘comments’],
‘items’ => $shipment_data[‘products’],
);

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'company_orders_department',
    'data' => array(
        'shipment' => $shipment,
        'order_info' => $order_info,
    ),
    'tpl' => 'shipments/shipment_products.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

}

with this one:

fn_set_hook('create_shipment_post', $shipment_data, $order_info, $group_key, $all_products, $shipment_id);

if (!empty($force_notification[‘C’])) {
$shipment = array(
‘shipment_id’ => $shipment_id,
‘timestamp’ => $shipment_data[‘timestamp’],
‘shipping’ => db_get_field(‘SELECT shipping FROM ?:shipping_descriptions WHERE shipping_id = ?i AND lang_code = ?s’, $shipment_data[‘shipping_id’], $order_info[‘lang_code’]),
‘tracking_number’ => $shipment_data[‘tracking_number’],
‘carrier’ => $shipment_data[‘carrier’],
‘comments’ => $shipment_data[‘comments’],
‘items’ => $shipment_data[‘products’],
);

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'default_company_orders_department',
    'data' => array(
        'shipment' => $shipment,
        'order_info' => $order_info,
    ),
    'tpl' => 'shipments/shipment_products.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

}

And

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'company_orders_department',
    'data' => array(
        'order_info' => $order_info,
        'shipments' => $shipments,
        'use_shipments' => $use_shipments,
        'order_status' => $order_status,
        'payment_method' => $payment_method,
        'status_settings' => $status_settings,
        'profile_fields' => $profile_fields,
        'secondary_currency' => $secondary_currency,
        'take_surcharge_from_vendor' => $take_surcharge_from_vendor
    ),
    'tpl' => 'orders/order_notification.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

if (!empty($edp_data)) {
Mailer::sendMail(array(
‘to’ => $order_info[‘email’],
‘from’ => ‘company_orders_department’,
‘data’ => array(
‘order_info’ => $order_info,
‘edp_data’ => $edp_data,
),
‘tpl’ => ‘orders/edp_access.tpl’,
‘company_id’ => $order_info[‘company_id’],
), ‘C’, $order_info[‘lang_code’]);
}

with this one

Mailer::sendMail(array(
    'to' => $order_info['email'],
    'from' => 'default_company_orders_department',
    'data' => array(
        'order_info' => $order_info,
        'shipments' => $shipments,
        'use_shipments' => $use_shipments,
        'order_status' => $order_status,
        'payment_method' => $payment_method,
        'status_settings' => $status_settings,
        'profile_fields' => $profile_fields,
        'secondary_currency' => $secondary_currency,
        'take_surcharge_from_vendor' => $take_surcharge_from_vendor
    ),
    'tpl' => 'orders/order_notification.tpl',
    'company_id' => $order_info['company_id'],
), 'C', $order_info['lang_code']);

if (!empty($edp_data)) {
Mailer::sendMail(array(
‘to’ => $order_info[‘email’],
‘from’ => ‘default_company_orders_department’,
‘data’ => array(
‘order_info’ => $order_info,
‘edp_data’ => $edp_data,
),
‘tpl’ => ‘orders/edp_access.tpl’,
‘company_id’ => $order_info[‘company_id’],
), ‘C’, $order_info[‘lang_code’]);
}

its will be solve this issue :) :D

Yea, that's what I ended up doing. I was initially looking for a more elegant "global" solution to override the vendor's email with ours for all emails, but in practice this only occurred in a few places, so I just edited each instance.

Thanks for your help.

Yea, that's what I ended up doing. I was initially looking for a more elegant "global" solution to override the vendor's email with ours for all emails, but in practice this only occurred in a few places, so I just edited each instance.

Thanks for your help.

Your welcome 8)

Should have used the hook to avoid future conflicts, especially if you want to do it for all emails.

That's good advice, but with all the core code changes we've made, we're far past the point of using hooks.