Removing checkout fields in OpenCart

Note: This guide was written for OpenCart 1.x. Although the process is similar for OpenCart 2.x and 3.x, the actual code will differ from the one in this guide.

By default OpenCart asks your customers to specify a number of personal information and address fields during checkout. While this is suitable for most stores, sometimes you might want to simplify the checkout process by removing some fields from the checkout page.

The easiest way to do it is hide input fields and remove error checks. I'll use OpenCart 1.5.1.3 as a basis, but this should be similar for all 1.5.x versions. We recommend you only modify OpenCart core files through vQmod or OCMOD.

Step 1: Modifying the template

There are two main templates responsible for input fields during checkout in default OpenCart theme: catalog/view/theme/default/template/checkout/register.tpl for account registration and catalog/view/theme/default/template/checkout/guest.tpl for guest checkout. Both of the files follow a similar structure so the process for modifying guest checkout template will be the same as for new user registration.

There are also two possible ways of introducing modifications: either by changing the original templates (directly or with vQmod) or by modifying copies of templates and then pointing the controller to load your new files. I'll describe the second method since it reduces the number of core modifications which in turn will make it easier to upgrade later on. You can also change the original templates if you wish - the process will be the same.

First, let's copy our original template: catalog/view/theme/default/template/checkout/register.tpl to catalog/view/theme/default/template/checkout/register-new.tpl.

This alone won't make OpenCart use our new template, we also need to tell the controller to use it instead of the original. In catalog/controller/checkout/register.php, find the following lines (145 - 149):

Change register.tpl to register-new.tpl to tell the controller to load your new template. If you are using a custom theme, make sure you have the new file in your theme's folder.

Now you should be able to see the changes you make to register-new.tpl on the checkout page when selecting to create a new account. Let's make the changes!

We need to hide the input fields we don't want to be displayed by applying style="display:none" to them and removing the corresponding labels. Let's say we don't need Telephone, Fax, Company and Postcode fields.

First we remove the following lines of code from register-new.tpl:

Now we need to hide the input fields by applying style="display:none":

You can also remove the input fields instead of hiding them, however, you'll need to make sure they don't get accessed in the controller or you'll get a bunch of "Undefined index" notices later.

If you now refresh the page, you'll see that the input fields are gone (remove unnecessary line breaks to align the fields properly). However, the new checkout won't work yet. We now have to make appropriate changes in the controller to remove unnecessary validation of hidden fields.

Step 2: Modifying the controller

Controllers reponsible for checkout screen validation are catalog/controller/checkout/register.php for account registration and catalog/controller/checkout/guest.php for guest checkout. As with templates, they have a similar structure so I'll only describe modification of the first one.

All input form validation begins on line 18, when a post request gets submitted to the controller. Since Company and Fax are not mandatory inputs, we will comment out error checks for the rest of our fields: Telephone and Postcode. You can either comment out whole blocks or just the lines where the error variables get set.

Basically, this is it: our input fields are hidden, so empty values will get passed to the controller. However, since HTML forms can be altered on client side, we want to be sure no one tries to post any values for our removed input fields from a modified form, so we'll explicitly clear post array values for both fields before the validation begins. If you removed the fields instead of hiding them, doing this will also ensure you don't get "Undefined index" notices:

Now we're done! Our customers don't have to enter their telephone number and postcode anymore and the company input field is removed from the form.

Need help? Hire us!

We offer a wide range of professional OpenCart & MultiMerch services. Find out more!

About the authorMartin Boze is the Founder of MultiMerch Marketplace. I also love skydiving, motorcycles and space. And other cool things.

