HOW TO: Add New Exportable Fields

For articles specific to version 6.x
Post Reply
Brandeline
Posts: 76
Joined: Thu Sep 16, 2010 4:12 am

HOW TO: Add New Exportable Fields

Post by Brandeline »

I don't know if anyone else has noticed, but some fields from the Orders table are not included in the available export fields you can choose for your export templates.

For example, the Order Discount field (orddiscountamount), and the Coupon Discount field (coupon_discount) are not available to export on Orders. Can't tell you how many times when doing tax reports I've wished those were there!

I've finally tracked down how to add them and it turns out to be really easy!
There are only two files that need edits to make it work.
These are the files:

In "admin\includes\exporter\filetypes" find the name of the type of exports you want to add a field to. For Orders, it's the orders.php file.
In "language\en\admin" find the export.filetype.<filetype>.ini file. For orders, this would be export.filetype.orders.ini

To add the Order Discount Field to the available export fields I did the following:
1. Open language\en\admin\export.filetype.orders.ini and add the following line to the bottom (This is the label that will be shown on the export template creation/edit screen for this field)

Code: Select all

ordDiscountAmount = "Order Discount Amt"
2. Open admin\includes\exporter\filetypes\orders.php and find the GetFields() function
Near the end of the function change

Code: Select all

"orderAccountsReceivable"	=> array()
to

Code: Select all

"orderAccountsReceivable"	=> array(),
"ordDiscountAmount"	=> array("dbfield" => "orddiscountamount", "format" => "number")
The above code adds the field to the list of fields that will be returned for selection on your template, and defines where the data comes from (the orddiscountamount database field) and the format (a number).

Now go to your export templates and edit one. Look at the orders tab. The new field is now available for selection on your export template.

Easy!
MegaFemaTron2
Confirmed
Confirmed
Posts: 84
Joined: Thu Oct 13, 2011 8:37 pm

Re: HOW TO: Add New Exportable Fields

Post by MegaFemaTron2 »

Doh! Wish I'd come here before I stumbled around and discovered the same thing today. :)
ISC 6.1.1 Ultimate Edition
TERWO
Posts: 17
Joined: Thu Jul 21, 2011 12:54 pm
Location: Bangkok, Thailand

Re: HOW TO: Add New Exportable Fields

Post by TERWO »

Thanks for sharing this. That's really easy small mod.
ISC 6.1.8 Ultimate - end of rope. Going for CS Cart Ultimate with 50+ multistores.
Post Reply