How to remove unwanted fields from OpenCart 2.x checkout page?

Page 1

How to remove unwanted fields from OpenCart 2.x checkout page?

Caption: You can remove a field from OpenCart checkout by editing some files explained here Description: Guide to remove a field from OpenCart checkout page

OpenCart checkout page asks the customers to fill up a number of details and address information during the checkout process. However, sometimes, in order to simplify the checkout process, we wish to remove some fields from the checkout page which we think are not important for us. These fields might be unnecessarily making the checkout complex and lengthy. In this article, I will use the OpenCart version 2.x to explain how can you remove such fields from the Guest and registered checkout process.

Caption: OpenCart uses two template files to show and control the fields on checkout Description: Removing a field from Guest checkout and Register account form


As an example I will remove the “Fax� field from the guest checkout and Register Account. You can use the same approach to remove any other field too. The codes for input field in checkout are handled by two main OpenCart templates:

catalog/view/theme/themeXXX/template/checkout/register.tpl - for Register Account catalog/view/theme/themeXXX/template/checkout/guest.tpl - for Guest Checkout

PS: I would suggest you to not to edit these files directly. Take a backup of the original files first by copying these files from your web server or wherever they are located and keep them with you so that you can always revert back in case of any mistake. Take another copy of these same files and perform the editing on these files, later replace them with the original files on the site after editing. Removing the Guest checkout fields 1. We will start with editing the Guest Checkout fields. So the first step you need to follow here is to navigate to the following file directory and open the file:

catalog/view/theme/themeXXX/template/checkout/guest.tpl

Caption: Open guest.tpl file 2. We are removing the Fax field from the guest checkout here. So, find the following lines of code in the file you have just opened: <div class="form-group">


<label class="control-label" for="input-payment-fax"><?php echo $entry_fax; ?></label> <input type="text" name="fax" value="<?php echo $fax; ?>" placeholder="<?php echo $entry_fax; ?>" id="input-payment-fax" class="form-control" /> </div> 3. Remove this code from the file or you can also just comment it to disable the code.

Caption: Remove or comment the code in guest.tpl file 4. Next, we need to edit the controller file to make sure this removal will not show any "Undefined index" later. So, navigate tot he following file directory and open the file to edit the controller:

catalog/controller/checkout/guest.php 5. Look for the following lines of code in the files you have just opened:

$data['entry_fax'] = $this->language->get('entry_fax'); if (isset($this->session->data['guest']['fax'])) { $data['fax'] = $this->session->data['guest']['fax'];


} else { $data['fax'] = ''; } $this->session->data['guest']['fax'] = $this->request->post['fax']; 6. Remove the codes or you can just comment them too.

Caption: Remove or comment the codes in guest.php file 7. Save both the files and replace them with the original files on the site.

Removing Fields from Register Account form 8. To remove the Fax field, open the following file :

catalog/view/theme/themeXXX/template/checkout/register.tpl


Caption: Open register.tpl file 9. Find and remove the following lines of code in the file you have just opened <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>


Caption: Remove or comment the code in register.tpl file 10. Next, we need to edit the following controller to make sure no “Undefined index� error is shown in the later part.

catalog/controller/checkout/register.php


Caption: Open register.php file 11. Find the following line of code and remove it. You can also comment it instead. $data['entry_fax'] = $this->language->get('entry_fax');

Caption: Remove or comment the code in register.php file 12. Save both the files now, and replace them with original files on the site.


So, this is how you can remove a field like "Fax" from both the Guest checkout and Account Register form. You can follow the similar approach to remove any kind field from the OpenCart checkout. Just do not forget to keep the backup of the original files before you edit them. Alternate solution Editing the core files is not a recommended way to perform the changes on your OpenCart site. Some of us might suggest the use of vQmod or OCMOD to reduce the risk, but these methods are too complicated for the website owners with no or less technical knowledge. As an alternate solution, you can choose to switch to our OpenCart checkout extension. It is a

one-page checkout extension that has loads of features to make your checkout conversion friendly.

Caption: With One-page checkout, you show or hide any field from the checkout You can “Hide” or “Display” any of fields from the checkout page by simply changing the settings from the extension’s back end configuration. Plus you can change the orders of fields by just dragging and dropping.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.