• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WooCommerce a2z

WooCommerce a2z

WooCommerce

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WC_Tracker::send_tracking_data() – Decide whether to send tracking data or not.

You appear to be a bot. Output may be restricted

Description

Decide whether to send tracking data or not.

Usage

WC_Tracker::send_tracking_data( $override );

Parameters

$override
( boolean ) optional – Should override?.

Returns

void

Source

File name: woocommerce/includes/class-wc-tracker.php
Lines:

1 to 38 of 38
  public static function send_tracking_data( $override = false ) {
    // Don't trigger this on AJAX Requests.
    if ( Constants::is_true( 'DOING_AJAX' ) ) {
      return;
    }

    if ( ! apply_filters( 'woocommerce_tracker_send_override', $override ) ) {
      // Send a maximum of once per week by default.
      $last_send = self::get_last_send_time();
      if ( $last_send && $last_send > apply_filters( 'woocommerce_tracker_last_send_interval', strtotime( '-1 week' ) ) ) {
        return;
      }
    } else {
      // Make sure there is at least a 1 hour delay between override sends, we don't want duplicate calls due to double clicking links.
      $last_send = self::get_last_send_time();
      if ( $last_send && $last_send > strtotime( '-1 hours' ) ) {
        return;
      }
    }

    // Update time first before sending to ensure it is set.
    update_option( 'woocommerce_tracker_last_send', time() );

    $params = self::get_tracking_data();
    wp_safe_remote_post(
      self::$api_url,
      array(
        'method'      => 'POST',
        'timeout'     => 45,
        'redirection' => 5,
        'httpversion' => '1.0',
        'blocking'    => false,
        'headers'     => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url_raw( home_url( '/' ) ) ) . ';' ),
        'body'        => wp_json_encode( $params ),
        'cookies'     => array(),
      )
    );
  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 6th April 2020

Primary Sidebar

Information

Function name: WC_Tracker::send_tracking_data
Class ref: WC_Tracker
Plugin ref: WooCommerce
Version: 4.8.0
Sourcefile: includes/class-wc-tracker.php
File ref: includes/class-wc-tracker.php
Deprecated?: No
API Letters: D,S,T,W

Footer

WooCommerce a2z
WooCommerce a2z
WooCommerce
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites