Date of receipt in the product card opencart
How to add the date of publication of the product in opencart
Creation, development, manufacturing sites | WEB-STYDIA.COM

5/52 ratings

Greetings to friends, today I want to publish a short note from some usefulness for the online store opencart, namely in this article I will show how you can display the date of publication of the goods in the card, as well as in the list of goods of the category.

All of you already know that when you publish a product in the form of adding the product to the admin panel, there is a field in which you can specify when this product appeared on the site, and so we will display this field in the store template.

Of course, I rarely use it when develop an online store this opportunity, so I think that the buyer before the light bulb when you added this product, but some customers are asking to do this, so we'll consider the option of displaying the date in the card and product category, perhaps someone else will need this note.

And so proceed first to the card of the goods.

In order to add the date of receipt to the card we need, edit only three files, namely:

First we will make changes to the catalog/controller/product/product.php, file, edit:

We are looking for a line:

After that we add the following:

That is, we added a language variable.

Further in the same file we are looking for:

And then we add:

The next step is to add the text itself to the catalog/language/russian/product/product.php file, where before:


The same is done with all the languages that you use on your website.

Well, the last point is the output of the publication date in the product template itself in the catalog/view/theme/*/template/product/product.tpl file:

We find something like this:

And lower or higher, add this:

PS: The date is displayed completely, together from the exact time, if you need to remove the output of time and leave only the date of receipt, then instead of:

Add the following code:

That's all, now next to the field of the model will be the date of receipt of the goods.

As I promised at the beginning of the article, we will also consider the possibility of outputting the date in the list of goods of the category, and so proceed:

As with the addition of the date in the product card, in the category we will only make changes to the three files, and our actions will be almost identical, except for a few moments.

We will make changes to the files:

We will make the first changes to the catalog/controller/product/category.php.

We are looking for a line:

After that we add the following code:

Further in the same file we are looking for:

And then add the following:

Then open the language file catalog/language/russian/product/category.php

And after:


Well, the last edit the template file category catalog/view/theme/*/template/product/category.tpl :

It's a bit more complicated here, since the list of products as usual has two kinds of display, grid and list, for this we need to do for one and for another option:

And so, to display the date of receipt of goods in the category we will be under the name of the goods:

We find:

And then we add:

Further we are looking for:

After we add:

After we search:

And add it again below:

That's actually all that needed to be done to ensure that the list of goods under the name added the date of receipt. Use it, I hope I spent my time writing this article knowingly and to whom it will be useful. Good luck to you.

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.