'business_choice' => array(
'description' => __( 'Business choice.', 'woocommerce' ),
'context' => array( 'view' ),
'selling_online_answer' => array(
'description' => __( 'Selling online answer.', 'woocommerce' ),
'context' => array( 'view' ),
'selling_platforms' => array(
'type' => array( 'array', 'null' ),
'description' => __( 'Selling platforms.', 'woocommerce' ),
'context' => array( 'view' ),
'type' => array( 'string', 'null' ),
* Filters the Onboarding Profile REST API JSON Schema.
* @param array $properties List of properties.
return apply_filters( 'woocommerce_rest_onboarding_profile_properties', $properties );
* Optionally validates email if user agreed to marketing or if email is not empty.
* @param mixed $value Email value.
* @param WP_REST_Request $request Request object.
* @param string $param Parameter name.
public static function rest_validate_marketing_email( $value, $request, $param ) {
$is_agree_marketing = $request->get_param( 'is_agree_marketing' );
( $is_agree_marketing || ! empty( $value ) ) &&
return new \WP_Error( 'rest_invalid_email', __( 'Invalid email address', 'woocommerce' ) );
* Get the schema, conforming to JSON Schema.
public function get_item_schema() {
// Unset properties used for collection params.
$properties = self::get_profile_properties();
foreach ( $properties as $key => $property ) {
unset( $properties[ $key ]['default'] );
unset( $properties[ $key ]['items'] );
unset( $properties[ $key ]['validate_callback'] );
unset( $properties[ $key ]['sanitize_callback'] );
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'onboarding_profile',
'properties' => $properties,
return $this->add_additional_fields_schema( $schema );
* Get the query params for collections.
public function get_collection_params() {
// Unset properties used for item schema.
$params = self::get_profile_properties();
foreach ( $params as $key => $param ) {
unset( $params[ $key ]['context'] );
unset( $params[ $key ]['readonly'] );
$params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
* Filters the Onboarding Profile REST API collection parameters.
* @param array $params Collection parameters.
return apply_filters( 'woocommerce_rest_onboarding_profile_collection_params', $params );