Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZoneMethod

Controller::check_permissionspublicWC 1.0

Check if a given request has permission to manage shipping methods.

Method of the class: Controller{}

No Hooks.

Returns

true|WP_Error. True if the request has permission, WP_Error otherwise.

Usage

$Controller = new Controller();
$Controller->check_permissions( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Controller::check_permissions() code WC 10.4.3

public function check_permissions( $request ) {
	if ( ! wc_shipping_enabled() ) {
		return new WP_Error(
			'rest_shipping_disabled',
			__( 'Shipping is disabled.', 'woocommerce' ),
			array( 'status' => WP_Http::SERVICE_UNAVAILABLE )
		);
	}

	if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
		return $this->get_authentication_error_by_method( $request->get_method() );
	}

	return true;
}