Generic Orders Export

    This module provides a more configurable means to export your batched order data to a flat file. The format and content of the header and exported orders is configured with tokens. Tokens are available for all of the order data and you can control exactly what data is exported. Including the shipping and payment data, even the data stored in the payment module's own databases. So you can export the credit card numbers and other payment data regardless of which payment module you have.
    Because of the flexibility provided, you can very specifically tailor the format of the exported data. For example, it is a simple matter to export ONLY data pertaining to the products in the order as you might need to generate a pick list. Similarly, you can generate a list of just the customer specific information.
    The Generic Orders Export module started life as a Worldship export module. It permits the order data to be exported in a format which can then be imported into UPS Worldship. Go here for more details on this application and here for a note from a customer about using the module for this purpose.

    Here is a run down on how the module works. The export occurs line-by-line. It exports the header line (if it is configured to do so) then looks through the Orders data base and finds the first order in that batch. It replaces the tokens in the "template for order row" with that order's information then exports that line. It then finds that order's first item. If the "Template for item row" field has text in it, the module will use that product's data to replace the tokens in that template, then export that line. If there is no text in this field, the module will skip that step and proceed to the attributes. After exporting the item row, the module finds the products first attribute (if any). It replaces the tokens of the "Template for attribute row" with the first attribute and exports that line. It repeats this process for each attribute. It then proceeds to find the next product. Etc.


Lists of tokens usable in this module can be found here
Installation instructions can be found here

The module has only 1 screen in admin:
Batch to export:    
This is the batch of orders that will be included in the export. Clicking on the "export" button starts the export. The export will NOT occur if you update the page to make changes to the configuration. Similarly, changes to the page will NOT be updated when you click on the "Export" button.

Export to file:
relative to Merchant2/00000001/export/
This is the file that the order will be exported to. This is relative to the "export" directory for your store (which is located in the Miva data directory). Typically this will have a path such as the above: Merchant2/00000001/export/. So in this example, entering nothing but a file name, the export will be in the Merchant2/00000001/export/orders.csv file.
If file already exists: Append To File Replace the file
This tells the module how to treat the export file if a copy of it already exists. It can either be deleted and replaced, or have the new exported data appended to the end.
Template for Header:
This is the exact line that will be exported in the "header" line of the export file. The characters: ^& represent a "tab" and when the export occurs any instance of those two characters will be replaced with tabs to produce...a tab delimited file!
    include in export?
If it's checked the header line will be exported...if not it won't be included in the export.
Template for Order row:
This is the exact line that will be exported for the orders (one per order). Tokens can be used to represent the order data you want to export. In the above example, %ship_lname% will be replaced with the shipping address last name, %ship_fname% will be replaced with the first name, %ship_comp% will be replaced with the shipping company, etc. A full list of tokens that can be used in this field can be found here. Note that only the order tokens can be used in this field.

Template for item row:
This is the exact line that will be exported for the items in the order(once per item). If the field is empty (such as it is in the "Miva's flat file" template shown in the example), the module will proceed to export the attributes (if the product has any). Tokens can be used to represent the product data you want to export. A full list of tokens that can be used in this field can be found here. Note that all order and product tokens can be used in this field.

Template for attribute row:
This is the exact line that will be exported for the attributes belonging to the product (once per attribute). Tokens can be used to represent the attribute and option data you want to export. A full list of tokens that can be used in this field can be found here. Note that all order, product, and attribute tokens can be used in this field.

Restore to:
don't restore   Miva's flat file format   an alternate example   a Worldship format
   Using as a delimiter: comma pipe tab
You can change/restore the templates to several different configurations. To change the template, click on the radio button for the format that you want to restore to and the delimiter that you want to use. The "Miva's flat file" format is identical to the format used by Miva's standard "Export orders to flat file" module (i.e. each line contains the customer and order data and is repeated once for each item/attribute combination). The "alternate example" exports the order info on the first line, followed by the first product, followed by it's attributes, then the second item, etc. The "Worldship" format is the format discovered to be able to be imported into UPS' Worldship. Go here for more information on this format.

Use ^& to represent tabs in the templates

A brief primer on the "concept" of tokens can be found here.

In this module, the "order" tokens can be used in any of the other fields. The "product" tokens can be used in the "product row" template and the "attribute row" template. The "attribute" tokens can be used only in the "Attribute row template". Tokens used in a fields in which they were not intended will simply display in the displayed page.

The "Orders" tokens:

