Output of the number of views in the product card opencart
Number of views in the product card opencart
Creation, development, manufacturing sites | WEB-STYDIA.COM

Guys I want to share with you one small revision for opencart namely how to make so that the product card displayed the number of views of this product, perhaps someone will be interested, since some customers sometimes want a blob :) .

And so in order to display the number of views in the product card, we need to change only a few lines in the product controller and also in the product template itself.

The "viewed" viewer function was originally built into the basic assembly of opencart, we'll just bring it to our template, and so let's go ....

First of all, we open the goods inspector: File catalog/controller/product/product.php

In it we search for a line:

After which we add:

Further in the same place we search for a line:

After it, add a line that is responsible for outputting the language from the language file namely the word "Views:"




All with the controller finished, we proceed to the language file catalog/language/russian/product/product.php

In it we add:

In any place after <?php I added for example after:

All the same thing we do with other languages if they are present in the store.

I finished the language, now open the file of your theme catalog/view/theme/default/template/product/product.tpl

And in the place convenient for you we add the code:

For example after:

That's basically all, now in the product card you will see the number of views of this product.

Well, and a little bun, for example, if you want to replace the word "views" with an example of a picture in the form of a glazier well, or something else ...

For this you need from the code added in the template:

Remove the output of the word itself and remove it:

After you add a set of styles to the style file for your theme:

Well, of course for each of the templates you may have to customize the styles for yourself, but still you have the basic view, well, do not forget to upload the picture of the eye in the image folder of your template. You can download the eye of  here 

That's basically all I wanted to write, now you have a beautiful glazik in the opencart product card near which you will see how many times this product was viewed ...

Good luck!

You may also like

No Comment

You can post first response comment.

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter a message.