WordPress filter hook
woocommerce_is_rest_api_request
Defined by WooCommerce and fired by 7 plugins in total, running on 7.4M+ sites between them.
“Whether this is a REST API request.”
How to use woocommerce_is_rest_api_request
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:
add_filter( 'woocommerce_is_rest_api_request', function( $is_rest_api_request ) {
// Change $is_rest_api_request here.
return $is_rest_api_request;
}, 10, 1 );Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
7 plugins that fire woocommerce_is_rest_api_request
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )includes/class-woocommerce.php:674 -
Meta for WooCommerce400,000+ installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )includes/Framework/Helper.php:413 -
Booster for WooCommerce30,000+ installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )includes/functions/wcj-functions-general.php:1092 -
Discount Rules and Dynamic Pricing for WooCommerce9,000+ installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )includes/helpers/class-wccs-helpers.php:287 -
CommerceBird400+ installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )vendor-prefixed/woocommerce-b2b/includes/classes/class-wcb2b.php:320 -
Subscriptions & Recurring Payments for WooCommerce10+ installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )inc/inependent-functions/awc-compatibility-functions.php:517 -
OminiFlow for WooCommerceFewer than 10 installs
apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request )includes/Framework/Helper.php:406
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.