2

I'm looking on an example of where I should place for Magento orders to be sent to a third-party API. I have all documentation and all proper code that I've tested. I just don't know where these API calls fit in.

How and where will it get triggered? Should it be a custom module? Event observer?

3

My first tought would go to creating my own extension with an observer for the checkout_submit_all_after event.

This event covers both front- and backend orders.

You can get your order object(s) like this in your observer:

    if ($observer->getEvent()->hasOrders()) {

               $orders = $observer->getEvent()->getOrders();

           } else {

               $orders[] = $observer->getEvent()->getOrder();

           }

           foreach ($orders as $order) {
           //call here
           }
}

I have also done a couple of ERP implementations where the client wanted a daily cron to sync the orders, the choise is up to you. In this case you will also create a custom extension that handles this.

0

Adding to Toon Van Dooren's answer, the observer for the event checkout_submit_all_after didn't work for paypal express checkouts so the event I needed to use was:

checkout_onepage_controller_success_action

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.