i would like to add my 2cents here. take it for what it is worth...
mc is correct, using an observer is the way to go.
you are incorrect; you do NOT need to add the data to the orders table or the orders_products table.
i would suggest using an auto loaded observer. you can read about it here:
https://docs.zen-cart.com/dev/code/n...aded-observers
when you are constructing an invoice, the order class will be queried. so you need to add some elements to the order object when queried, and then use those elements when constructing an invoice.
for example, if we were to look here:
https://github.com/zencart/zencart/b...order.php#L367
here is a notifier that you want to attach to. at this point, you will have a product_id and from within your observer you can then get the products_qfcode and make it part of your order object.
Okay, I see the Notify bit but how do I attach to it? What do I need to do to attach to it?
you can then use the same observer to attach to the notifier here:
https://github.com/zencart/zencart/b...order.php#L375
at this point, the class should already have the customer_id and you can then retrieve the customers_qfcode and again make it part of your order object.
Same point as above.
then depending on where you want to display those elements on your invoice, they will be available for use. the invoice makes use of the order object as seen here:
https://github.com/zencart/zencart/b...nvoice.php#L25
and when using the order object it will query the order if an order number is provided as seen here:
https://github.com/zencart/zencart/b....php#L151-L152
while adding the elements to the 2 aforementioned table could be done, i think it will be a lot more work and rather unnecessary. unless of course these codes change over time, and you want to know what the codes were at the time of the order. that would require something completely different; and would necessitate storing those elements in the tables.
Whilst there is some merit in having an audit trail - it isn't necessary if the Observer method is easier to achieve.
best.
Bookmarks