WooCommerce::schedule_tracking_action
Schedule the action to send tracking events if tracking is enabled.
Method of the class: WooCommerce{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WooCommerce = new WooCommerce(); $WooCommerce->schedule_tracking_action();
WooCommerce::schedule_tracking_action() WooCommerce::schedule tracking action code WC 11.0.1
public function schedule_tracking_action() {
if ( false === wc_string_to_bool( get_option( 'woocommerce_allow_tracking', 'no' ) ) ) {
return;
}
/**
* How frequent to schedule the tracker send event.
*
* @since 2.3.0
* @param string $recurrence Recurrence as per wp_get_schedules.
*/
$tracker_recurrence = apply_filters( 'woocommerce_tracker_event_recurrence', 'daily' );
$tracker_recurrence = is_string( $tracker_recurrence ) ? $tracker_recurrence : 'daily';
$core_internals = wp_get_schedules();
$interval = $core_internals[ $tracker_recurrence ]['interval'] ?? DAY_IN_SECONDS;
as_schedule_recurring_action( time() + 10, $interval, 'woocommerce_tracker_send_event_wrapper', array(), 'woocommerce', true );
}