We have a store setup using ExpressionEngine and Expresso Store, it's all working great however we now need to integrate with another system. This system imports information on orders, it's basically a CRM system, it required an XML file to be produced each time an order is processed, we've managed to produce an XML feed for these orders but unfortunatently it requires a seperate file for EACH order. This is the XML we produced:

<?xml version="1.0" encoding="UTF-8"?>
<Clarity xmlns="http://www.touchsystems.co.uk/schemas" Type="Order" DateTime="2011-04-04T17:58:41.000000" Source="Customer Website">

      <Address1>{billing_address1} {billing_address2}</Address1>
      <Country>United Kingdom</Country>
      <Title>Online Order REF {order_id}</Title>
      <Notes>Here are some example order notes</Notes>
        <Terms>Delivery within 30 days of payment</Terms>
        <Description>{title} {modifiers}{modifier_name} {modifier_value} {if price_mod_val}({price_mod}){/if}{/modifiers}</Description>
        <UnitPrice>{price} - {item_subtotal}</UnitPrice>

But we're not really sure how to go about generating a single XML file per order, will we need to do this with PHP or can ExpressionEngine handle this? Any ideas would be really appreciated!

2 Answers 2


Looks like you have working code to generate XML for multiple orders, and generating XML for a single order is easy by just including the order_hash or order_id parameter.

The only problem then is how to move these files into an FTP directory for your CRM. To do this you could either set up a nightly script to check for new orders and save their XML to a particular folder, or as Derek mentioned in the comments, you could use the store_order_complete_end hook to do this immediately after the order is saved.

  • Thanks Adrian, do you think we could potentially add a script to the order complete template that generates an XML file when the page is visited? Guessing this would need to be PHP? This page should only be accessed once an order is processed. Or would this method generally be frowned upon?
    – Nick
    Dec 17, 2013 at 12:42
  • You could. But it's a little unreliable (if the page is visited again it will keep generating new files). It's probably going to be about the same amount of work to keep the XML URL secret, and set up a simple extension which downloads that URL to a file on the server (or generate the XML straight from the extension, which would be better still but requires a little bit more experience with PHP). Dec 17, 2013 at 19:33
  • Thanks, we ended up building a custom extension for this
    – Nick
    Feb 24, 2014 at 10:58
  • Hi Nick, did your custom extension simply fetch the XML template and save the output to disk, or did it generate the XML itself as well? I'm looking for a solution that will do the former, but for CSV: expressionengine.stackexchange.com/questions/30358/…
    – Sandwich
    Mar 4, 2015 at 14:15

You could have an admin-only page where you list orders using store:orders, and have each link to the order detail via its order_hash.

{if count  == "1"}<ul>{/if}
    <li><a href="{path="orders/view/{order_hash}">Order #{order_id}</a></li>
{if count  == total_results}</ul>{/if}

Then orders/view looks like:

{exp:store:orders order_hash="{segment_3}"}
    // your XML template here

You'd want to add something like {if logged_in_member_group != "1"}{redirect="404"}{/if} to each page to make sure prying eyes could not see.

  • Thanks Derek, looks like a great solution. The issue we have is that the system we're syncing with requires physical XML files in an FTP directory so the site has to automatically generate one of these when an order is placed, would this be possible?
    – Nick
    Dec 16, 2013 at 14:30
  • 1
    Ah - trickier then. Have a look at the store_order_complete_end hook - you could write an extension which uses that hook, loads your template programatically, then saves the result on the server. Lots of steps to work out there though. Dec 16, 2013 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.