1

I'm am improving Magento plugin that my friend wrote and I need to add a logic where I check each order and if the total sum is less than x then get this order details like total amount, name, address, phone number etc. And with these order details create XML and send out this XML to an external provider. At the same time send out to the customer the invoice and add to order comments in admin panel with some text like order placed from external provider. And do this only if the order total sum is less or equals than x.

I haven't done plugin from scratch myself, but the current plugin is made by a friend who due to some reasons can't continue and help me with that then I need to make it myself. What my current knowledge is that I know how to make additional tabs and fields in Admin -> Configuration. So there I currently have set up the field enable/disable the plugin and a text field make order from an external provider if the sum is less than x.

What I'm unfamiliar is how to observe all the going through orders? And get out the order total amount from that as well as order details I stated above. Also, I need to change the order status to processing and add a comment with my text. I guess the XML creation and sending out to the external provider is standard PHP task (use Varien/Zend in Magento) and is not related to Magento architecture.

Any tutorials for that, examples or your hints would be appreciated. I don't really want to dive deep into Magento architecture and read whole books, but just need to get this done. I tried to google about that but didn't get any good examples/tutorials maybe cause I don't write the problem in better Magento architecture/terms.

2

I guess in this case you would want to observe the invoice to create an event to make sure an order is paid. The event is called sales_order_invoice_save_after.

This Magento wiki page tells you how to implement a simple observer from a custom extension. In your case the $observer variable will most likely contain the order by calling ->getOrder(). I suggest printing the getData() method of that order to see what data you can get from there.

On how to build a custom extension please check this link. I find that it outlines how to go about it pretty well.

As the question you've posted is very broad I suggest starting on building your extension and posting more direct questions if you need help later on.

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.