How can I remove a form field in opencart 2.0 checkout/registration page?

5.4k Views Asked by At

I am trying to remove some fields from opencart 2.0x checkout and registration page, like fax, postal code. I can't seem to find the right extension so I'd like to go editing from the code level.

Can anyone guide me to a starting point?

2

There are 2 best solutions below

3
On BEST ANSWER
  1. Search for the field in account/register.tpl and delete it.
  2. If the field is mandatory, you will also have to search for it in register controller and delete its validation from validate() function.
0
On

You can make new file

remove-fields.ocmod.xml

and put this code

<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Remove Field From Checkout Page</name>
<code>removeextrafield</code>
<version>1.0</version>
<author>Anuj Khandelwal</author>
<link>http://themextension.com</link>

<file path="catalog/view/theme/*/template/account/register.tpl">
    <operation>
        <search index="2"><![CDATA[
            <div class="form-group">
        ]]></search>
        <add position="replace"><![CDATA[
            <div class="form-group" style="display: none;>
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/account/address_form.tpl">
    <operation>
        <search index="1"><![CDATA[
            <div class="form-group">
        ]]></search>
        <add position="replace"><![CDATA[
            <div class="form-group" style="display: none;>
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/affiliate/{edit,register}.tpl">
    <operation>
        <search index="3"><![CDATA[
            <div class="form-group">
        ]]></search>
        <add position="replace"><![CDATA[
            <div class="form-group" style="display: none;>
        ]]></add>
    </operation>
    <operation>
        <search><![CDATA[
            $entry_address_1;
        ]]></search>
        <add position="replace" trim="true"><![CDATA[
            $text_your_address;
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/checkout/{guest_shipping,payment_address,shipping_address}.tpl">
    <operation>
        <search index="1"><![CDATA[
            <div class="form-group">
        ]]></search>
        <add position="replace"><![CDATA[
            <div class="form-group" style="display: none;>
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/checkout/{guest_shipping,payment_address,shipping_address}.tpl">
    <operation>
        <search index="1"><![CDATA[
            <div class="form-group">
        ]]></search>
        <add position="replace"><![CDATA[
            <div class="form-group" style="display: none;>
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/checkout/{register,guest}.tpl">
    <operation>
        <search><![CDATA[
            <div class="form-group">
        ]]></search>
        <add position="replace"><![CDATA[
            <div class="form-group" style="display: none;>
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/account/{register,address_form}.tpl">
    <operation>
        <search><![CDATA[
            $entry_address_1;
        ]]></search>
        <add position="replace" trim="true"><![CDATA[
            $text_your_address;
        ]]></add>
    </operation>
</file>

<file path="catalog/view/theme/*/template/checkout/{register,guest,guest_shipping,payment_address,shipping_address}.tpl">
    <operation>
        <search><![CDATA[
            $entry_address_1;
        ]]></search>
        <add position="replace" trim="true"><![CDATA[
            $text_your_address;
        ]]></add>
    </operation>
</file>

</modification>