43 replies
  1. Nightstar
    Nightstar says:

    Hi,

    This is a very good how-to!! Thanks indeed~ I followed your instruction to do t hat, and I wanna to complete hide the Step 2 & Step 3 in registration & checkout... but seems doesn't work... maybe I do the wrong way, especially for the other fields, can you demonstrate how to hide the Step 2? Thanks!

    Reply
  2. affect
    affect says:

    You can't just remove them since the customer always needs to have an associated address. The easiest way to do it would be to hide Step 2 form using CSS or JavaScript, then assign random or predefined values to mandatory address fields and automatically submit the form when Step 2 is requested.

    We're using a similar approach for hiding Step 3 here: http://ffct.cc/opencart-remove-step-3-on-the-checkout-page/

    You can use this vQmod as a base and extend it so it hides both steps.

    Reply
  3. Xavier
    Xavier says:

    This doesn't work for guest.tpl and guest.php. It generates a json.parse error. And if i use vqmod, it does not proceed to Delivery Options. Please Help!!

    Reply
  4. Ahmed
    Ahmed says:

    Hi guys. There is also an alternative easier way to solve this problem. You can just remove the part that makes the Postal Code required and but in to quotes to make it a comment in both the register.tpl and the guest.tpl.

    I simply modified the code like this <!--*--> that way it keeps the postal code if any customer wants to voluntary include it and it avoids touching the basic structure of the file so as not to mess anything up while making it non-required.

    I hope this helps. Thanks

    Reply
  5. Akash
    Akash says:

    Hey,
    since i am operating in only one city..i do not require options country, city, region. Through your steps i could definitely remove them. no doubt it worked.
    but, after filling the details when a customer clicks on CONTINUE button ..he is not getting redirected.. what should i do?

    Reply
    • Iván
      Iván says:

      Hi Akash, remember that if you hide or remove a required field, it will fail with the validation, you should disable/remove the validation for each field you remove.

      Thank you for this tutorial.

      Reply
  6. raj
    raj says:

    hey bro,

    First I have to say thanks for your great tutorial. I'am not getting the " Step 03 Delivery Details" and "Step 04 Delivery Method" section . It goes straight away to 05 Payment Methods. What is the issue ? I did some modifications to fields and i thought, its due to that issue but when i checked with a previous copy of mine it comes up with same issue step 03 and 04 are missing. Its frustrating me. Is it due to some issue with jqurey files ?

    Reply
  7. Kevin
    Kevin says:

    i've used this method and i thought everything worked properly. But when a costumer orders and gets a confirmation e-mail from his adress and from the products there is a error.

    Instead of a gap or just nothing is this wat they see:

    Notice: Undefined variable: address_2 in /home/rovaranl/domains/rovara.nl/public_html/catalog/view/t

    This looks very strange and gives my shop a unprofessional look and feel.

    Can you tell me how to erase this error?

    Kind regards!

    Kevin

    Reply
  8. Sarah Millington
    Sarah Millington says:

    I have tried to follow the notes here and have successfully removed the fax, company, company ID and Tax ID fields, However, when I get to "Delivery method" I get the message "Warning: No Shipping options are available. ". These were available before. I have tried to undo the steps above, but cannot remove the error message - can you advise me on how to reinstate shipping options after the above code changes?

    Thanks, Sarah

    Reply
    • Anil
      Anil says:

      Hey Jasper,
      Did you get these instructions to work in 1.5.5.1 ?? Im installing 1.5.5.1 on a new website and need to remove some fields. It did work perfectly in 1.5.4.1,
      see ya

      Reply
  9. Bob
    Bob says:

    I think that the best way to do so is to install the extension Custom Registration:

    http://www.opencart.com/index.php?route=extension/extension/info&extension_id=10364

    So you have the full control of all fields, that can be displayed or removed and also can be set to be required or optional. It works on Opencart but also on Mijoshop (Opencart+Joomla).

    Is not a free extension but it saved me a lot of time, and plus, it is compatible with all the latest versions of Opencart. It comes in two versions, one is for vQmod and the second (which contains the same features) doesn't require vQmod at all. It also allows you to style the registration forms with your own CSS and add your own javascript code to the registration/checkout pages. Very useful if you need some jQuery funcion to be added to the forms ( I use a small jQuery function together with that extension that highlights fields when the mouse hovers on them).

    Reply
  10. bitcoin forum
    bitcoin forum says:

    Normally I do not read post on blogs, however I would like to say that this write-up very compelled me to take a look at and do so! Your writing taste has been amazed me. Thank you, quite nice post.

    Reply
  11. Marko
    Marko says:

    Hi,
    Thanks for the great tutorial! I have applied this for several fields (company id, fax, zone id...) in checkout process. The problem I have is that the checkout process is slower (loading time) than it used to be. Should this be normal?

    Thanks,
    Marko

    Reply
  12. Annonymous
    Annonymous says:

    It's realy dificult brother..!! I am sorry it just a suggest for to remove this post and replace with this.

    If you want to remove company name field:
    Open: /catalog/view/theme/your_template/template/checkout/guest.tpl
    And find this code:

    <input type="text" name="company" value="" class="large-field" />

    And then, replace with this code:

    <input type="text" name="company" value="" class="large-field" />

    1. You can change (entry_company) to (entry_address_2) or another
    2. You can change (name=company) to (name=address_2) or another
    3. You can change ($company;) to ($address_2;) or another
    4. It's easy and 100% works..!! But, don't forget to stay backup your default guest.tpl

    Reply
  13. sony
    sony says:

    My whole checkout page got screwed up trying to follow these instructions. It would be my mistake. But pls dont try these things if you are a novice.

    Reply
  14. Svemir
    Svemir says:

    Hi, this is great guide! Trough some errors and trials i managed to remove all fields except email. If i remove email field i don't get any notifications if something is ordered. Customer still gets they email.

    Do you have any suggestion where to look and what might need change? I am trying to understand, notification emails are sent by the store admin and not by the user and i still don't getem?

    Reply
  15. mikael
    mikael says:

    go to this location
    /public_html/catalog/view/theme/default/template/account/register.tpl
    there you remove the taxid and company id
    for the registration page

    Reply
  16. social anxiety cures
    social anxiety cures says:

    I am not sure where you are getting your information, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for excellent information I was looking for this information for my
    mission.

    Reply
  17. Everett
    Everett says:

    I read a lot of interesting posts here. Probably you spend a lot
    of time writing, i know how to save you a lot of time, there is an online tool that creates unique, SEO friendly posts in minutes, just type in google - laranitas free content
    source

    Reply
  18. Catalin Teodorescu
    Catalin Teodorescu says:

    Hello, If i dont want to have mandatory field on guest checkout ... and someone doesnt type email address, how should i do to get email with order as Owner of shop ?

    Reply

Trackbacks & Pingbacks

  1. [...] Maybe I’ll have to start from scratch for the checkout fields.Can anyone confirm if this tutorial is accurate?http://ffct.cc/removing-checkout-fields-in-opencart/ [...]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.