Post by Vector224 » Fri Nov 23, 2018 10:00 pm

Hello,

I have removed some fields from the registration form, and everything worked fine, but I am afraid that I will get some error in the future or what I did might not be best practice so I just want to check with you what I did and please tell me if I did something wrong. I am using Opencart Version 2.3.0.2

I First removed the Fax field by doing the following:


in file register.tpl in the following path:
public_html\catalog\view\theme\default\template\checkout\register.tpl

I have removed:

Code: Select all

 <div class="form-group">
        <label class="control-label" for="input-payment-fax"><?php echo $entry_fax; ?></label>
        <input type="text" name="fax" value="" placeholder="<?php echo $entry_fax; ?>" id="input-payment-fax" class="form-control" />
      </div>
and then I went ahead to the controller (register.php) in the following path:
public_html\catalog\controller\checkout\register.php

and I disabled (commented) the following

Code: Select all

	//	$data['entry_fax'] = $this->language->get('entry_fax');
After that, I thought everything was right, but I got an error message saying:

Code: Select all

<b> Notice </b> : Undefined index: fax in <b> /home4/dertn/public_html/system/storage/modifcation/catalog/model/account/customer.php</b> on line <b> 19</b> []
So I went ahead to customer.php
in the following path
/home4/dertn/public_html/system/storage/modification/catalog/model/account/customer.php
and I removed:

Code: Select all

"', fax = '" . $this->db->escape($data['fax']) .

And I did the same with company and address 2 fields .... Now do you think what I did was right?

New member

Posts

Joined
Thu May 03, 2018 4:43 am


Post by OSWorX » Sat Nov 24, 2018 4:36 pm

If you never want to use or need these fields, it is basically okay what and how you have done.
Otherwise I would leave the db table fields, and assign an empty value (assigned inside the controller or adding directly in the model).
You should also check if the removed / not needed fields are not used/called somewhere else, e.g. delivery slip, invoice, etc.
Also in customers account.
Otherwise you will get some notices/error messages.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by ocmta » Sat Nov 24, 2018 6:07 pm

Much better way is to replace not needed fields with hidden inputs with empty values instead of removing them. No need to change anything anywhere besides the template.

Code: Select all

<input type="hidden" name="fax" value="" />

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OSWorX » Sat Nov 24, 2018 8:04 pm

ocmta wrote:
Sat Nov 24, 2018 6:07 pm
Much better way is to replace not needed fields with hidden inputs with empty values instead of removing them. No need to change anything anywhere besides the template.

Code: Select all

<input type="hidden" name="fax" value="" />
Not really!
Why?
Because the text (Label) is still displayed.
And (!) the validation in the controller is also still made > result are messages (errors) in fhe form.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by ocmta » Sat Nov 24, 2018 8:22 pm

Of course entire div should be replaced with the hidden input, i should have been more clear about that, though it's kinda obvious.
Most fields don't have validation, and for those that do removing them doesn't solve the problem, since controller will try to validate them anyway. So validation has to be taken care of in the controller if you remove the field, while if you make it hidden, you could put a valid non-empty value in the template input instead.
Again, no need to change anything besides the template, which is much better.

For example, fax is not validated, so all you need to do is replace this:

Code: Select all

 <div class="form-group">
        <label class="control-label" for="input-payment-fax"><?php echo $entry_fax; ?></label>
        <input type="text" name="fax" value="" placeholder="<?php echo $entry_fax; ?>" id="input-payment-fax" class="form-control" />
      </div>
with this:

Code: Select all

 <input type="hidden" name="fax" value="" />
And if you want to remove, for example, phone number, which is required to be between 3 and 32 characters, you can just put 3 spaces as a value.

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OSWorX » Sat Nov 24, 2018 9:34 pm

@ocmta: whenever you (or someone else) is writing here a solution which require to edit the code, post whenever possible the whole code.
Because do not forget, how many visitors here are technicions/coders?
Or know the code, know what is happening if they do what proposed and come back
.. help, have errors .., shop is not working anymore, etc ..
Very rare, so posting a complete and working solution in one answer would be the best for all.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 42 guests