How to add custom fields to the order_invoice.tpl, OpenCart 2.0

你离开我真会死。 提交于 2020-01-04 05:47:11

问题


I have searched far and wide for this answer on the web, and nobody seems to have an answer. I know that in OpenCart 2.0 you have the ability to add custom fields in the registration process. I have added 3. I see that they are showing up in the Order Details section of an order, but I need them to show up on the printed invoice too. The code that outputs the custom fields in the order_info.tpl is as follows:

<?php foreach ($account_custom_fields as $custom_field) { ?>
  <tr>
    <td><?php echo $custom_field['name']; ?>:</td>
    <td><?php echo $custom_field['value']; ?></td>
  </tr>
<?php } ?>

I attempted to just insert that into order_invoice.tpl but I am receiving the error:

Notice: Undefined variable: account_custom_fields in /home/raphaelseventworks.com/www/ncbaorders/admin/view/template/sale/order_invoice.tpl on line 64Warning: Invalid argument supplied for foreach() in /home/raphaelseventworks.com/www/ncbaorders/admin/view/template/sale/order_invoice.tpl on line 64

I don't know enough about OpenCart to know which files make up the order_invoice.tpl. Can someone help me out? I believe one answer I saw to this same question is, "It's difficult." I know it's not a simple process, but if you can point me to the right files, I would greatly appreciate it!


回答1:


Thanks to nevermind for the hint!

In admin->controller->sale->order.php, I found on line 863 the section for Custom Fields. I copied that whole section into the bottom of public function invoice(). Worked like a dream. Thanks for the help!!




回答2:


[VQMOD] Add Custom Fields To Order Invoice
https://github.com/kanenas/vqmod-opencart-admin-add-custom-fields-order-invoice

Opencart: v.2.1.0.2
Attention: You have to install [VQMOD] for Opencart ( https://github.com/vqmod/vqmod/releases ) for this to work!

  1. Upload the file knns_admin_add_custom_fields_order_invoice.xml inside the folder /vqmod/xml/.


来源:https://stackoverflow.com/questions/32214811/how-to-add-custom-fields-to-the-order-invoice-tpl-opencart-2-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!