As uctanovit module Example module "Optional field" (Edit)

Categories

We will analyze the installation of the add-on using the example of the "Additional field in the order" module. The rest of the modules are installed in a similar way.

You will receive the module as an archive with folders. They contain the files that need to be edited, as well as the database in the "1DB_changes" folder.

If the module is intended for the same version of OkayCMS as yours, and there are no modifications on your site, then you can simply find the same files and replace.

If you installed a different template or somehow edited the standard one, then it is better to make changes to the files located in the root folder " design" manually, and not to re-upload the files.

The first step is to execute the sql query, which is located in the "1DB_changes" folder.

  1. We execute the sql query.

To do this, go to your hosting. Go to the section "Databases SQL», select the desired database, and open the phpMyAdmin.

PHP MyAdmin

We copy the contents of the * .sql file from the "1DB_changes" folder - this will be our request. For this module, it looks like:

ADD `surname` varchar (255) COLLATE 'utf8_general_ci' NOT NULL DEFAULT ''

Insert the request into the "Sql " phpMyAdmin field. Then press the "Forward " button and execute.

SQL query

To edit the following files, we need FTP access to your hosting. On the hosting, in the "FTP " section, we take the connection data.

  1. We make changes to the CMS files.

After connecting, go to the " Api " folder, which is located at the root of the site. Open the "Validate.php " file.

In the installation files of the module in the folder of the same name, open the same file and look for a comment in the document, in which the revision is highlighted.The comment can be found from the name of the module folder , it is written in English. In this case, the add-on code is marked with the comment / * surname * / . Find the beginning and end of the code marked with a comment and copy it.

We look where the comment is posted and paste it in the same place in your site file.

In this file, the module is placed between the function

 public function is_address ($ address = "", $ is_required = false)

and function

 public function is_comment ($ comment = "", $ is_required = false)

those.

checking custom field

Thus, we have added an additional field check.

We do the same with all the files that are in the module. We find in them the code marked with a comment, and transfer it to the corresponding file on our website. If you know for sure that this file has not been edited before, then you can simply replace it with the one that comes in the archive with the module.

NOTICE:

If the file is in the module folder, but you do not have it in the CMS, then this file is completely new and you just need to upload it to the corresponding folder of your site.

Sometimes, commented-out fragments can be found in add-on files. This marks the code that ALREADY was in the CMS, but for the module to work, it must not be executed. In such cases, you need to find this fragment in the site file and comment it out, or even better, copy the commented out fragment from the add-on and paste it into the appropriate place on your site.

  1. Add the code to the order basket .

Open the folder of the template installed on your site. It is usually located in the root "design " folder. There you need to select a subfolder with the name of the theme of your site. The default template has a folder called "okay_shop " , the rest has a different name.

You need to install the revision in the active template. If you later include another template, then these edits will not be in it!

In the template files, the revision is marked with a comment in curly braces. In our case - {* surname *} . Copy everything that is marked with this comment. We find in the template file the place where our add-on should be located, and paste the copied code there.

For example, in the default template, the revision is placed after

 <span data-language = "form_error_captcha"> 
 <div class = "form_group col-sm-6">
 <input class = "form_input" name = "name" type = "text" value = "" data-language = "form_name" placeholder = " *">
 </div>

those.

custom box to cart

Paste the code into your file and save.

As a result, you will have an additional field in the shopping cart when placing an order:

custom field in the cart

The field also appears in the "Order details " :

custom field in detail

and in the admin panel in the "Orders" :

custom field in orders

We hope we were able to clearly explain the procedure for installing the module in general and the "Additional field" in particular. If you have any questions, write in the comments, and our technical support will help those who cannot cope at all!

Comments 2
Ю.
29.08.2018, 00:57
внесла изменения в файлы CMS (модуль сортировки по популярности), но изменений пока не видно, что еще надо сделать?( так как третий пункт "Добавляем код в корзину заказа" ко мне вроде не относится)
Андрей Воробей
19.05.2018, 09:10
Все понятно. Спасибо) А таким же способом можно добавить поле отечество? Как сделать это поле обязательными?
Write your comment
log in
Download OkayCMS
version 4.5.0
Subscribe to the newsletter
You will receive a selection of useful articles on working with the site on OkayCMS, discounts on modules and templates