Ubercart Integration
Overview
The uc_xtuple_edi module (which is available in the xChange) allows you to export order and payment information from your Ubercart store into an XML file that is formatted for import into xTuple ERP.
The uc_xtuple_edi module gets almost all of its code from the uc_edi module, developed by Ryan Szama, the man behind Ubercart. We modified this module slightly to make it more capable of exporting xml. We're hoping that our changes will be incorporated back into the core uc_edi module, but if you want to use Ubercart and xTuple for now, you'll need to use the custom uc_xtuple_edi module, available in the xTuple xChange.
The settings below will allow you to import both order and sales or information from Ubercart into xTuple. The orders will be imported as Open Sales Orders, and the payments will be imported as Miscellaneous Credit Memos.
Prerequisites
To get Ubercart to generate an xml file in a format that xTuple can import, you'll need to have the following environment installed:
- Drupal 6.x
- Ubercart 2.x
- uc_xtuple_edi (6.x)
Ubercart Store Settings
You need to make sure that your store is setting the order to the correct status after the user completes his checkout process. To do this,
- Go to the Conditional Access configuration section at <mysite>/admin/store/ca.
- Find the action titled “Update order status upon checkout completion with full payment” and click “edit”
- Go to the Actions tab and find “Action: update the order status”
- Expand that section and make sure that the Argument is set to “Payment received”
This will set up Ubercart so that when a user completes a checkout (finishes a purchase), the order status will be set to Payment received. This is the status that the uc_xtuple_edi module uses to queue up orders for export.
All orders that are in “Payment received status” will be picked up and added to the export file when it is generated. Once the export file is generated, the uc_xtuple_edi module changes the order status to “Complete” for those orders. We chose to set them to Complete because we are selling digital downloads in our store. If you are selling shippable goods, on the other hand, you may want the uc_xtuple_edi module to set the status of exported orders to Ready for Shipping, and then update the status manually when the actual goods are shipped. If that is the case, then modify the setting for “Exported order status” below.
Configuring uc_xtuple_edi
Once you've installed the uc_xtuple_edi module and enabled it, go to <yoursite>/admin/store/settings/edi to access edi configuration page.

