And so, as you already understood from the title today, we'll talk as much as possible for the "Bank Transfer" payment module that comes in the standard opencart assembly to add your own text with HTML formatting support.
In this manual, we will attach the ckeditor editor to the translation instruction form, add the html display in the customer order history, in the order history for the administrator, and also send the html code to the client's mail when ordering.
In order to accomplish our task, we need to change only 5 files, namely:
1 2 3 4 5 |
catalog/controller/payment/bank_transfer.php catalog/controller/account/order.php admin/controller/sale/order.php catalog/model/checkout/order.php admin/view/template/payment/bank_transfer.tpl |
Well, let's get started, to make it possible to add HTML code for the payment module Bank transfer.
1.Β Open the file: catalog/controller/payment/bank_transfer.php
We are looking for a line:
1 |
$this->data['bank'] = nl2br($this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id'))); |
And replace it with the following code:
1 |
$this->data['bank'] = html_entity_decode($this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id'))); |
2.Β Open the file: catalog/controller/account/order.php
We are looking for a line with the code:
1 |
'comment' => nl2br($result['comment']) |
And replace it with:
1 |
'comment' => html_entity_decode($result['comment']) |
Further we find the line:
1 |
$this->data['comment'] = nl2br($order_info['comment']); |
And we change it to:
1 |
$this->data['comment'] = html_entity_decode($order_info['comment']); |
3.Β Open the file: admin/controller/sale/order.php
Find the string:
1 |
$this->data['comment'] = nl2br($order_info['comment']); |
And replace with:
1 |
$this->data['comment'] = html_entity_decode($order_info['comment']); |
Further we search for the code:
1 |
'comment' => nl2br($result['comment']), |
And change it to the following code:
1 |
'comment' => html_entity_decode($result['comment']), |
Then again look for the line with the code:
1 |
'comment' => nl2br($order_info['comment']) |
And replace it with:
1 |
'comment' => html_entity_decode($order_info['comment']) |
4.Β Open the file: catalog/model/checkout/order.php
Find the string:
1 |
$template->data['comment'] = nl2br($comment); |
And change it to:
1 |
$template->data['comment'] = html_entity_decode($comment); |
Well, that's all, now you can add instructions to the module with support for html.
But for your convenience, we'll add the HTML editor for the module as well, so that you can quickly and easily edit the text.
5.Β Open the file: admin/view/template/payment/bank_transfer.tpl
In this file we will connect our editor ckeditor.
And so, go to the very end of the file and before:
1 |
<?php echo $footer; ?> |
Add a few lines of code:
1 2 3 4 5 6 7 8 9 10 11 |
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script> <script type="text/javascript"><!-- CKEDITOR.replace('description1', { filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=d8bc4bf53d75d2b575437a54190efb9a', filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=d8bc4bf53d75d2b575437a54190efb9a', filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=d8bc4bf53d75d2b575437a54190efb9a', filebrowserUploadUrl: 'index.php?route=common/filemanager&token=d8bc4bf53d75d2b575437a54190efb9a', filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=d8bc4bf53d75d2b575437a54190efb9a', filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=d8bc4bf53d75d2b575437a54190efb9a' }); //--></script> |
Further in the file we search for a line with the form of input of the instruction:
1 |
<td><textarea name="bank_transfer_bank_<?php echo $language['language_id']; ?>" cols="80" rows="10"><?php echo isset(${'bank_transfer_bank_' . $language['language_id']}) ? ${'bank_transfer_bank_' . $language['language_id']} : ''; ?></textarea> |
And replace it with:
1 |
<td><textarea name="bank_transfer_bank_<?php echo $language['language_id']; ?>" cols="80" rows="10" id="description1"><?php echo isset(${'bank_transfer_bank_' . $language['language_id']}) ? ${'bank_transfer_bank_' . $language['language_id']} : ''; ?></textarea> |
That is, in this line we added id="description1" to the ckeditor editor.
Well, in principle, all you had to do was make the payment module "Bank Transfer" work with HTML code support ...
All the above actions were carried out on opencart version 1.5.5.6 but this instruction will work on all versions of this branch ...
For the second version of Opencart, everything is basically the same except for a few moments that depend on the specific version of Opencart, the very path of the file placement is a bit different code and so on ...
No Comment
You can post first response comment.