I'm really frustrated right now, because I just can't seem to figure out what's wrong here. Maybe it's something really simple and I'm just stuck somewhere. Please help me out!
I'm working on a small plugin to add a payment reminder to WooCommerce. I added a wp_schedule_event(nd_payment_reminder) to the activation hook. This works so far.
In my main plugin file I'm including my class which looks a little like this:
class ND_Payment_Due extends WC_Email
{
public function __construct() {
parent::__construct();
add_action('nd_payment_reminder', array($this, 'getOpenOrders'));
}
public function getOpenOrders() {
// getting data and triggering the email
}
[...]
}
I'm using add_filter('woocommerce_email_classes', 'nd_add_payment_reminder_mails'); to instantiate the class like that:
function nd_add_payment_reminder_mails($email_classes)
{
require('inc/class-wc-payment-due.php');
$email_classes['ND_Payment_Due'] = new ND_Payment_Due();
return $email_classes;
}
add_filter('woocommerce_email_classes', 'nd_add_payment_reminder_mails');
Whatever I try, the function getOpenOrders seems not to be firing. I've originally used this tutorial to write this plugin:
https://www.ibenic.com/create-custom-woocommerce-email/
I've also used the same procedure on another site - and it works there!?
I even thought the getOpenOrders() might be faulty, but when I tried and used another simple function from within my class it's just not working. :-(
I was already told that it might be possible, that the filter I'm using is only fired when emails are handled. But then I'm confused why it actually works on a different site.
Any ideas would be highly appreciated! Thanks in advance!