2015-04-26



In my one of previous tutorial we learned about "Adding Custom Product Field in Opencart".This tutorial will explain how to display the custom product field on front end.

Note: Before making any changes directly at any levels , its recommended to take a Backup of database and files.

All the changes explained in this tutorial is for the default English language. If you are running a store in multi language , then you need to download the respective language pack from the opencart extension store and need to add the changes in that pack also.

So before starting, we need to list out the pages where we need to display the custom product field on front end. Below are some of the pages at front end in which we are going to make the changes to display the custom product field.

Product Detail page

Products Compare Page

Products Search Page

Product Detail Page

As the name suggests, Product detail page has all the information about the product. If you want to display the custom_desc field then make the following changes:

(1) Open catalog/language/english/product/product.php file and add the below line :

(2) Open catalog/model/catalog/product.php file and search for the below code in the getProduct() function:

and add the below code just after that :

(3) Open catalog/controller/product/product.php file and search for the below code:

and add the below line just after that:

Now search for the below line:

and add the below line just after that:

Search for the below line :

In case if you use ckeditor for adding new "custom_desc" value in the admin side, then add the following code just after that.

otherwise you can simply add as below,

Now search for the below line:

and add the below code just after that:

(4) Open catalog/view/theme/default/template/product/product.tpl file. Now here we have more that one choices.

-- If you want to display the custom_desc inside the description tab, then find the below line

and add the following code just after that (inside the same div).

-- If you want to display the custom_desc just after the product title, then find the below line:

and add the below line just after that:

-- If you want to display the custom_desc in the Related Products block , then search for the below line :

and add this just after that:

Products Search Page

Opencart provides the searching functionality to easily find the product the user want to search in the store. If you want to display the custom_desc field display in the search page then do the following changes:

(1) Open catalog/controller/product/search.php file and search for the below line in the $data['products'][] array:

and add the below line just after that:

(2) Open catalog/view/theme/default/template/product/search.tpl file and search for the below line :

and add the below line after that :

Product Compare Page

Opencart provides the functionality of comparison between the products so that users can view the features of the different products side by side. In order to add the custom_desc field in the product compare page make the below changes.

(1) Open catalog/language/english/product/compare.php file and add the below code:

(2) Open catalog/controller/product/compare.php file and find the below code:

and add the below line of code just after that:

Now find,

and add the below code just after that:

(3) Open catalog/view/theme/default/template/product/compare.tpl file and search for the below code:

and add the below code just after that:

That's it..!! You have custom_desc field display in front end. Let me know if you get any error , issues or want to display custom_desc in any other section of the front end side. I will add the code for the same as an update of this article.

Need Opencart Customization, Contact Me

Show more