OpenCart Remove Required Telephone on Checkout

Feb 26, 2013 articles, code, web design

Ive been doing quite a few OpenCart customization sites lately. And one thing I always have to do is take out the required telephone field on the checkout page. I haven’t done it in a while, and well when I searched Google for the template pages to go to and find the code, it took me a good 10mins to find exactly what I was looking for.

So here is your guide to removing the required telephone field in OpenCart on checkout. 

Files that are throwing the errors if you don’t enter a phone number.

First we have to turn off the warning when someone doesn’t enter a phone number. You will do this in both files listed above. You will need to find the json code. It changes from version to version of OpenCart, so a find (ctrl F) on your editor and search error_telephone and it should take you to the line you need to delete.

if ((utf8_strlen($this->request->post['telephone']) < 3) 
|| (utf8_strlen($this->request->post['telephone']) > 32)) {
                $json['error']['telephone'] = $this->language->get('error_telephone');

Next we need to get rid of the astrix that says the field is required. So we edit the view files.


These 2 files you are just removing the red astrix that states this a required field.

<span>*</span> <?php echo $entry_telephone; ?><br />

That’s it. Pretty simple, and can be applied to other fields.