WooCommerce Code Reference

RestApi

Class RestApi

This class handles the REST API endpoints for importing and exporting WooCommerce Blueprints.

Table of Contents

MAX_FILE_SIZE  = 52428800
Maximum allowed file size in bytes (50MB)
$namespace  : string
Endpoint namespace.
check_permission()  : bool|WP_Error
Check if the current user has permission to perform the request.
export()  : WP_HTTP_Response
Handle the export request.
get_import_step_response_schema()  : array<string|int, mixed>
Get the schema for the import-step endpoint.
get_process_response_schema()  : array<string|int, mixed>
Get the schema for the process endpoint.
get_queue_response_schema()  : array<string|int, mixed>
Get the schema for the queue endpoint.
import_step()  : array<string|int, mixed>
Import a single step.
register_routes()  : mixed
Register routes.
get_max_file_size()  : int
Get maximum allowed file size for blueprint uploads.
get_settings_to_overwrite()  : array<string|int, mixed>
Get list of settings that will be overridden by the import.
steps_payload_to_blueprint_steps()  : array<string|int, mixed>
Convert step list from the frontend to the backend format.

Constants

Properties

Methods

check_permission()

Check if the current user has permission to perform the request.

public check_permission() : bool|WP_Error
Return values
bool|WP_Error

export()

Handle the export request.

public export(WP_REST_Request $request) : WP_HTTP_Response
Parameters
$request : WP_REST_Request

The request object.

Return values
WP_HTTP_ResponseThe response object.

get_import_step_response_schema()

Get the schema for the import-step endpoint.

public get_import_step_response_schema() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_process_response_schema()

Get the schema for the process endpoint.

public get_process_response_schema() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_queue_response_schema()

Get the schema for the queue endpoint.

public get_queue_response_schema() : array<string|int, mixed>
Return values
array<string|int, mixed>

import_step()

Import a single step.

public import_step(WP_REST_Request $request) : array<string|int, mixed>
Parameters
$request : WP_REST_Request

The request object.

Return values
array<string|int, mixed>

get_max_file_size()

Get maximum allowed file size for blueprint uploads.

protected get_max_file_size() : int
Return values
intMaximum file size in bytes

get_settings_to_overwrite()

Get list of settings that will be overridden by the import.

private get_settings_to_overwrite(array<string|int, mixed> $requested_steps) : array<string|int, mixed>
Parameters
$requested_steps : array<string|int, mixed>

List of steps from the import schema.

Return values
array<string|int, mixed>List of settings that will be overridden.

steps_payload_to_blueprint_steps()

Convert step list from the frontend to the backend format.

private steps_payload_to_blueprint_steps(array<string|int, mixed> $steps) : array<string|int, mixed>

From: { "settings": ["setWCSettings", "setWCShippingZones", "setWCShippingMethods", "setWCShippingRates"], "plugins": ["akismet/akismet.php], "themes": ["approach], }

To:

["setWCSettings", "setWCShippingZones", "setWCShippingMethods", "setWCShippingRates", "installPlugin", "installTheme"]

Parameters
$steps : array<string|int, mixed>

steps payload from the frontend.

Return values
array<string|int, mixed>