1

So, at the end of the checkout process (where it becomes an order) I want to fire off an SQL query wrapped inside AJW export (which creates an xml file).

However, within the confines of ExpressionEngine and Expresso respectively how precisely would I do this?

The idea would be:

User hits submit --> No Errors --> Turn into order --> Fire off AJE\SQL XML --> Redirect user to whatever page.

I'm guessing I'd use a hook or something like this, right?

store_order_complete_start

Any suggestions for how this might be most suitably accomplished? The documentation is kind of thin when it comes to this stuff.

On the other hand, would it be possible for me to put the code in a template and do a 'next' on the checkout tag instead of 'return' so when the user hits "confirm" it takes them to a template with the code, which automatically creates the order and returns them to a page with the hash?

If I'm over thinking this, I'm totally open to any solution that proves to be simpler\superior.

Edit: Have this figured out. Wrapped the PHP\AJE code inside a javascript function and had an even listener tied to the checkout submit button. Seems to be working just fine!

Edit: No, this won't work. Because it hasn't been put into the database by the time this script executes...

2

I think either method would work.

The hook is going to be the more nerdy (read "hard") way to do it. I use the store_order_complete_end hook to trigger code that notifies other systems of the order. Depend ing on how AJW Export is written, you may be able to fire it off from your code in the extension.

The easier approach would be to do it in the template. You can set your return parameter on the checkout tag to return="cart/confirmation/ORDER_HASH" (obviously using your template group and name).

On the confirmation template you could just fire off a plugin, which will have access to the hash in the URL to find the order and do whatever DB queries you need done.

2

I recently made an extension to do this, so I've put it up on GitHub for others to learn from.

https://github.com/expressodev/store_order_export

Generally, you want to use the store_order_complete_end hook, which runs when an order is marked as "complete" (when payment is successful). From there it is easy to write an extension which generates any XML (or other reporting format) necessary. The example extension should easily be modified to suit your particular needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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