Automattic\WooCommerce\StoreApi

Authentication::opt_in_checkout_endpointpublicWC 1.0

Opt in to rate limiting for the checkout endpoint.

Метод класса: Authentication{}

Хуков нет.

Возвращает

\WP_Error|null|true|false.

Использование

$Authentication = new Authentication();
$Authentication->opt_in_checkout_endpoint( $result );
$result(WP_Error|разное) (обязательный)
Error from another authentication handler, null if we should handle it, or another value if not.

Код Authentication::opt_in_checkout_endpoint() WC 10.5.2

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;
}