Mia Stringer
Mia Stringer

Reputation: 31

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

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!

Upvotes: 2

Views: 5768

Answers (2)

kanenas
kanenas

Reputation: 879

[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/.

Upvotes: 0

Mia Stringer
Mia Stringer

Reputation: 31

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!!

Upvotes: 1

Related Questions