%orderdate%order date
%todaysdate%todays date
%yesterday%yesterday's date
%orderid%Order id
%cust_password%Customers password (assuming the customer was logged into their account)
%cust_login% Customers login (assuming the customer was logged into their account)
%cust_id% Customer id (assuming the customer was logged into their account)
%ship_fname% shipping first name
%ship_lname% shipping last name
%ship_email% shipping email
%ship_comp% shipping comp
%ship_phone% shipping phone
%ship_fax% shipping fax
%ship_addr% shipping address
%ship_city% shipping city
%ship_state% shipping state
%ship_zip% shipping zip
%ship_cntry% shipping cntry
%bill_fname% billing first name
%bill_lname% billing last name
%bill_email% billing email
%bill_comp% billing company
%bill_phone% billing phone
%bill_fax% billing fax
%bill_addr% billing addr
%bill_city% billing city
%bill_state% billing state
%bill_zip% billing zip
%bill_cntry% billing cntry
%storename% Store's name
%storeowner% Store's owner
%storeemail% Store's email
%storecompany% Store's company
%storeaddress% Store's address
%storecity% Store's city
%storestate% Store's state
%storezip% Store's zip
%storephone% Store's phone
%storefax% Store's fax
%storecountry% Store's country
%ordershipping%Shipping method as stored in orders database
%shippingmethod%Shipping method as reported by shipping module
%totalshipping%Shipping total
%paymentmethod%Payment method as reported by payment module
%paytype%Payment method description (same as %paymentmethod%
%orderpayment%Payment method as stored in orders database
%totaltax%Amount of tax
%totalwithshipping%Subtotal with shipping
%totalwithtax%Subtotal with tax
%ordertotal%Total paid for order

The tokens used for the payment data have a slightly peculiar form. The data displayed for the payment corresponds with the data displayed by the payment module in the >Order Processing section of admin (and identical to the data displayed for the order in the "Standard Batch Report"). So if you go to an order, to the payment module's tab for that order, you will see the data for the payment displayed, one item of data per line. For example, a credit card payment might show:

Card TypeVISA
Card Number5444 4444 4444 4444
Expiration Month03
Expiration Year2004

The label (eg. Card Type or Card Number) for the first line would be represented in the template with the token %paylabel|1|%. The data (eg. Visa or 5444 4444 4444 444) for the first line would be displayed with the token %paydata|1|%. And so on. So if your payment module collects 4 fields, to include the data for all four fields in the export, you will need the tokens %paydata|1|%, %paydata|2|%, %paydata|3|%, and %paydata|4|% in your template In the above example, to add the payment data to the end of the orders line in your export file, you could add to the end of "template for header" the labels (assuming that you are using the comma as the delimiter):

,CARD_TYPE,CARD_NUMBER,EXP_MONTH,EXP_YEAR

and add to the end of the "Template for Order row"

,%paydata|1|%,%paydata|2|%,%paydata|3|%, %paydata|4|%

%paydata|x|%the data for the xth payment field
%paylabel|x|%the label (as displayed at checkout) for the xth payment field
%payfield|x|%the abbreviated "code" used by the module to identify the payment field. For example, this might be ccnum for the card number

The "Products" tokens:

%prodname%product's name
%prodcode%product's code
%prodweight%product's weight
%prodprice%product's price
%prodcost%product's cost
%prodquantity%quantity ordered
%produpsold%'1' if product was an upsell, '0' otherwise
%prodtaxable%'1' if product was a taxable purchase, '0' otherwise
%prodtotal%the total paid for that product (quantity x price)
%prodtotalF%the total paid for that product formatted using the currency module

The "Attribute" tokens:

%attrcode%attributes's code
%optcode%option's code (if options was selected)
%attrprice%attributes's price. If there is no price, nothing will be displayed
%attrdata%data entered into attribute's "text" field (for text type attributes"
%attrdatalong%data entered into attribute's "memo" field (for memo type attributes". Note: since a single attribute can't have data in the %attrdata% and %attrdatalong% attribute at the same time, these two are often used together in templates such as: %attrdata%%attrdatalong%
%attrtotal%the attribute's total price (quantity x attribute price)
%attrtotalF%the attribute's total price formatted with the currency module

    Here is a note from Barrett Butler of http://handmade-paper.us (the customer behind the original module and the individual who had the patience to figure out how to import a flat file into Worldship) on how to use the module to produce a flat file which can then be exported into Worldship as well as information on how to do the import:
Ok here is what I have in the module fields which is about 90% of the  
battle.
  You still must create "Map" in Worldship no matter what module you use.
This will create file made for "keyed" import method for WorldShip.
e.g. enter order#, field populate, weigh your box, enter weight, hit  
process, label prints

File name:

orders.txt

Template for Header Row:

nameups^&Company^&Street^&Country^&Zip^&City^&State^&ordnum^&Email^&snop 
tion^&sntype

snoption = Y  [you must use Y literally for WS]
sntype = e-mail   [you must spell e-mail just like that or it will not  
work in WS]
Those 2 are for "ship notification" and "ship notification type"


Template for Order row:

%ship_fname%  
%ship_lname%^&%ship_comp%^&%ship_addr%^&%ship_cntry%^&%ship_zip%^&%ship_ 
city%^&%ship_state%^&%orderid%^&%ship_email%^&Y^&e-mail

^& = tab character [ed: use the ^& characters in the templates.  They will be replaced with 
the tab character when the export occurs]

Now I thought I'd keep this a secret but to prevent undue pain and  
suffering:
The export file for ups CANNOT have a field named "order"  - "ordnum"  
will work.
If you do call a field "order" for like the order number you'll get some  
stupid  MS Windows OBDC error.
Don't bother trying to fixit as UPS tech guy said it was an issue with  
their app and windows.

Don't let low level tech at UPS tell you it cannot use tabs. They  
always try to use CSV comma file and that will screw you with mMerchant  
since users will enter commas into the bill/ship fields.

let me know if you need further help using this.
We go cross platform from Mac to Windows with this thing too for all  
the Mac offices out there.
I can brief that workflow if needed - not a big deal really.

Here is a sample of final file output as I use it.

nameups|Company|Street|Country|Zip|City|State|ordnum|Email|snoption|snty 
pe
Barrett Butler|TestCompany|123 Test Drive, Suite  
123|US|48169|Testville|TN|3432|creativepapers@mac.com|Y|e-mail
I used pipes in this text since my dang email app wouldn' let me paste  
it with tabs to suit me.

    Here is a later note from T. Taylor of http://www.RisingStarIdeas.com. He purchased the module with an eye towards using it for a WorldShip export and found the following:
Mike here are a few things I discovered while trying to use this module for UPS Worldship:

1.      The header field names can not contain spaces 
2.      If you are exporting data from the Order row and the Item row, put all tokens in
the item row, to avoid the results data appearing on two lines. Worldship can not handle
the results data listed on two separate lines, therefore using the Item row will eliminate
this.

3.      Tell customers to obtain a copy of Worldship because they list what the minimum
required fields are to import data.

Regards,

T. Taylor

Rising Star Ideas, LLC
9400 Snowden River Parkway Suite 230
Columbia, MD 21045
410-381-0810 x823 voice/fax
We reach for the STARS!!!
www.RisingStarIdeas.com


Installation

This module installs as a store utility module (and not as an Export module as you might expect).
To install the main module:
1. As with any module, there are two ways to upload the file to your server, through the Merchant mall's "add module" feature which lets you upload the file, or by putting hte file on the server yourself via ftp. If you want to ftp the module file (BROK_GENEXPORT.mv) to your server, do so now. For convenience, place it into the Merchant2/modules/util/ directory. Note that your Merchant scripts might NOT be installed in a directory called Merchant2/. Although most setups use this directory. If your's uses a different directory, make sure you put the module there
2. Enter into admin and expand >Modules in the left frame.
3. Click on the link to "Add Module"
4. In the right frame, you'll see a text entry field with an "upload module" button next to it. If you ftped the BROK_GENEXPORT.mv file to your server, enter the path to that file into the text field (usually modules/util/BROK_GENEXPORT.mv). Click on the "add" button. If you did not ftp the file to the server, click on the 'upload' icon next to the text entry field. This will pop up a small window. Enter the path to the file on your local computer or click on the "browse" button to browse your hard drive to find it. After you have the path in the text entry field click on the "upload" key. When you're back to the right frame, click on the "Add" button. After a short delay, you should see a notification that the module was installed and you will see it at the bottom of the list of installed modules in the left frame.
5. The module is now installed into your "mall". And being an export module, it is automatically available in your store.
6. Click on the >Utilities link under your store in admin. This will bring up a window in the right frame listing all of the store utility modules you have installed. Check the box next to the Generic Orders Export in the list and click on "update". You'll now have a new tab, "Generic Order Export".
To return to the top, click here

[mike@mikeworks.com]