Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Changing The Email "from" Name Rate Topic   - - - - -

 
  • arteeni
  • Advanced Member
  • Members
  • Join Date: 07-Aug 15
  • 85 posts

Posted 29 August 2016 - 06:31 PM #1

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


Arteeni - a marketplace for artisan, handmade goods, with a charitable twist.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 20947 posts

Posted 30 August 2016 - 06:43 AM #2

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • arteeni
  • Advanced Member
  • Members
  • Join Date: 07-Aug 15
  • 85 posts

Posted 30 August 2016 - 01:14 PM #3

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


Arteeni - a marketplace for artisan, handmade goods, with a charitable twist.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 20947 posts

Posted 30 August 2016 - 02:29 PM #4

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • akshay.sharma
  • Advanced Member
  • Members
  • Join Date: 19-Dec 15
  • 107 posts

Posted 21 September 2016 - 12:51 PM #5

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

 



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11770 posts

Posted 22 September 2016 - 01:03 AM #6

Deleted


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • arteeni
  • Advanced Member
  • Members
  • Join Date: 07-Aug 15
  • 85 posts

Posted 25 September 2016 - 04:36 PM #7

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.


Arteeni - a marketplace for artisan, handmade goods, with a charitable twist.


 
  • akshay.sharma
  • Advanced Member
  • Members
  • Join Date: 19-Dec 15
  • 107 posts

Posted 25 September 2016 - 06:52 PM #8

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)



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11770 posts

Posted 26 September 2016 - 05:45 AM #9

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

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • arteeni
  • Advanced Member
  • Members
  • Join Date: 07-Aug 15
  • 85 posts

Posted 26 September 2016 - 05:57 PM #10

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


Arteeni - a marketplace for artisan, handmade goods, with a charitable twist.