Requirements
- CSVI Pro 4.5+
- VirtueMart 2.0.10+
Background information
The advanced order export makes it possible to export XML files with a complex structure that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<orders xmlns="urn:orders-schema">
<order>
<customer>
<name>Shipping name</name>
<contactperson>Shipping name</contactperson>
<address>Shipping address</address>
<zip>Shipping zip</zip>
<city>Shipping city</city>
<country>Shipping country</country>
<billtoname>Bill to name</billtoname>
<billtoaddress>Bill to address></billtoaddress>
<billtozip>Bill to zip</billtozip>
<billtocity>Bill to city</billtocity>
<billtocountry>Bill to country</billtocountry>
<phone>0123456789</phone>
<mobilephone>0123456789</mobilephone>
<fax>9876543210</fax>
<email>This email address is being protected from spambots. You need JavaScript enabled to view it.</email>
<website>www.example.com</website>
<taxnumber></taxnumber>
<chamberofcommerce></chamberofcommerce>
</customer>
<orderdate>2013-05-01</orderdate>
<orderdescription>Webshop order 25874</orderdescription>
<ordernumber>ab12345</ordernumber>
<note>Deliver it fast</note>
<orderlines>
<orderline>
<code>H01</code>
<description>Wooden hammer</description>
<qty>1</qty>
<price>14.95</price>
</orderline>
<orderline>
<code>P01</code>
<description>Power product</description>
<qty>3</qty>
<price>12.45</price>
</orderline>
</orderlines>
</order>
</orders>
These structures are most often used for exporting orders to external sources like a fullfilment company for example.
Preparing the template
The template is the same as any other template except you must setup the layout for CSVI to use for your export. The layout consists of four parts:
- Header
- Order
- Order line
- Footer
We are going to use the layout as shown at the intro as example here.
Header
The header is the start of the XML file and contains the opening node for the whole XML file. In our example that is <orders xmlns="urn:orders-schema">.
<?xml version="1.0" encoding="UTF-8"?>
<orders xmlns="urn:orders-schema">
Order
The order part is the complete node of the order and this part is repeated for every order that gets exported. There is a special tag inside the order and is called [orderlines]. This tag will be replaced by the Order line section.
<order>
<customer>
<name>[shipping_full_name]</name>
<contactperson>[shipping_full_name]</contactperson>
<address>[shipping_address_1]</address>
<zip>[shipping_zip]</zip>
<city>[shipping_city]</city>
<country>[shipping_country_2_code]</country>
<billtoname>[full_name]</billtoname>
<billtoaddress>[address_1]></billtoaddress>
<billtozip>[zip]</billtozip>
<billtocity>[city]</billtocity>
<billtocountry>[country_2_code]</billtocountry>
<phone>[phone_1]</phone>
<mobilephone>[phone_2]</mobilephone>
<fax>[fax]</fax>
<email>[email]</email>
<website></website>
<taxnumber></taxnumber>
<chamberofcommerce></chamberofcommerce>
</customer>
<orderdate>[created_on]</orderdate>
<orderdescription>Webshop order [order_number]</orderdescription>
<ordernumber>[order_number]</ordernumber>
<note>[customer_note]</note>
<orderlines>
[orderlines]
</orderlines>
</order>
Order line
This section contains all the products that belong to the order. This part is repeated as many times as there are products in the order, once all the products are collected the order lines are injected in the Order part where the tag [orderlines] is set.
<orderline>
<code>[order_item_sku]</code>
<description>[order_item_name]</description>
<qty>[product_quantity]</qty>
<price>[product_item_price]</price>
</orderline>
Footer
The footer closes the XML
</orders>
Exporting the template
To export the order XML it works the same way as a regular order export, once you have assigned the fields to the template and set your options, click on Process to export the orders.