I’m having a problem figuring out what function gets called when a payment is completed with Woocommerce and PayPal sends the IPN.
The IPN is being received because PayPal log file is being updated as soon as I click Pay
, but I can’t figure out what function is writing to that file.
I need to figure out if there is already a built in functionality to send emails to the admin when an order is created, and where this happens.
If it does exist I need to modify it to email other people too, and if not then I need to create it myself, but I need to know where to put the code.
Checking the file
/wp-content/plugins/woocommerce/classes/gateways/paypal/class-wc-paypal.php
, we see that there’s an action hook inside the functioncheck_ipn_response
:You can hook into it like this:
Building on @brasofilo’s answer, I had to do extra work for each product for the current order.
Note: I’m new to (un)serializing data, so I don’t know why I had to unescape the double quotes to get
unserialize()
to work. It threw an error, otherwise. Maybe there’s a better way to handle this.