How To Add Extra Settings Text Fields On Settings: Company Section

Hi,

I'm in a need of adding an extra text field to accept emails which is to send out notifications to additional internal department of the company.

So how do I achieve this goal from Settings: Company section?

Where are the areas/ files will I need to edit in order to do this?

Can I do this with a custom module?

Thanks in advance

You would add the setting in the schema. You would add the label text in the language translations. You will then need to (most likely) use the mailer_send_pre hook to check if the field is set and/or other conditions.

If you know what you want and don't expect it to change frequently, you can do it a lot cheaper/easier by not using a UI and simply setting the email addresses to use in the hook.

HI Tbirnseth,

Thank you for responding to my query,

Actually, this email id will be changed from time to time, So I believe adding in a settings page is more appropriate.

I'm sorry, could you be more specif about the files and the locations please? I"m bit confused about 'setting in the schema.' wordings.

Should I create a new module to achieve this? or should I need to edit any core files for the purpose?

Thanks again

HI,

I have created a separate addon to accept an email. So bypassing schema editing part.

Now in my func.php file I get this email id and trying to inject into $message of this 'mailer_send_pre' hook function

But the problem is it seems $message contains all private data and not able to see in a foreach loop.

when I do fn_print_r($message) I get following ,

Tygh\Mailer\Message Object
(
[id:protected] => low_stock
[params:protected] => Array
(
)
[data:protected] => Array
(
[product_options] =>
[new_qty] => 5
[product_id] => 2189
[product_code] =>
[product] => product name
[company_data] => Array
(
[company_name] =>
[company_address] => 147 st, Tower T21
[company_city] => Sharq
[company_country] => KW
[company_state] =>
[company_zipcode] =>
[company_phone] => 345643453
[company_phone_2] =>

...

....

Can anyone suggest me how to fetch ' default_company_support_department' data and to replace with module value?

You'll need to look at the class. There are methods that will affect those private properties or you can adjust the data elements that are in the data variables passed to the Mailer.php file.

Hi Tbirnseth,

Thanks for your help,

I went through Message.php class to see as you said, And indeed I found few getters and setters functions.

I called them to fetch the data I wanted and was able to achieve what I needed.

It would be great for me and for the community if you can educate editing general settings page to add a custom input element.

Thank you again for your tips,