Post by GilesM » Mon May 29, 2017 8:48 pm

Hi all,
I am starting to dabble in OCMOD for a new project using OpenCart. I have dredged up all that google can offer on how to use OCMOD ...

However, I am little confused why the following is not working ...

ocmod.xml file:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Add new wholesale register section</name>
    <code>00001</code>
    <version>1.0</version>
    <author>PGM</author>
    <link></link>
    <file path="admin/view/template/customer/custom_field_form.tpl">
        <operation>
            <search><![CDATA[
            <option value="address"><?php echo $text_address; ?></option>
            ]]></search>
            <add position="after" offset="1"><![CDATA[
            <?php if ($location == 'wholesale') { ?>
            <option value="wholesale" selected="selected"><?php echo $text_wholesale; ?></option>
            <?php } else { ?>
            <option value="wholesale"><?php echo $text_wholesale; ?></option>
            <?php } ?>
            ]]></add>
        </operation>
    </file> 
    <file path="admin/language/en-gb/customer/custom_field.php">
        <operation>
            <search><![CDATA[$_['text_regex']           = 'Regex';]]></search>
            <add position="after"><![CDATA[$_['text_wholesale'] = 'Wholesale';]]></add>
        </operation>
    </file>
</modification>
In the log file it looks like it has added just fine:
MOD: Add new wholesale register section

FILE: admin/view/template/customer/custom_field_form.tpl
CODE: <option value="address"><?php echo $text_address; ?></option>
LINE: 59

FILE: admin/language/en-gb/customer/custom_field.php
CODE: $_['text_regex'] = 'Regex';
LINE: 23

But when I go to the custom_field page in the admin I get a notice inside the select box saying:
Notice: Undefined variable: text_wholesale

If I hard code the language text into the OCMOD it seems to work fine!

Any help would be great ... sure it is something really obvious I am missing.

Regards.
Last edited by GilesM on Mon May 29, 2017 9:15 pm, edited 1 time in total.

PGM

Don't pay for simple mods
My free modules: Filter resets in admin, Add extra flat shipping, Improved Admin Product Search and Canned Messages.
My site uses (free): Modification refresh button, Additional Alert Email Fix, TLT Structured Data
My site uses (paid): Journal2, Restrict catalog by customer group


New member

Posts

Joined
Mon May 29, 2017 8:28 pm

Post by cyclops12 » Mon May 29, 2017 8:54 pm

You will also need to define the variable in the relevant controller file

Active Member
Online

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by GilesM » Mon May 29, 2017 9:14 pm

Thanks cyclops12! ;D
Anyone else reading this - I added the following and it works fine ... got remember this is MVC-L.

Code: Select all

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

PGM

Don't pay for simple mods
My free modules: Filter resets in admin, Add extra flat shipping, Improved Admin Product Search and Canned Messages.
My site uses (free): Modification refresh button, Additional Alert Email Fix, TLT Structured Data
My site uses (paid): Journal2, Restrict catalog by customer group


New member

Posts

Joined
Mon May 29, 2017 8:28 pm

Post by cyclops12 » Mon May 29, 2017 9:39 pm

glad to be of help, and happy its working now :)

Active Member
Online

Posts

Joined
Sun Sep 27, 2015 1:10 am
Who is online

Users browsing this forum: No registered users and 4 guests