i added the cron job as the following and the action method called from the class which class is a custom payment gateway..
function cronJobSchedule() {
return array(
'in_per_minute' => array(
'interval' =>60,
'display' => 'In every custom Mintues'
)
);
}
/* Add Cron Job Event */
register_activation_hook(__FILE__,'registerCronJob');
//Schedule Cron Job Event-in_per_minute-every_minute
function registerCronJob() {
if ( ! wp_next_scheduled( 'cronPerMinutes' ) ) {
wp_schedule_event( time(), 'in_per_minute', 'cronPerMinutes' );
}
}
//trigger action based on period in minutes
add_action( 'cronPerMinutes',array('plugin_name','action') );
//remove schedule event on deactivate
register_deactivation_hook(__FILE__, 'unRegisterCronJob');
add_filter( 'cron_schedules','cronJobSchedule');
function unRegisterCronJob() {
wp_clear_scheduled_hook('cronPerMinutes');
}
and the action method in the class:
public function action()
{
$orderObj = new WC_Order(50);
$authenticationToken=$this->getAuthenticationToken();
$orderObj->add_order_note($authenticationToken);
}
the problem that i can’t call any method ($this->getAuthenticationToken()) in this action hook … it doesn’t work!! when i call any method.