Post by CJC » Tue Jan 11, 2022 10:38 pm

Hi All,
I'm taking a stab at updating an old modification that adds a separate email address for the contact us page. There's one change that's not working because the search term is not found in the target file. I'm guessing those data functions have been moved somewhere else since version 2 of OC. I'm not quite sure what the added code is intended to do since it appears that the modification works without it. In the code below I've commented out the section that is failing. But like I said, running it as an ocmod without that change seems to work. Anyone have some insight as to whether or not that is really needed and if so what file it should be put in?

Code: Select all

 <!--
        Admin > Setting > Store
    -->
    <file path="admin/language/*/setting/setting.php">
        <operation>
            <search><![CDATA[
                $_['entry_email']
            ]]></search>
            <add position="after"><![CDATA[
                $_['entry_email_contact'] = 'Contact E-Mail';
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[
                $_['error_email']
            ]]></search>
            <add position="after"><![CDATA[
                $_['error_email_contact'] = 'E-Mail Address does not appear to be valid!';
            ]]></add>
        </operation>
    </file>

    <file path="admin/controller/setting/setting.php">
      <!--  <operation>
            <search><![CDATA[
                $data['entry_email'] = $this->language->get('entry_email');
            ]]></search>
            <add position="after"><![CDATA[
                $data['entry_email_contact'] = $this->language->get('entry_email_contact');
            ]]></add>
        </operation>
-->
        <operation>
            <search><![CDATA[
                if (isset($this->error['email'])) {
            ]]></search>
            <add position="after" offset="4"><![CDATA[
                $data['error_email_contact'] = '';
                if (isset($this->error['email_contact'])) {
        			$data['error_email_contact'] = $this->error['email_contact'];
        		}
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[
                if (isset($this->request->post['config_email'])) {
            ]]></search>
            <add position="after" offset="4"><![CDATA[
                $data['config_email_contact'] = $this->config->get('config_email_contact');
                if (isset($this->request->post['config_email_contact'])) {
        			$data['config_email_contact'] = $this->request->post['config_email_contact'];
        		}
            ]]></add>
        </operation>

        <operation>
            <search><![CDATA[
                $this->error['email'] = $this->language->get('error_email');
            ]]></search>
            <add position="after" offset="1"><![CDATA[
                if ((utf8_strlen($this->request->post['config_email_contact']) > 96) || !preg_match('/^[^\@]+@.*.[a-z]{2,15}$/i', $this->request->post['config_email_contact'])) {
        			$this->error['email_contact'] = $this->language->get('error_email_contact');
        		}
            ]]></add>
        </operation>
    </file>

    <file path="admin/view/template/setting/setting.twig">
        <operation>
            <search><![CDATA[
                <input type="text" name="config_email"
            ]]></search>
            <add position="after" offset="4"><![CDATA[
                <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-email_contact">{{ entry_email_contact }}</label>
                    <div class="col-sm-10">
                        <input type="text" name="config_email_contact" value="{{ config_email_contact }}" placeholder="{{ entry_email_contact }}" id="input-email-contact" class="form-control" />
                        {% if error_email_contact %}
                            <div class="text-danger">{{ error_email_contact }}</div>
                        {% endif %}
                    </div>
                </div>
            ]]></add>
        </operation>
    </file>


    <!--
        Catalog > Controller > Information > Contact
    -->
    <file path="catalog/controller/information/contact.php">
        <operation>
            <search><![CDATA[
                $mail->setTo($this->config->get('config_email'));
            ]]></search>
            <add position="replace"><![CDATA[
                $mail->setTo($this->config->get('config_email_contact'));
            ]]></add>
        </operation>
    </file>
Last edited by CJC on Thu Jan 20, 2022 10:02 pm, edited 1 time in total.

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by xxvirusxx » Tue Jan 11, 2022 11:06 pm

200 $ :laugh: :laugh: :laugh:

Don't use this

Code: Select all

            <search><![CDATA[
                <input type="text" name="config_email"
            ]]></search>
Use this:

Code: Select all

<search><![CDATA[<input type="text" name="config_email"]]></search>
And same when you use replace

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by CJC » Wed Jan 12, 2022 2:34 am

@xxvirusxx is your suggestion merely a general code formatting one for clarify? I ask because the modification functions as intended even with the line breaks/spacing in place.

This is the particular operation that fails because the search item is no longer in that file.

Code: Select all

    <file path="admin/controller/setting/setting.php">
      <!--  <operation>
            <search><![CDATA[
                $data['entry_email'] = $this->language->get('entry_email');
            ]]></search>
            <add position="after"><![CDATA[
                $data['entry_email_contact'] = $this->language->get('entry_email_contact');
            ]]></add>
        </operation>

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by by mona » Wed Jan 12, 2022 2:54 am

well then it is not going to find it and you will have to find another one
in addition it will work without that and it is fine

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by xxvirusxx » Wed Jan 12, 2022 3:04 am

You can remove it from the ocmod. Not needed anymore in 3.x

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by CJC » Wed Jan 12, 2022 3:47 am

@by mona , @xxvirusxx
I will remove the code in question and make the ocmod available here. Thank you for your help.

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by CJC » Thu Jan 20, 2022 10:01 pm

I have attached the mod that will add a separate email address for the contact form. It is based on an older mod for version 2 done by iBet7o.
Please let me know if there are any problems with it.

Attachments


CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am
Who is online

Users browsing this forum: No registered users and 102 guests