Automattic\WooCommerce\StoreApi
Authentication::opt_in_checkout_endpoint
Opt in to rate limiting for the checkout endpoint.
Method of the class: Authentication{}
No Hooks.
Returns
\WP_Error|null|true|false.
Usage
$Authentication = new Authentication(); $Authentication->opt_in_checkout_endpoint( $result );
- $result(WP_Error|mixed) (required)
- Error from another authentication handler, null if we should handle it, or another value if not.
Authentication::opt_in_checkout_endpoint() Authentication::opt in checkout endpoint code WC 10.7.0
public function opt_in_checkout_endpoint( $result ) {
if (
FeaturesUtil::feature_is_enabled( 'rate_limit_checkout' )
&& $this->is_request_to_store_api()
&& preg_match( '#/wc/store(?:/v\d+)?/checkout#', $GLOBALS['wp']->query_vars['rest_route'] )
&& $this->is_only_post_request()
) {
add_filter(
'woocommerce_store_api_rate_limit_options',
function ( $options ) {
$options['enabled'] = true;
$options['limit'] = 3;
$options['seconds'] = 60;
return $options;
},
1,
1
);
}
return $result;
}