Leave the “Import settings” sections alone—we won't be using those for now. Expand the “Order export settings” section and enter the following settings:
| Export directory: | [Specify the directory on your web server where the module will place the exported file. This directory will need to be writable, so it should be a file outside of your web root] |
|
Export archive directory: |
[Specify the directory where the exported file will be moved when it is archived.] |
| Export file prefix: | [Enter a prefix to use for your exported order files. Leave blank for none.] |
| Export file extension: | xml |
|
Export frequency |
[Select the frequency at which automatic exports should occur.] |
| Ready for export order status: | Payment received |
| Exported order status: | Completed |
| Export order comment: | - |
| Order export prefix: | <?xml version="1.0"?> <!DOCTYPE xtupleimport SYSTEM "xtupleapi.dtd"> <xtupleimport> |
| Order export suffix: | </xtupleimport> |
| Order export pattern: | !_, <customer ignore="true">, !_, <customer_number quote="false">, !_, getCustNumberFromInfo(',!primary_email,',, !_, ',!billing_company,',, !_, ',!billing_first_name,',, !_, ',!billing_last_name,',, !_, ',!billing_name,',, !_, 'true'), !_, </customer_number>, !_, <customer_name quote="false">, !_, getCustNameFromInfo(',!primary_email,',, !_, ',!billing_company,',, !_, ',!billing_first_name,',, !_, ',!billing_last_name,',, !_, ',!billing_name,',, !_, 'true'), !_, </customer_name>, !_, <ship_via>Parcel Post</ship_via>, !_, <default_tax_authority>NONE</default_tax_authority>, !_, <default_currency>USD</default_currency>, !_, <billing_contact_first>,!billing_first_name,</billing_contact_first>, !_, <billing_contact_last>,!billing_last_name,</billing_contact_last>, !_, <billing_contact_voice>,!billing_phone,</billing_contact_voice>, !_, <billing_contact_email>,!primary_email,</billing_contact_email>, !_, <billing_contact_address1>,!billing_company,</billing_contact_address1>, !_, <billing_contact_address2>,!billing_street1,</billing_contact_address2>, !_, <billing_contact_address3>,!billing_street2,</billing_contact_address3>, !_, <billing_contact_city>,!billing_city,</billing_contact_city>, !_, <billing_contact_state>,!billing_zone_code,</billing_contact_state>, !_, <billing_contact_postalcode>,!billing_postal_code,</billing_contact_postalcode>, !_, <billing_contact_country>,!billing_country_name,</billing_contact_country>, !_, <billing_contact_address_change value="CHANGEALL"/>, !_, <correspond_contact_first>,!billing_first_name,</correspond_contact_first>, !_, <correspond_contact_last>,!billing_last_name,</correspond_contact_last>, !_, <correspond_contact_voice>,!billing_phone,</correspond_contact_voice>, !_, <correspond_contact_email>,!primary_email,</correspond_contact_email>, !_, <correspond_contact_address1>,!billing_company,</correspond_contact_address1>, !_, <correspond_contact_address2>,!billing_street1,</correspond_contact_address2>, !_, <correspond_contact_address3>,!billing_street2,</correspond_contact_address3>, !_, <correspond_contact_city>,!billing_city,</correspond_contact_city>, !_, <correspond_contact_state>,!billing_zone_code,</correspond_contact_state>, !_, <correspond_contact_postalcode>,!billing_postal_code,</correspond_contact_postalcode>, !_, <correspond_contact_country>,!billing_country_name,</correspond_contact_country>, !_, <notes></notes>, !_, </customer>, !_, <salesorder>, !_, <order_number>,!order_id,</order_number>, !_, <order_date>,!date(Y-m-d)(!created),</order_date>, !_, <originated_by value="Internet"/>, !_, <customer_number quote="false">, !_, getCustNumberFromInfo(',!primary_email,',, !_, ', !billing_company,',, !_, ', !billing_first_name,',, !_, ', !billing_last_name,',, !_, ', !billing_name,',, !_, 'true'), !_, </customer_number>, !_, <billto_name>,!billing_name,</billto_name>, !_, <billto_address1>,!billing_company,</billto_address1>, !_, <billto_address2>,!billing_street1,</billto_address2>, !_, <billto_address3>,!billing_street2,</billto_address3>, !_, <billto_city>,!billing_city,</billto_city>, !_, <billto_state>,!billing_zone_code,</billto_state>, !_, <billto_postal_code>,!billing_postal_code,</billto_postal_code>, !_, <billto_country>,!billing_country_name,</billto_country>, !_, <shipto_number quote="false">, !_, getShiptoNumberFromInfo(, !_, getCustNameFromInfo(',!primary_email,',, !_, ',!delivery_company,',, !_, ',!delivery_first_name,',, !_, ',!delivery_last_name,',, !_, ',!delivery_name,',, !_, 'false'), !_, ,, !_, '',, !_, '',, !_, ',!delivery_first_name,',, !_, ',!delivery_last_name,',, !_, ',!delivery_name,',, !_, ',!delivery_street1,',, !_, ',!delivery_street2,',, !_, NULL,, !_, ',!delivery_city,',, !_, ',!delivery_zone_code,',, !_, ',!delivery_postal_code,',, !_, ',!delivery_country_name,',, !_, true,, !_, true), !_, </shipto_number>, !_, <shipto_name>,!delivery_name,</shipto_name>, !_, <shipto_address1>,!delivery_street1,</shipto_address1>, !_, <shipto_address2>,!delivery_street2,</shipto_address2>, !_, <shipto_city>,!delivery_city,</shipto_city>, !_, <shipto_state>,!delivery_zone_code,</shipto_state>, !_, <shipto_postal_code>,!delivery_postal_code,</shipto_postal_code>, !_, <shipto_country>,!delivery_country_name,</shipto_country>, !_, <ship_via>Parcel Post</ship_via>, !_, <currency>USD</currency>, !_, <freight>,!uc_shipping_charges,</freight>, !_, <order_notes></order_notes>, !_, </salesorder>, !_, <armemo>, !_, <customer_number quote="false">, !_, getCustNumberFromInfo(',!primary_email,',, !_, ', !billing_company,',, !_, ', !billing_first_name,',, !_, ', !billing_last_name,',, !_, ', !billing_name,',, !_, 'true'), !_, </customer_number>, !_, <document_date>,!date(Y-m-d)(!created),</document_date>, !_, <due_date>,!date(Y-m-d)(!created),</due_date>, !_, <document_number quote="false">,fetcharmemonumber(),</document_number>, !_, <document_type>,Credit Memo,</document_type>, !_, <amount>,!order_total,</amount>, !_, <alternate_prepaid_account quote="false">,formatglaccount(104),</alternate_prepaid_account>,!_, </armemo>, !_, !products, !_, |
| Order product export pattern: | <salesline>, !_, <order_number>,!order_id,</order_number>, !_, <line_number>,!#,</line_number>, !_, <item_number>,!model,</item_number>, !_, <qty_ordered>,!qty,</qty_ordered>, !_, <net_unit_price>,!price,</net_unit_price>, !_, <scheduled_date quote="false">',!scheduled_date,'</scheduled_date>, !_, <notes></notes> </salesline> |
| Export pattern delimiter: | nothing |
Exporting a file from Ubercart
Once you have some orders placed on your store, you are ready to export them.
Go to <mysite>/admin/store/orders/edi to get to the EDI Import/Export page.

You can ignore the “Order import details” section for now.
You will see the list of order numbers for any orders that are in “Payment Received” status, meaning they are ready to be exported.
Click on the “Export Orders Now” button to generate the export file. It will be written to the export directory you specified on the configuration page.
You will probably need a mechanism to move the exported file from that directory to one where xTuple ERP can pick it up for importing. In our own implementation we wrote a script that checks the export directory for any files and move them to a directory on a different server, where we have our xTuple ERP database.
Configuring xTuple ERP to import the file
Set up xTuple to import Ubercart (UC) order xml files.
Create items in xTuple to match those in the online catalog.
xTuple Item Number = Ubercart SKU
System->Configure Modules->Sales, Uncheck “Use calculated freight values by default”
System > Configure Modules > Sales, change Sales Order# Generation to either "Automatic, Allow Override" or "Manual".
System > Master Information > Configure Data Import and Export
Pick directory where any xslt mapping files are stored (eg. The yahoo directory)
Follow the instructions for setting up an xslt processor for your system, available here: http://www.xtuple.org/YahooStoreIntegration
