WordPress filter hook

woocommerce_rest_is_request_to_rest_api

Defined by WooCommerce and fired by 6 plugins in total, running on 7.3M+ sites between them.

“Filters whether the current request is a request to the WooCommerce REST API.”

How to use woocommerce_rest_is_request_to_rest_api

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_rest_is_request_to_rest_api', function( $value ) {
	// Change $value here.
	return $value;
}, 10, 1 );

Argument names come from Mailchimp for WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

6 plugins that fire woocommerce_rest_is_request_to_rest_api

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_rest_is_request_to_rest_api', $is_wc_route ) includes/class-wc-rest-authentication.php:97
  2. Mailchimp for WooCommerce icon Mailchimp for WooCommerce200,000+ installs apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party ) includes/class-mailchimp-woocommerce-service.php:1169
  3. WPML Multilingual & Multicurrency for WooCommerce icon WPML Multilingual & Multicurrency for WooCommerce100,000+ installs apply_filters( 'woocommerce_rest_is_request_to_rest_api', self::checkEndpoint( 'wc/v' . self::getApiRequestVersion() . '/' ) || self::isWooCommerceAbilityRequest() ) classes/Rest/Functions.php:19
  4. Vanquish Upload Files for WooCommerce icon Vanquish Upload Files for WooCommerce80+ installs apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party ) classes/com/globals.php:178
  5. MyStyle Custom Product Designer icon MyStyle Custom Product Designer60+ installs apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party ) includes/wprestapi/class-mystyle-wp-rest-api-authentication.php:66
  6. WooPOS Store Credit & Points icon WooPOS Store Credit & Points10+ installs apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party ) woopos_credit_points.php:130

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.