Merge pull request #27248 from woocommerce/fix/api-textdomain
Changed textdomain since API is merged into core now.
This commit is contained in:
commit
49a9ab4437
|
@ -67,7 +67,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'permission_callback' => array( $this, 'create_item_permissions_check' ),
|
||||
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
|
||||
'code' => array(
|
||||
'description' => __( 'Coupon code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon code.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
),
|
||||
|
@ -79,7 +79,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -105,7 +105,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -250,7 +250,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
// Validate required POST fields.
|
||||
if ( 'POST' === $request->get_method() && 0 === $coupon->get_id() ) {
|
||||
if ( empty( $request['code'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce-rest-api' ), 'code' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce' ), 'code' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
$id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id );
|
||||
|
||||
if ( $id_from_code ) {
|
||||
return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$coupon->set_code( $coupon_code );
|
||||
|
@ -307,7 +307,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$coupon_id = $this->save_coupon( $request );
|
||||
|
@ -348,7 +348,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
$post_id = (int) $request['id'];
|
||||
|
||||
if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$coupon_id = $this->save_coupon( $request );
|
||||
|
@ -412,64 +412,64 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the object.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'code' => array(
|
||||
'description' => __( 'Coupon code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Coupon description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'discount_type' => array(
|
||||
'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'fixed_cart',
|
||||
'enum' => array_keys( wc_get_coupon_types() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'amount' => array(
|
||||
'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'expiry_date' => array(
|
||||
'description' => __( 'UTC DateTime when the coupon expires.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'UTC DateTime when the coupon expires.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'usage_count' => array(
|
||||
'description' => __( 'Number of times the coupon has been used already.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of times the coupon has been used already.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'individual_use' => array(
|
||||
'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'product_ids' => array(
|
||||
'description' => __( "List of product IDs the coupon can be used on.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "List of product IDs the coupon can be used on.", 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -477,7 +477,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'exclude_product_ids' => array(
|
||||
'description' => __( "List of product IDs the coupon cannot be used on.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "List of product IDs the coupon cannot be used on.", 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -485,28 +485,28 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'usage_limit' => array(
|
||||
'description' => __( 'How many times the coupon can be used in total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'How many times the coupon can be used in total.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'usage_limit_per_user' => array(
|
||||
'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'limit_usage_to_x_items' => array(
|
||||
'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'free_shipping' => array(
|
||||
'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'product_categories' => array(
|
||||
'description' => __( "List of category IDs the coupon applies to.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "List of category IDs the coupon applies to.", 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -514,7 +514,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'excluded_product_categories' => array(
|
||||
'description' => __( "List of category IDs the coupon does not apply to.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "List of category IDs the coupon does not apply to.", 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -522,23 +522,23 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'exclude_sale_items' => array(
|
||||
'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'minimum_amount' => array(
|
||||
'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'maximum_amount' => array(
|
||||
'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email_restrictions' => array(
|
||||
'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
|
@ -546,7 +546,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'used_by' => array(
|
||||
'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -569,7 +569,7 @@ class WC_REST_Coupons_V1_Controller extends WC_REST_Posts_Controller {
|
|||
$params = parent::get_collection_params();
|
||||
|
||||
$params['code'] = array(
|
||||
'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
|
|
@ -43,7 +43,7 @@ class WC_REST_Customer_Downloads_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'customer_id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -67,11 +67,11 @@ class WC_REST_Customer_Downloads_V1_Controller extends WC_REST_Controller {
|
|||
$customer = get_user_by( 'id', (int) $request['customer_id'] );
|
||||
|
||||
if ( ! $customer ) {
|
||||
return new WP_Error( 'woocommerce_rest_customer_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_customer_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_user_permissions( 'read', $customer->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -166,67 +166,67 @@ class WC_REST_Customer_Downloads_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'download_url' => array(
|
||||
'description' => __( 'Download file URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Download file URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'download_id' => array(
|
||||
'description' => __( 'Download ID (MD5).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Download ID (MD5).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Downloadable product ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Downloadable product ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'download_name' => array(
|
||||
'description' => __( 'Downloadable file name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Downloadable file name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'order_id' => array(
|
||||
'description' => __( 'Order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'order_key' => array(
|
||||
'description' => __( 'Order key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'downloads_remaining' => array(
|
||||
'description' => __( 'Number of downloads remaining.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of downloads remaining.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'access_expires' => array(
|
||||
'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File details.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File details.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'name' => array(
|
||||
'description' => __( 'File name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -55,16 +55,16 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
'email' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'New user email address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'New user email address.', 'woocommerce' ),
|
||||
),
|
||||
'username' => array(
|
||||
'required' => 'no' === get_option( 'woocommerce_registration_generate_username', 'yes' ),
|
||||
'description' => __( 'New user username.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'New user username.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
'password' => array(
|
||||
'required' => 'no' === get_option( 'woocommerce_registration_generate_password', 'no' ),
|
||||
'description' => __( 'New user password.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'New user password.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
) ),
|
||||
|
@ -75,7 +75,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -101,12 +101,12 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
'reassign' => array(
|
||||
'default' => 0,
|
||||
'type' => 'integer',
|
||||
'description' => __( 'ID to reassign posts to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ID to reassign posts to.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -132,7 +132,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_user_permissions( 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -147,7 +147,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_user_permissions( 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -163,7 +163,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$id = (int) $request['id'];
|
||||
|
||||
if ( ! wc_rest_check_user_permissions( 'read', $id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -180,7 +180,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$id = (int) $request['id'];
|
||||
|
||||
if ( ! wc_rest_check_user_permissions( 'edit', $id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -197,7 +197,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$id = (int) $request['id'];
|
||||
|
||||
if ( ! wc_rest_check_user_permissions( 'delete', $id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -212,7 +212,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_user_permissions( 'batch' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -324,7 +324,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
public function create_item( $request ) {
|
||||
try {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_customer_exists', __( 'Cannot create existing resource.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_customer_exists', __( 'Cannot create existing resource.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Sets the username.
|
||||
|
@ -342,7 +342,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$customer->save();
|
||||
|
||||
if ( ! $customer->get_id() ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_cannot_create', __( 'This resource cannot be created.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_cannot_create', __( 'This resource cannot be created.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
$user_data = get_userdata( $customer->get_id() );
|
||||
|
@ -380,7 +380,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$user_data = get_userdata( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $user_data->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$customer = $this->prepare_item_for_response( $user_data, $request );
|
||||
|
@ -401,15 +401,15 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$customer = new WC_Customer( $id );
|
||||
|
||||
if ( ! $customer->get_id() ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['email'] ) && email_exists( $request['email'] ) && $request['email'] !== $customer->get_email() ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_customer_invalid_email', __( 'Email address is invalid.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_customer_invalid_email', __( 'Email address is invalid.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['username'] ) && $request['username'] !== $customer->get_username() ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_customer_invalid_argument', __( "Username isn't editable.", 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_customer_invalid_argument', __( "Username isn't editable.", 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Customer email.
|
||||
|
@ -463,17 +463,17 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Customers do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Customers do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$user_data = get_userdata( $id );
|
||||
if ( ! $user_data ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $reassign ) ) {
|
||||
if ( $reassign === $id || ! get_userdata( $reassign ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_customer_invalid_reassign', __( 'Invalid resource id for reassignment.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_customer_invalid_reassign', __( 'Invalid resource id for reassignment.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $result ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -629,31 +629,31 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( 'The date the customer was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the customer was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'The email address for the customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The email address for the customer.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'first_name' => array(
|
||||
'description' => __( 'Customer first name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer first name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -661,7 +661,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Customer last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -669,7 +669,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'username' => array(
|
||||
'description' => __( 'Customer login name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer login name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -677,24 +677,24 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'password' => array(
|
||||
'description' => __( 'Customer password.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer password.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'last_order' => array(
|
||||
'description' => __( 'Last order data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last order data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Last order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date' => array(
|
||||
'description' => __( 'The date of the customer last order, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date of the customer last order, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -702,133 +702,133 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'orders_count' => array(
|
||||
'description' => __( 'Quantity of orders made by the customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Quantity of orders made by the customer.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_spent' => array(
|
||||
'description' => __( 'Total amount spent.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total amount spent.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'avatar_url' => array(
|
||||
'description' => __( 'Avatar URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Avatar URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'billing' => array(
|
||||
'description' => __( 'List of billing address data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of billing address data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'Email address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Email address.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'phone' => array(
|
||||
'description' => __( 'Phone number.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Phone number.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping' => array(
|
||||
'description' => __( 'List of shipping address data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of shipping address data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -862,7 +862,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -871,7 +871,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -880,14 +880,14 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['order'] = array(
|
||||
'default' => 'asc',
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'type' => 'string',
|
||||
|
@ -895,7 +895,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
);
|
||||
$params['orderby'] = array(
|
||||
'default' => 'name',
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
|
||||
'enum' => array(
|
||||
'id',
|
||||
'include',
|
||||
|
@ -907,13 +907,13 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['email'] = array(
|
||||
'description' => __( 'Limit result set to resources with a specific email.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources with a specific email.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['role'] = array(
|
||||
'description' => __( 'Limit result set to resources with a specific role.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources with a specific role.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'customer',
|
||||
'enum' => array_merge( array( 'all' ), $this->get_role_names() ),
|
||||
|
|
|
@ -50,7 +50,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'order_id' => array(
|
||||
'description' => __( 'The order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -67,7 +67,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
|
||||
'note' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Order note content.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order note content.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
),
|
||||
) ),
|
||||
|
@ -78,11 +78,11 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'order_id' => array(
|
||||
'description' => __( 'The order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -102,7 +102,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -118,7 +118,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -133,7 +133,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -149,7 +149,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( $order && ! wc_rest_check_post_permissions( $this->post_type, 'read', $order->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -166,7 +166,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( $order && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $order->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -183,7 +183,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order || $this->post_type !== $order->get_type() ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
|
@ -217,20 +217,20 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order || $this->post_type !== $order->get_type() ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
// Create the note.
|
||||
$note_id = $order->add_order_note( $request['note'], $request['customer_note'] );
|
||||
|
||||
if ( ! $note_id ) {
|
||||
return new WP_Error( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
$note = get_comment( $note_id );
|
||||
|
@ -265,13 +265,13 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order || $this->post_type !== $order->get_type() ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$note = get_comment( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$order_note = $this->prepare_item_for_response( $note, $request );
|
||||
|
@ -292,19 +292,19 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Webhooks do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Webhooks do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order || $this->post_type !== $order->get_type() ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$note = get_comment( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -313,7 +313,7 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
$result = wc_delete_order_note( $note->comment_ID );
|
||||
|
||||
if ( ! $result ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce-rest-api' ), 'order_note' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), 'order_note' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,24 +398,24 @@ class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'note' => array(
|
||||
'description' => __( 'Order note.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order note.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'customer_note' => array(
|
||||
'description' => __( 'Shows/define if the note is only for reference or for the customer (the user will be notified).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows/define if the note is only for reference or for the customer (the user will be notified).', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
|
|
|
@ -58,7 +58,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'order_id' => array(
|
||||
'description' => __( 'The order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -80,11 +80,11 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'order_id' => array(
|
||||
'description' => __( 'The order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -104,7 +104,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
'force' => array(
|
||||
'default' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -124,13 +124,13 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
|
||||
}
|
||||
|
||||
$refund = wc_get_order( $post );
|
||||
|
||||
if ( ! $refund || $refund->get_parent_id() !== $order->get_id() ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce-rest-api' ), 404 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 404 );
|
||||
}
|
||||
|
||||
$dp = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] );
|
||||
|
@ -278,17 +278,17 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$order_data = get_post( (int) $request['order_id'] );
|
||||
|
||||
if ( empty( $order_data ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order', __( 'Order is invalid', 'woocommerce-rest-api' ), 400 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order', __( 'Order is invalid', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
if ( 0 > $request['amount'] ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Create the refund.
|
||||
|
@ -305,7 +305,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
}
|
||||
|
||||
if ( ! $refund ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce-rest-api' ), 500 );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 );
|
||||
}
|
||||
|
||||
$post = get_post( $refund->get_id() );
|
||||
|
@ -341,29 +341,29 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'amount' => array(
|
||||
'description' => __( 'Refund amount.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Refund amount.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'reason' => array(
|
||||
'description' => __( 'Reason for refund.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reason for refund.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'line_items' => array(
|
||||
'description' => __( 'Line items data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line items data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -371,79 +371,79 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Product SKU.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product SKU.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Product ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product ID.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'variation_id' => array(
|
||||
'description' => __( 'Variation ID, if applicable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation ID, if applicable.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'quantity' => array(
|
||||
'description' => __( 'Quantity ordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Quantity ordered.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class of product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class of product.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Product price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Line subtotal (before discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal_tax' => array(
|
||||
'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'taxes' => array(
|
||||
'description' => __( 'Line taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line taxes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -451,19 +451,19 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Tax total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -472,7 +472,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
),
|
||||
),
|
||||
'meta' => array(
|
||||
'description' => __( 'Line item meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line item meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -480,19 +480,19 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'Meta label.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta label.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -519,7 +519,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
|
|||
|
||||
$params['dp'] = array(
|
||||
'default' => wc_get_price_decimals(),
|
||||
'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
|
|
@ -73,7 +73,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -99,7 +99,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -531,7 +531,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
try {
|
||||
// Make sure customer exists.
|
||||
if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Make sure customer is part of blog.
|
||||
|
@ -620,7 +620,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
} elseif ( 'update' === $action ) {
|
||||
$product_id = 0;
|
||||
} else {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 );
|
||||
}
|
||||
return $product_id;
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
if ( 'create' === $action ) {
|
||||
if ( empty( $posted['method_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
if ( 'create' === $action ) {
|
||||
if ( empty( $posted['name'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
if ( 'create' === $action ) {
|
||||
if ( empty( $posted['code'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
absint( $order->get_id() )
|
||||
) );
|
||||
if ( is_null( $result ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$order_id = $this->create_order( $request );
|
||||
|
@ -864,7 +864,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
$post_id = (int) $request['id'];
|
||||
|
||||
if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$order_id = $this->update_order( $request );
|
||||
|
@ -918,236 +918,236 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'parent_id' => array(
|
||||
'description' => __( 'Parent order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Parent order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Order status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'pending',
|
||||
'enum' => $this->get_order_statuses(),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'order_key' => array(
|
||||
'description' => __( 'Order key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'number' => array(
|
||||
'description' => __( 'Order number.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order number.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'currency' => array(
|
||||
'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => get_woocommerce_currency(),
|
||||
'enum' => array_keys( get_woocommerce_currencies() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'version' => array(
|
||||
'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'prices_include_tax' => array(
|
||||
'description' => __( 'True the prices included tax during checkout.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the order was created, as GMT.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order was created, as GMT.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the order was last modified, as GMT.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order was last modified, as GMT.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'customer_id' => array(
|
||||
'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => 0,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'discount_total' => array(
|
||||
'description' => __( 'Total discount amount for the order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total discount amount for the order.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'discount_tax' => array(
|
||||
'description' => __( 'Total discount tax amount for the order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_total' => array(
|
||||
'description' => __( 'Total shipping amount for the order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total shipping amount for the order.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_tax' => array(
|
||||
'description' => __( 'Total shipping tax amount for the order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'cart_tax' => array(
|
||||
'description' => __( 'Sum of line item taxes only.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sum of line item taxes only.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Grand total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Grand total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Sum of all taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sum of all taxes.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'billing' => array(
|
||||
'description' => __( 'Billing address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Billing address.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'Email address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Email address.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'phone' => array(
|
||||
'description' => __( 'Phone number.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Phone number.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping' => array(
|
||||
'description' => __( 'Shipping address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping address.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'payment_method' => array(
|
||||
'description' => __( 'Payment method ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment method ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'payment_method_title' => array(
|
||||
'description' => __( 'Payment method title.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment method title.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -1155,131 +1155,131 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'set_paid' => array(
|
||||
'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'transaction_id' => array(
|
||||
'description' => __( 'Unique transaction ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique transaction ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'customer_ip_address' => array(
|
||||
'description' => __( "Customer's IP address.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Customer's IP address.", 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'customer_user_agent' => array(
|
||||
'description' => __( 'User agent of the customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'User agent of the customer.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'created_via' => array(
|
||||
'description' => __( 'Shows where the order was created.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows where the order was created.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'customer_note' => array(
|
||||
'description' => __( 'Note left by customer during checkout.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Note left by customer during checkout.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_completed' => array(
|
||||
'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_paid' => array(
|
||||
'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'cart_hash' => array(
|
||||
'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'line_items' => array(
|
||||
'description' => __( 'Line items data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line items data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Product SKU.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product SKU.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Product ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product ID.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'variation_id' => array(
|
||||
'description' => __( 'Variation ID, if applicable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation ID, if applicable.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'quantity' => array(
|
||||
'description' => __( 'Quantity ordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Quantity ordered.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class of product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class of product.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Product price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Line subtotal (before discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'subtotal_tax' => array(
|
||||
'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'taxes' => array(
|
||||
'description' => __( 'Line taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line taxes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1287,19 +1287,19 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Tax total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1308,7 +1308,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'meta' => array(
|
||||
'description' => __( 'Line item meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line item meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1316,19 +1316,19 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'Meta label.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta label.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1340,7 +1340,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'tax_lines' => array(
|
||||
'description' => __( 'Tax lines data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax lines data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1348,43 +1348,43 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'rate_code' => array(
|
||||
'description' => __( 'Tax rate code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'rate_id' => array(
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'Tax rate label.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate label.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'compound' => array(
|
||||
'description' => __( 'Show if is a compound tax rate.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'tax_total' => array(
|
||||
'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_tax_total' => array(
|
||||
'description' => __( 'Shipping tax total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping tax total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1393,41 +1393,41 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'shipping_lines' => array(
|
||||
'description' => __( 'Shipping lines data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping lines data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'method_title' => array(
|
||||
'description' => __( 'Shipping method name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method name.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'method_id' => array(
|
||||
'description' => __( 'Shipping method ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method ID.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'taxes' => array(
|
||||
'description' => __( 'Line taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line taxes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1435,13 +1435,13 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Tax total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1453,46 +1453,46 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'fee_lines' => array(
|
||||
'description' => __( 'Fee lines data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Fee lines data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Fee name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Fee name.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class of fee.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class of fee.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_status' => array(
|
||||
'description' => __( 'Tax status of fee.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax status of fee.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'enum' => array( 'taxable', 'none' ),
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'taxes' => array(
|
||||
'description' => __( 'Line taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line taxes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1500,19 +1500,19 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Tax total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1524,30 +1524,30 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'coupon_lines' => array(
|
||||
'description' => __( 'Coupons line data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupons line data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'code' => array(
|
||||
'description' => __( 'Coupon code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon code.', 'woocommerce' ),
|
||||
'type' => 'mixed',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'discount' => array(
|
||||
'description' => __( 'Discount total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Discount total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'discount_tax' => array(
|
||||
'description' => __( 'Discount total tax.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Discount total tax.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1556,7 +1556,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
),
|
||||
),
|
||||
'refunds' => array(
|
||||
'description' => __( 'List of refunds.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of refunds.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1564,19 +1564,19 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Refund ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Refund ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'reason' => array(
|
||||
'description' => __( 'Refund reason.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Refund reason.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Refund total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Refund total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1600,27 +1600,27 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
$params['status'] = array(
|
||||
'default' => 'any',
|
||||
'description' => __( 'Limit result set to orders assigned a specific status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to orders assigned a specific status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_merge( array( 'any' ), $this->get_order_statuses() ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['customer'] = array(
|
||||
'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['product'] = array(
|
||||
'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['dp'] = array(
|
||||
'default' => wc_get_price_decimals(),
|
||||
'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
|
|
@ -44,7 +44,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
array(
|
||||
'args' => array(
|
||||
'attribute_id' => array(
|
||||
'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -61,7 +61,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Name for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Name for the resource.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
),
|
||||
) ),
|
||||
|
@ -72,11 +72,11 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'attribute_id' => array(
|
||||
'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -102,7 +102,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -112,7 +112,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
|
||||
'args' => array(
|
||||
'attribute_id' => array(
|
||||
'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -193,13 +193,13 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Term name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Term name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -207,7 +207,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -215,7 +215,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -223,12 +223,12 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
|
|||
),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -60,7 +60,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
'permission_callback' => array( $this, 'create_item_permissions_check' ),
|
||||
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
|
||||
'name' => array(
|
||||
'description' => __( 'Name for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Name for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
|
@ -72,7 +72,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -98,7 +98,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -124,7 +124,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -138,7 +138,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'attributes', 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -152,11 +152,11 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! $this->get_taxonomy( $request ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -170,11 +170,11 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function update_item_permissions_check( $request ) {
|
||||
if ( ! $this->get_taxonomy( $request ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'attributes', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -188,11 +188,11 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function delete_item_permissions_check( $request ) {
|
||||
if ( ! $this->get_taxonomy( $request ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'attributes', 'delete' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -207,7 +207,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'attributes', 'batch' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -360,7 +360,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$attribute = $this->get_attribute( (int) $request['id'] );
|
||||
|
@ -375,7 +375,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
$deleted = wc_delete_attribute( $attribute->attribute_id );
|
||||
|
||||
if ( false === $deleted ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -459,13 +459,13 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -473,7 +473,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -481,21 +481,21 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Type of attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Type of attribute.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'select',
|
||||
'enum' => array_keys( wc_get_attribute_types() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'order_by' => array(
|
||||
'description' => __( 'Default sort order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default sort order.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'menu_order',
|
||||
'enum' => array( 'menu_order', 'name', 'name_num', 'id' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'has_archives' => array(
|
||||
'description' => __( 'Enable/Disable attribute archives.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Enable/Disable attribute archives.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
|
@ -554,7 +554,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
", $id ) );
|
||||
|
||||
if ( is_wp_error( $attribute ) || is_null( $attribute ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_attribute_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_attribute_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
return $attribute;
|
||||
|
@ -570,11 +570,11 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
protected function validate_attribute_slug( $slug, $new_data = true ) {
|
||||
if ( strlen( $slug ) >= 28 ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce-rest-api' ), $slug ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
|
||||
} elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce-rest-api' ), $slug ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
|
||||
} elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce-rest-api' ), $slug ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -171,13 +171,13 @@ class WC_REST_Product_Categories_V1_Controller extends WC_REST_Terms_Controller
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Category name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -185,7 +185,7 @@ class WC_REST_Product_Categories_V1_Controller extends WC_REST_Terms_Controller
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -193,12 +193,12 @@ class WC_REST_Product_Categories_V1_Controller extends WC_REST_Terms_Controller
|
|||
),
|
||||
),
|
||||
'parent' => array(
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -206,59 +206,59 @@ class WC_REST_Product_Categories_V1_Controller extends WC_REST_Terms_Controller
|
|||
),
|
||||
),
|
||||
'display' => array(
|
||||
'description' => __( 'Category archive display type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category archive display type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'default',
|
||||
'enum' => array( 'default', 'products', 'subcategories', 'both' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'image' => array(
|
||||
'description' => __( 'Image data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'title' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -43,11 +43,11 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the variation.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variation.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -65,17 +65,17 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
'review' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Review content.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Review content.', 'woocommerce' ),
|
||||
),
|
||||
'name' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Name of the reviewer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Name of the reviewer.', 'woocommerce' ),
|
||||
),
|
||||
'email' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Email of the reviewer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Email of the reviewer.', 'woocommerce' ),
|
||||
),
|
||||
) ),
|
||||
),
|
||||
|
@ -85,11 +85,11 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -115,7 +115,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -131,7 +131,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( 'product', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -147,7 +147,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
$post = get_post( (int) $request['product_id'] );
|
||||
|
||||
if ( $post && ! wc_rest_check_post_permissions( 'product', 'read', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -162,7 +162,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
public function create_item_permissions_check( $request ) {
|
||||
$post = get_post( (int) $request['product_id'] );
|
||||
if ( $post && ! wc_rest_check_post_permissions( 'product', 'create', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
public function update_item_permissions_check( $request ) {
|
||||
$post = get_post( (int) $request['product_id'] );
|
||||
if ( $post && ! wc_rest_check_post_permissions( 'product', 'edit', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
public function delete_item_permissions_check( $request ) {
|
||||
$post = get_post( (int) $request['product_id'] );
|
||||
if ( $post && ! wc_rest_check_post_permissions( 'product', 'delete', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
$product_id = (int) $request['product_id'];
|
||||
|
||||
if ( 'product' !== get_post_type( $product_id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$reviews = get_approved_comments( $product_id );
|
||||
|
@ -231,13 +231,13 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
$product_id = (int) $request['product_id'];
|
||||
|
||||
if ( 'product' !== get_post_type( $product_id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$review = get_comment( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$delivery = $this->prepare_item_for_response( $review, $request );
|
||||
|
@ -257,7 +257,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
$product_id = (int) $request['product_id'];
|
||||
|
||||
if ( 'product' !== get_post_type( $product_id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$prepared_review = $this->prepare_item_for_database( $request );
|
||||
|
@ -274,7 +274,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
$product_review_id = wp_insert_comment( $prepared_review );
|
||||
if ( ! $product_review_id ) {
|
||||
return new WP_Error( 'rest_product_review_failed_create', __( 'Creating product review failed.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'rest_product_review_failed_create', __( 'Creating product review failed.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
update_comment_meta( $product_review_id, 'rating', ( ! empty( $request['rating'] ) ? $request['rating'] : '0' ) );
|
||||
|
@ -312,20 +312,20 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
$product_id = (int) $request['product_id'];
|
||||
|
||||
if ( 'product' !== get_post_type( $product_id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$review = get_comment( $product_review_id );
|
||||
|
||||
if ( empty( $product_review_id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$prepared_review = $this->prepare_item_for_database( $request );
|
||||
|
||||
$updated = wp_update_comment( $prepared_review );
|
||||
if ( 0 === $updated ) {
|
||||
return new WP_Error( 'rest_product_review_failed_edit', __( 'Updating product review failed.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'rest_product_review_failed_edit', __( 'Updating product review failed.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['rating'] ) ) {
|
||||
|
@ -363,7 +363,7 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
$product_review = get_comment( $product_review_id );
|
||||
if ( empty( $product_review_id ) || empty( $product_review->comment_ID ) || empty( $product_review->comment_post_ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid product review ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid product review ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,18 +383,18 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
$result = wp_delete_comment( $product_review_id, true );
|
||||
} else {
|
||||
if ( ! $supports_trash ) {
|
||||
return new WP_Error( 'rest_trash_not_supported', __( 'The product review does not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'rest_trash_not_supported', __( 'The product review does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
if ( 'trash' === $product_review->comment_approved ) {
|
||||
return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.', 'woocommerce-rest-api' ), array( 'status' => 410 ) );
|
||||
return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.', 'woocommerce' ), array( 'status' => 410 ) );
|
||||
}
|
||||
|
||||
$result = wp_trash_comment( $product_review->comment_ID );
|
||||
}
|
||||
|
||||
if ( ! $result ) {
|
||||
return new WP_Error( 'rest_cannot_delete', __( 'The product review cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'rest_cannot_delete', __( 'The product review cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -523,38 +523,38 @@ class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'review' => array(
|
||||
'description' => __( 'The content of the review.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The content of the review.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'rating' => array(
|
||||
'description' => __( 'Review rating (0 to 5).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Review rating (0 to 5).', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Reviewer name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviewer name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'Reviewer email.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviewer email.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'verified' => array(
|
||||
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -91,13 +91,13 @@ class WC_REST_Product_Shipping_Classes_V1_Controller extends WC_REST_Terms_Contr
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Shipping class name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -105,7 +105,7 @@ class WC_REST_Product_Shipping_Classes_V1_Controller extends WC_REST_Terms_Contr
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -113,7 +113,7 @@ class WC_REST_Product_Shipping_Classes_V1_Controller extends WC_REST_Terms_Contr
|
|||
),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -121,7 +121,7 @@ class WC_REST_Product_Shipping_Classes_V1_Controller extends WC_REST_Terms_Contr
|
|||
),
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -91,13 +91,13 @@ class WC_REST_Product_Tags_V1_Controller extends WC_REST_Terms_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Tag name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -105,7 +105,7 @@ class WC_REST_Product_Tags_V1_Controller extends WC_REST_Terms_Controller {
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -113,7 +113,7 @@ class WC_REST_Product_Tags_V1_Controller extends WC_REST_Terms_Controller {
|
|||
),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -121,7 +121,7 @@ class WC_REST_Product_Tags_V1_Controller extends WC_REST_Terms_Controller {
|
|||
),
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -66,7 +66,7 @@ class WC_REST_Report_Sales_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'reports', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -287,67 +287,67 @@ class WC_REST_Report_Sales_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'total_sales' => array(
|
||||
'description' => __( 'Gross sales in the period.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Gross sales in the period.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'net_sales' => array(
|
||||
'description' => __( 'Net sales in the period.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Net sales in the period.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'average_sales' => array(
|
||||
'description' => __( 'Average net daily sales.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Average net daily sales.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_orders' => array(
|
||||
'description' => __( 'Total of orders placed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total of orders placed.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_items' => array(
|
||||
'description' => __( 'Total of items purchased.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total of items purchased.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Total charged for taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total charged for taxes.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_shipping' => array(
|
||||
'description' => __( 'Total charged for shipping.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total charged for shipping.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_refunds' => array(
|
||||
'description' => __( 'Total of refunded orders.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total of refunded orders.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_discount' => array(
|
||||
'description' => __( 'Total of coupons used.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total of coupons used.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'totals_grouped_by' => array(
|
||||
'description' => __( 'Group type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Group type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'totals' => array(
|
||||
'description' => __( 'Totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Totals.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'array',
|
||||
|
@ -370,7 +370,7 @@ class WC_REST_Report_Sales_V1_Controller extends WC_REST_Controller {
|
|||
return array(
|
||||
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
|
||||
'period' => array(
|
||||
'description' => __( 'Report period.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Report period.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array( 'week', 'month', 'last_month', 'year' ),
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
@ -378,7 +378,7 @@ class WC_REST_Report_Sales_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
'date_min' => array(
|
||||
/* translators: %s: date format */
|
||||
'description' => sprintf( __( 'Return sales for a specific start date, the date need to be in the %s format.', 'woocommerce-rest-api' ), 'YYYY-MM-DD' ),
|
||||
'description' => sprintf( __( 'Return sales for a specific start date, the date need to be in the %s format.', 'woocommerce' ), 'YYYY-MM-DD' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date',
|
||||
'validate_callback' => 'wc_rest_validate_reports_request_arg',
|
||||
|
@ -386,7 +386,7 @@ class WC_REST_Report_Sales_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
'date_max' => array(
|
||||
/* translators: %s: date format */
|
||||
'description' => sprintf( __( 'Return sales for a specific end date, the date need to be in the %s format.', 'woocommerce-rest-api' ), 'YYYY-MM-DD' ),
|
||||
'description' => sprintf( __( 'Return sales for a specific end date, the date need to be in the %s format.', 'woocommerce' ), 'YYYY-MM-DD' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date',
|
||||
'validate_callback' => 'wc_rest_validate_reports_request_arg',
|
||||
|
|
|
@ -149,19 +149,19 @@ class WC_REST_Report_Top_Sellers_V1_Controller extends WC_REST_Report_Sales_V1_C
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Product ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'quantity' => array(
|
||||
'description' => __( 'Total number of purchases.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total number of purchases.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -59,7 +59,7 @@ class WC_REST_Reports_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'reports', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -75,11 +75,11 @@ class WC_REST_Reports_V1_Controller extends WC_REST_Controller {
|
|||
return array(
|
||||
array(
|
||||
'slug' => 'sales',
|
||||
'description' => __( 'List of sales reports.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of sales reports.', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'slug' => 'top_sellers',
|
||||
'description' => __( 'List of top sellers products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of top sellers products.', 'woocommerce' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -154,13 +154,13 @@ class WC_REST_Reports_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human-readable description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human-readable description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -59,7 +59,7 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<slug>\w[\w\s\-]*)', array(
|
||||
'args' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'Unique slug for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique slug for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -71,7 +71,7 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -87,7 +87,7 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -102,7 +102,7 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -117,7 +117,7 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function delete_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -135,7 +135,7 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
// Add standard class.
|
||||
$tax_classes[] = array(
|
||||
'slug' => 'standard',
|
||||
'name' => __( 'Standard rate', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Standard rate', 'woocommerce' ),
|
||||
);
|
||||
|
||||
$classes = WC_Tax::get_tax_classes();
|
||||
|
@ -203,14 +203,14 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Taxes do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Taxes do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$tax_class = WC_Tax::get_tax_class_by( 'slug', sanitize_title( $request['slug'] ) );
|
||||
$deleted = WC_Tax::delete_tax_class_by( 'slug', sanitize_title( $request['slug'] ) );
|
||||
|
||||
if ( ! $deleted ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $deleted ) ) {
|
||||
|
@ -288,13 +288,13 @@ class WC_REST_Tax_Classes_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Tax class name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'required' => true,
|
||||
|
|
|
@ -59,7 +59,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -85,7 +85,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -111,7 +111,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -126,7 +126,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -140,7 +140,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -155,7 +155,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function update_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -170,7 +170,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function delete_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -185,7 +185,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'batch' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -361,7 +361,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_tax_exists', __( 'Cannot create existing resource.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_tax_exists', __( 'Cannot create existing resource.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$tax = $this->create_or_update_tax( $request );
|
||||
|
@ -397,7 +397,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
|
||||
if ( empty( $id ) || empty( $tax_obj ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$tax = $this->prepare_item_for_response( $tax_obj, $request );
|
||||
|
@ -417,7 +417,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
|
||||
if ( empty( $id ) || empty( $tax_obj ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$tax = $this->create_or_update_tax( $request, $tax_obj );
|
||||
|
@ -454,13 +454,13 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Taxes do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Taxes do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$tax = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
|
||||
if ( empty( $id ) || empty( $tax ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -469,7 +469,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
WC_Tax::_delete_tax_rate( $id );
|
||||
|
||||
if ( 0 === $wpdb->rows_affected ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -573,66 +573,66 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'Country ISO 3166 code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Country ISO 3166 code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'State code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'State code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postcode / ZIP.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postcode / ZIP.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'rate' => array(
|
||||
'description' => __( 'Tax rate.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Tax rate name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'priority' => array(
|
||||
'description' => __( 'Tax priority.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax priority.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => 1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'compound' => array(
|
||||
'description' => __( 'Whether or not this is a compound rate.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether or not this is a compound rate.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'shipping' => array(
|
||||
'description' => __( 'Whether or not this tax rate also gets applied to shipping.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether or not this tax rate also gets applied to shipping.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'order' => array(
|
||||
'description' => __( 'Indicates the order that will appear in queries.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Indicates the order that will appear in queries.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'class' => array(
|
||||
'description' => __( 'Tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'standard',
|
||||
'enum' => array_merge( array( 'standard' ), WC_Tax::get_tax_class_slugs() ),
|
||||
|
@ -655,7 +655,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['page'] = array(
|
||||
'description' => __( 'Current page of the collection.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Current page of the collection.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => 1,
|
||||
'sanitize_callback' => 'absint',
|
||||
|
@ -663,7 +663,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
'minimum' => 1,
|
||||
);
|
||||
$params['per_page'] = array(
|
||||
'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => 10,
|
||||
'minimum' => 1,
|
||||
|
@ -672,14 +672,14 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['order'] = array(
|
||||
'default' => 'asc',
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'type' => 'string',
|
||||
|
@ -687,7 +687,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
);
|
||||
$params['orderby'] = array(
|
||||
'default' => 'order',
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
|
||||
'enum' => array(
|
||||
'id',
|
||||
'order',
|
||||
|
@ -697,7 +697,7 @@ class WC_REST_Taxes_V1_Controller extends WC_REST_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['class'] = array(
|
||||
'description' => __( 'Sort by tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort by tax class.', 'woocommerce' ),
|
||||
'enum' => array_merge( array( 'standard' ), WC_Tax::get_tax_class_slugs() ),
|
||||
'sanitize_callback' => 'sanitize_title',
|
||||
'type' => 'string',
|
||||
|
|
|
@ -44,7 +44,7 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'webhook_id' => array(
|
||||
'description' => __( 'Unique identifier for the webhook.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the webhook.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -60,11 +60,11 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'webhook_id' => array(
|
||||
'description' => __( 'Unique identifier for the webhook.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the webhook.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -88,7 +88,7 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -102,7 +102,7 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -119,7 +119,7 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
$webhook = wc_get_webhook( (int) $request['webhook_id'] );
|
||||
|
||||
if ( empty( $webhook ) || is_null( $webhook ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$logs = array();
|
||||
|
@ -144,13 +144,13 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
$webhook = wc_get_webhook( (int) $request['webhook_id'] );
|
||||
|
||||
if ( empty( $webhook ) || is_null( $webhook ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$log = array();
|
||||
|
||||
if ( empty( $id ) || empty( $log ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$delivery = $this->prepare_item_for_response( (object) $log, $request );
|
||||
|
@ -223,32 +223,32 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'duration' => array(
|
||||
'description' => __( 'The delivery duration, in seconds.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The delivery duration, in seconds.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'summary' => array(
|
||||
'description' => __( 'A friendly summary of the response including the HTTP response code, message, and body.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A friendly summary of the response including the HTTP response code, message, and body.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'request_url' => array(
|
||||
'description' => __( 'The URL where the webhook was delivered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The URL where the webhook was delivered.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'request_headers' => array(
|
||||
'description' => __( 'Request headers.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Request headers.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -257,25 +257,25 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'request_body' => array(
|
||||
'description' => __( 'Request body.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Request body.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'response_code' => array(
|
||||
'description' => __( 'The HTTP response code from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The HTTP response code from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'response_message' => array(
|
||||
'description' => __( 'The HTTP response message from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The HTTP response message from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'response_headers' => array(
|
||||
'description' => __( 'Array of the response headers from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Array of the response headers from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -284,13 +284,13 @@ class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'response_body' => array(
|
||||
'description' => __( 'The response body from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The response body from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the webhook delivery was logged, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the webhook delivery was logged, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -60,12 +60,12 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
'topic' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Webhook topic.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook topic.', 'woocommerce' ),
|
||||
),
|
||||
'delivery_url' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Webhook delivery URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook delivery URL.', 'woocommerce' ),
|
||||
),
|
||||
) ),
|
||||
),
|
||||
|
@ -75,7 +75,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -101,7 +101,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -127,7 +127,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -142,7 +142,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -156,7 +156,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -171,7 +171,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function update_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -186,7 +186,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function delete_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'delete' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -201,7 +201,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'webhooks', 'batch' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -297,7 +297,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
$id = (int) $request['id'];
|
||||
|
||||
if ( empty( $id ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$data = $this->prepare_item_for_response( $id, $request );
|
||||
|
@ -315,17 +315,17 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
// Validate topic.
|
||||
if ( empty( $request['topic'] ) || ! wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic is required and must be valid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic is required and must be valid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
// Validate delivery URL.
|
||||
if ( empty( $request['delivery_url'] ) || ! wc_is_valid_url( $request['delivery_url'] ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$post = $this->prepare_item_for_database( $request );
|
||||
|
@ -377,7 +377,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
$webhook = wc_get_webhook( $id );
|
||||
|
||||
if ( empty( $webhook ) || is_null( $webhook ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
// Update topic.
|
||||
|
@ -385,7 +385,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
if ( wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) {
|
||||
$webhook->set_topic( $request['topic'] );
|
||||
} else {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic must be valid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic must be valid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
if ( wc_is_valid_url( $request['delivery_url'] ) ) {
|
||||
$webhook->set_delivery_url( $request['delivery_url'] );
|
||||
} else {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
if ( wc_is_webhook_valid_status( strtolower( $request['status'] ) ) ) {
|
||||
$webhook->set_status( $request['status'] );
|
||||
} else {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_status", __( 'Webhook status must be valid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_status", __( 'Webhook status must be valid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,13 +452,13 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Webhooks do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Webhooks do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$webhook = wc_get_webhook( $id );
|
||||
|
||||
if ( empty( $webhook ) || is_null( $webhook ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -467,7 +467,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
if ( ! $result ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,7 +498,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
|
||||
// Validate required POST fields.
|
||||
if ( 'POST' === $request->get_method() && empty( $data->ID ) ) {
|
||||
$data->post_title = ! empty( $request['name'] ) ? $request['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce-rest-api' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce-rest-api' ) ) ); // @codingStandardsIgnoreLine
|
||||
$data->post_title = ! empty( $request['name'] ) ? $request['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce' ) ) ); // @codingStandardsIgnoreLine
|
||||
|
||||
// Post author.
|
||||
$data->post_author = get_current_user_id();
|
||||
|
@ -546,7 +546,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
$webhook = wc_get_webhook( $id );
|
||||
|
||||
if ( empty( $webhook ) || is_null( $webhook ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
@ -612,42 +612,42 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'A friendly name for the webhook.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A friendly name for the webhook.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Webhook status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'active',
|
||||
'enum' => array_keys( wc_get_webhook_statuses() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'topic' => array(
|
||||
'description' => __( 'Webhook topic.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook topic.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'resource' => array(
|
||||
'description' => __( 'Webhook resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'event' => array(
|
||||
'description' => __( 'Webhook event.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook event.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'hooks' => array(
|
||||
'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -656,25 +656,25 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'delivery_url' => array(
|
||||
'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'secret' => array(
|
||||
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -696,19 +696,19 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['after'] = array(
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['before'] = array(
|
||||
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -717,7 +717,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -726,20 +726,20 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'date',
|
||||
'enum' => array(
|
||||
|
@ -751,7 +751,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
|
|||
);
|
||||
$params['status'] = array(
|
||||
'default' => 'all',
|
||||
'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array( 'all', 'active', 'paused', 'disabled' ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
|
|
|
@ -58,7 +58,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'args' => array_merge(
|
||||
$this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
|
||||
'code' => array(
|
||||
'description' => __( 'Coupon code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon code.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
),
|
||||
|
@ -73,7 +73,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -99,7 +99,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -268,7 +268,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
|
||||
// Validate required POST fields.
|
||||
if ( $creating && empty( $request['code'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce-rest-api' ), 'code' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce' ), 'code' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
// Handle all writable props.
|
||||
|
@ -283,7 +283,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
$id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id );
|
||||
|
||||
if ( $id_from_code ) {
|
||||
return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$coupon->set_code( $coupon_code );
|
||||
|
@ -332,81 +332,81 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the object.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'code' => array(
|
||||
'description' => __( 'Coupon code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'amount' => array(
|
||||
'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the coupon was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the coupon was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the coupon was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the coupon was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'discount_type' => array(
|
||||
'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'fixed_cart',
|
||||
'enum' => array_keys( wc_get_coupon_types() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Coupon description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_expires' => array(
|
||||
'description' => __( "The date the coupon expires, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the coupon expires, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_expires_gmt' => array(
|
||||
'description' => __( 'The date the coupon expires, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the coupon expires, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'usage_count' => array(
|
||||
'description' => __( 'Number of times the coupon has been used already.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of times the coupon has been used already.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'individual_use' => array(
|
||||
'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'product_ids' => array(
|
||||
'description' => __( 'List of product IDs the coupon can be used on.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of product IDs the coupon can be used on.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -414,7 +414,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'excluded_product_ids' => array(
|
||||
'description' => __( 'List of product IDs the coupon cannot be used on.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of product IDs the coupon cannot be used on.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -422,28 +422,28 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'usage_limit' => array(
|
||||
'description' => __( 'How many times the coupon can be used in total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'How many times the coupon can be used in total.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'usage_limit_per_user' => array(
|
||||
'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'limit_usage_to_x_items' => array(
|
||||
'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'free_shipping' => array(
|
||||
'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'product_categories' => array(
|
||||
'description' => __( 'List of category IDs the coupon applies to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of category IDs the coupon applies to.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -451,7 +451,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'excluded_product_categories' => array(
|
||||
'description' => __( 'List of category IDs the coupon does not apply to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of category IDs the coupon does not apply to.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -459,23 +459,23 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'exclude_sale_items' => array(
|
||||
'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'minimum_amount' => array(
|
||||
'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'maximum_amount' => array(
|
||||
'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email_restrictions' => array(
|
||||
'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
|
@ -483,7 +483,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'used_by' => array(
|
||||
'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -492,25 +492,25 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -531,7 +531,7 @@ class WC_REST_Coupons_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
$params = parent::get_collection_params();
|
||||
|
||||
$params['code'] = array(
|
||||
'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
|
|
@ -78,79 +78,79 @@ class WC_REST_Customer_Downloads_V2_Controller extends WC_REST_Customer_Download
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'download_id' => array(
|
||||
'description' => __( 'Download ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Download ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'download_url' => array(
|
||||
'description' => __( 'Download file URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Download file URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Downloadable product ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Downloadable product ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'download_name' => array(
|
||||
'description' => __( 'Downloadable file name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Downloadable file name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'order_id' => array(
|
||||
'description' => __( 'Order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'order_key' => array(
|
||||
'description' => __( 'Order key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'downloads_remaining' => array(
|
||||
'description' => __( 'Number of downloads remaining.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of downloads remaining.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'access_expires' => array(
|
||||
'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'access_expires_gmt' => array(
|
||||
'description' => __( 'The date when download access expires, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date when download access expires, as GMT.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File details.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File details.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'name' => array(
|
||||
'description' => __( 'File name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -121,43 +121,43 @@ class WC_REST_Customers_V2_Controller extends WC_REST_Customers_V1_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the customer was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the customer was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the customer was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the customer was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the customer was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the customer was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'The email address for the customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The email address for the customer.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'first_name' => array(
|
||||
'description' => __( 'Customer first name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer first name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -165,7 +165,7 @@ class WC_REST_Customers_V2_Controller extends WC_REST_Customers_V1_Controller {
|
|||
),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Customer last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -173,13 +173,13 @@ class WC_REST_Customers_V2_Controller extends WC_REST_Customers_V1_Controller {
|
|||
),
|
||||
),
|
||||
'role' => array(
|
||||
'description' => __( 'Customer role.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer role.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'username' => array(
|
||||
'description' => __( 'Customer login name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer login name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -187,169 +187,169 @@ class WC_REST_Customers_V2_Controller extends WC_REST_Customers_V1_Controller {
|
|||
),
|
||||
),
|
||||
'password' => array(
|
||||
'description' => __( 'Customer password.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer password.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'billing' => array(
|
||||
'description' => __( 'List of billing address data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of billing address data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'Email address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Email address.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'phone' => array(
|
||||
'description' => __( 'Phone number.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Phone number.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping' => array(
|
||||
'description' => __( 'List of shipping address data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of shipping address data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'is_paying_customer' => array(
|
||||
'description' => __( 'Is the customer a paying customer?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is the customer a paying customer?', 'woocommerce' ),
|
||||
'type' => 'bool',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'orders_count' => array(
|
||||
'description' => __( 'Quantity of orders made by the customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Quantity of orders made by the customer.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_spent' => array(
|
||||
'description' => __( 'Total amount spent.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total amount spent.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'avatar_url' => array(
|
||||
'description' => __( 'Avatar URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Avatar URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
|
|
@ -55,31 +55,31 @@ class WC_REST_Network_Orders_V2_Controller extends WC_REST_Orders_V2_Controller
|
|||
$schema = parent::get_public_item_schema();
|
||||
|
||||
$schema['properties']['blog'] = array(
|
||||
'description' => __( 'Blog id of the record on the multisite.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Blog id of the record on the multisite.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
);
|
||||
$schema['properties']['edit_url'] = array(
|
||||
'description' => __( 'URL to edit the order', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'URL to edit the order', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
);
|
||||
$schema['properties']['customer'][] = array(
|
||||
'description' => __( 'Name of the customer for the order', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Name of the customer for the order', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
);
|
||||
$schema['properties']['status_name'][] = array(
|
||||
'description' => __( 'Order Status', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order Status', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
);
|
||||
$schema['properties']['formatted_total'][] = array(
|
||||
'description' => __( 'Order total formatted for locale', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order total formatted for locale', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -146,7 +146,7 @@ class WC_REST_Network_Orders_V2_Controller extends WC_REST_Orders_V2_Controller
|
|||
$current_order['blog'] = get_blog_details( get_current_blog_id() );
|
||||
$current_order['edit_url'] = get_admin_url( $blog_id, 'post.php?post=' . absint( $order->get_id() ) . '&action=edit' );
|
||||
/* translators: 1: first name 2: last name */
|
||||
$current_order['customer'] = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce-rest-api' ), $order->get_billing_first_name(), $order->get_billing_last_name() ) );
|
||||
$current_order['customer'] = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $order->get_billing_first_name(), $order->get_billing_last_name() ) );
|
||||
$current_order['status_name'] = wc_get_order_status_name( $order->get_status() );
|
||||
$current_order['formatted_total'] = $order->get_formatted_order_total();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class WC_REST_Order_Notes_V2_Controller extends WC_REST_Order_Notes_V1_Controlle
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order || $this->post_type !== $order->get_type() ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
|
@ -126,30 +126,30 @@ class WC_REST_Order_Notes_V2_Controller extends WC_REST_Order_Notes_V1_Controlle
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the order note was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the order note was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'note' => array(
|
||||
'description' => __( 'Order note content.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order note content.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'customer_note' => array(
|
||||
'description' => __( 'If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
|
@ -170,7 +170,7 @@ class WC_REST_Order_Notes_V2_Controller extends WC_REST_Order_Notes_V1_Controlle
|
|||
$params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
|
||||
$params['type'] = array(
|
||||
'default' => 'any',
|
||||
'description' => __( 'Limit result to customers or internal notes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result to customers or internal notes.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array( 'any', 'customer', 'internal' ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
|
|
|
@ -61,7 +61,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
$this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'order_id' => array(
|
||||
'description' => __( 'The order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -85,11 +85,11 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'order_id' => array(
|
||||
'description' => __( 'The order ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The order ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -109,7 +109,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
'force' => array(
|
||||
'default' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -188,11 +188,11 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
|
||||
}
|
||||
|
||||
if ( ! $object || $object->get_parent_id() !== $order->get_id() ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce-rest-api' ), 404 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 404 );
|
||||
}
|
||||
|
||||
$data = $this->get_formatted_item_data( $object );
|
||||
|
@ -270,11 +270,11 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
|
||||
}
|
||||
|
||||
if ( 0 > $request['amount'] ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Create the refund.
|
||||
|
@ -293,7 +293,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
}
|
||||
|
||||
if ( ! $refund ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce-rest-api' ), 500 );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
|
||||
|
@ -352,64 +352,64 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the order refund was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the order refund was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'amount' => array(
|
||||
'description' => __( 'Refund amount.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Refund amount.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'reason' => array(
|
||||
'description' => __( 'Reason for refund.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reason for refund.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'refunded_by' => array(
|
||||
'description' => __( 'User ID of user who created the refund.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'User ID of user who created the refund.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'refunded_payment' => array(
|
||||
'description' => __( 'If the payment was refunded via the API.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the payment was refunded via the API.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -417,7 +417,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
),
|
||||
),
|
||||
'line_items' => array(
|
||||
'description' => __( 'Line items data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line items data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -425,67 +425,67 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Item ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Item ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Product ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product ID.', 'woocommerce' ),
|
||||
'type' => array( 'integer', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'variation_id' => array(
|
||||
'description' => __( 'Variation ID, if applicable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation ID, if applicable.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'quantity' => array(
|
||||
'description' => __( 'Quantity ordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Quantity ordered.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class of product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class of product.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Line subtotal (before discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal_tax' => array(
|
||||
'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_tax' => array(
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'taxes' => array(
|
||||
'description' => __( 'Line taxes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Line taxes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -493,19 +493,19 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax rate ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Tax total.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax total.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'subtotal' => array(
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax subtotal.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -514,7 +514,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
),
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -522,19 +522,19 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -543,13 +543,13 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
),
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Product SKU.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product SKU.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Product price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product price.', 'woocommerce' ),
|
||||
'type' => 'number',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -558,7 +558,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
|
|||
),
|
||||
),
|
||||
'api_refund' => array(
|
||||
'description' => __( 'When true, the payment gateway API is used to generate the refund.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'When true, the payment gateway API is used to generate the refund.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'edit' ),
|
||||
'default' => true,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -51,7 +51,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\w-]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -82,7 +82,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function update_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
$gateway = $this->get_gateway( $request );
|
||||
|
||||
if ( is_null( $gateway ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$gateway = $this->prepare_item_for_response( $gateway, $request );
|
||||
|
@ -158,7 +158,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
$gateway = $this->get_gateway( $request );
|
||||
|
||||
if ( is_null( $gateway ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
// Get settings.
|
||||
|
@ -184,7 +184,7 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( $errors_found ) {
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,23 +351,23 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Payment gateway ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => __( 'Payment gateway title on checkout.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway title on checkout.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Payment gateway description on checkout.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway description on checkout.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'order' => array(
|
||||
'description' => __( 'Payment gateway sort order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway sort order.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -375,71 +375,71 @@ class WC_REST_Payment_Gateways_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'enabled' => array(
|
||||
'description' => __( 'Payment gateway enabled status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway enabled status.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'method_title' => array(
|
||||
'description' => __( 'Payment gateway method title.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway method title.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'method_description' => array(
|
||||
'description' => __( 'Payment gateway method description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway method description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'settings' => array(
|
||||
'description' => __( 'Payment gateway settings.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway settings.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Type of setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Type of setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Setting value.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'default' => array(
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'tip' => array(
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'placeholder' => array(
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -100,13 +100,13 @@ class WC_REST_Product_Categories_V2_Controller extends WC_REST_Product_Categorie
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Category name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -114,7 +114,7 @@ class WC_REST_Product_Categories_V2_Controller extends WC_REST_Product_Categorie
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -122,12 +122,12 @@ class WC_REST_Product_Categories_V2_Controller extends WC_REST_Product_Categorie
|
|||
),
|
||||
),
|
||||
'parent' => array(
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -135,71 +135,71 @@ class WC_REST_Product_Categories_V2_Controller extends WC_REST_Product_Categorie
|
|||
),
|
||||
),
|
||||
'display' => array(
|
||||
'description' => __( 'Category archive display type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category archive display type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'default',
|
||||
'enum' => array( 'default', 'products', 'subcategories', 'both' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'image' => array(
|
||||
'description' => __( 'Image data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'title' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -42,7 +42,7 @@ class WC_REST_Product_Reviews_V2_Controller extends WC_REST_Product_Reviews_V1_C
|
|||
$this->namespace, '/' . $this->rest_base . '/batch', array(
|
||||
'args' => array(
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -65,7 +65,7 @@ class WC_REST_Product_Reviews_V2_Controller extends WC_REST_Product_Reviews_V1_C
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( 'product', 'batch' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -150,43 +150,43 @@ class WC_REST_Product_Reviews_V2_Controller extends WC_REST_Product_Reviews_V1_C
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'review' => array(
|
||||
'description' => __( 'The content of the review.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The content of the review.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the review was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the review was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'rating' => array(
|
||||
'description' => __( 'Review rating (0 to 5).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Review rating (0 to 5).', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Reviewer name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviewer name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'Reviewer email.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviewer email.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'verified' => array(
|
||||
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -47,7 +47,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
$this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -70,11 +70,11 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the variation.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variation.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -104,7 +104,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -115,7 +115,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
$this->namespace, '/' . $this->rest_base . '/batch', array(
|
||||
'args' => array(
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -151,12 +151,12 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
$object = $this->get_object( (int) $request['id'] );
|
||||
|
||||
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $object->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
// Check if variation belongs to the correct parent product.
|
||||
if ( $object && 0 !== $object->get_parent_id() && absint( $request['product_id'] ) !== $object->get_parent_id() ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Parent product does not match current variation.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Parent product does not match current variation.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -488,7 +488,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
|
||||
if ( ! $object || 0 === $object->get_id() ) {
|
||||
return new WP_Error(
|
||||
"woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array(
|
||||
"woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array(
|
||||
'status' => 404,
|
||||
)
|
||||
);
|
||||
|
@ -509,7 +509,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
|
||||
return new WP_Error(
|
||||
/* translators: %s: post type */
|
||||
"woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce-rest-api' ), $this->post_type ), array(
|
||||
"woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array(
|
||||
'status' => rest_authorization_required_code(),
|
||||
)
|
||||
);
|
||||
|
@ -527,7 +527,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
if ( ! $supports_trash ) {
|
||||
return new WP_Error(
|
||||
/* translators: %s: post type */
|
||||
'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce-rest-api' ), $this->post_type ), array(
|
||||
'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array(
|
||||
'status' => 501,
|
||||
)
|
||||
);
|
||||
|
@ -538,7 +538,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
if ( 'trash' === $object->get_status() ) {
|
||||
return new WP_Error(
|
||||
/* translators: %s: post type */
|
||||
'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce-rest-api' ), $this->post_type ), array(
|
||||
'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array(
|
||||
'status' => 410,
|
||||
)
|
||||
);
|
||||
|
@ -552,7 +552,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
if ( ! $result ) {
|
||||
return new WP_Error(
|
||||
/* translators: %s: post type */
|
||||
'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce-rest-api' ), $this->post_type ), array(
|
||||
'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array(
|
||||
'status' => 500,
|
||||
)
|
||||
);
|
||||
|
@ -648,125 +648,125 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Variation description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'permalink' => array(
|
||||
'description' => __( 'Variation URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Unique identifier.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Current variation price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Current variation price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'regular_price' => array(
|
||||
'description' => __( 'Variation regular price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation regular price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sale_price' => array(
|
||||
'description' => __( 'Variation sale price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation sale price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from' => array(
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from_gmt' => array(
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to' => array(
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to_gmt' => array(
|
||||
'description' => __( 'End date of sale price, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'End date of sale price, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'on_sale' => array(
|
||||
'description' => __( 'Shows if the variation is on sale.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the variation is on sale.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'visible' => array(
|
||||
'description' => __( "Define if the variation is visible on the product's page.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Define if the variation is visible on the product's page.", 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'purchasable' => array(
|
||||
'description' => __( 'Shows if the variation can be bought.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the variation can be bought.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'virtual' => array(
|
||||
'description' => __( 'If the variation is virtual.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the variation is virtual.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloadable' => array(
|
||||
'description' => __( 'If the variation is downloadable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the variation is downloadable.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloads' => array(
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'File ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'File name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -774,183 +774,183 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
),
|
||||
),
|
||||
'download_limit' => array(
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'download_expiry' => array(
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_status' => array(
|
||||
'description' => __( 'Tax status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'taxable',
|
||||
'enum' => array( 'taxable', 'shipping', 'none' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'manage_stock' => array(
|
||||
'description' => __( 'Stock management at variation level.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock management at variation level.', 'woocommerce' ),
|
||||
'type' => array( 'boolean', 'null' ),
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'stock_quantity' => array(
|
||||
'description' => __( 'Stock quantity.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock quantity.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'in_stock' => array(
|
||||
'description' => __( 'Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders' => array(
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'no',
|
||||
'enum' => array( 'no', 'notify', 'yes' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders_allowed' => array(
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'backordered' => array(
|
||||
'description' => __( 'Shows if the variation is on backordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'weight' => array(
|
||||
/* translators: %s: weight unit */
|
||||
'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce-rest-api' ), $weight_unit ),
|
||||
'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'dimensions' => array(
|
||||
'description' => __( 'Variation dimensions.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation dimensions.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'length' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Variation length (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'width' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Variation width (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'height' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Variation height (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping_class' => array(
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'shipping_class_id' => array(
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'image' => array(
|
||||
'description' => __( 'Variation image data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation image data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'position' => array(
|
||||
'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'attributes' => array(
|
||||
'description' => __( 'List of attributes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of attributes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Attribute ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'option' => array(
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -958,30 +958,30 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr
|
|||
),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
|
|
@ -83,7 +83,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -112,7 +112,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'args' => array(
|
||||
'force' => array(
|
||||
'default' => false,
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
),
|
||||
),
|
||||
|
@ -423,8 +423,8 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'date_modified' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ),
|
||||
'date_modified_gmt' => wc_rest_prepare_date_response( time() ),
|
||||
'src' => wc_placeholder_img_src(),
|
||||
'name' => __( 'Placeholder', 'woocommerce-rest-api' ),
|
||||
'alt' => __( 'Placeholder', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Placeholder', 'woocommerce' ),
|
||||
'alt' => __( 'Placeholder', 'woocommerce' ),
|
||||
'position' => 0,
|
||||
);
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
if ( 'variation' === $product->get_type() ) {
|
||||
return new WP_Error(
|
||||
"woocommerce_rest_invalid_{$this->post_type}_id",
|
||||
__( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce-rest-api' ),
|
||||
__( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ),
|
||||
array(
|
||||
'status' => 404,
|
||||
)
|
||||
|
@ -1120,7 +1120,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
/* translators: %s: attachment id */
|
||||
throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce-rest-api' ), $attachment_id ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 );
|
||||
}
|
||||
|
||||
$gallery_positions[ $attachment_id ] = absint( isset( $image['position'] ) ? $image['position'] : $index );
|
||||
|
@ -1351,7 +1351,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
if ( ! $object || 0 === $object->get_id() ) {
|
||||
return new WP_Error(
|
||||
"woocommerce_rest_{$this->post_type}_invalid_id",
|
||||
__( 'Invalid ID.', 'woocommerce-rest-api' ),
|
||||
__( 'Invalid ID.', 'woocommerce' ),
|
||||
array(
|
||||
'status' => 404,
|
||||
)
|
||||
|
@ -1361,7 +1361,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
if ( 'variation' === $object->get_type() ) {
|
||||
return new WP_Error(
|
||||
"woocommerce_rest_invalid_{$this->post_type}_id",
|
||||
__( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce-rest-api' ),
|
||||
__( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ),
|
||||
array(
|
||||
'status' => 404,
|
||||
)
|
||||
|
@ -1384,7 +1384,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
return new WP_Error(
|
||||
"woocommerce_rest_user_cannot_delete_{$this->post_type}",
|
||||
/* translators: %s: post type */
|
||||
sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce-rest-api' ), $this->post_type ),
|
||||
sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ),
|
||||
array(
|
||||
'status' => rest_authorization_required_code(),
|
||||
)
|
||||
|
@ -1422,7 +1422,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
return new WP_Error(
|
||||
'woocommerce_rest_trash_not_supported',
|
||||
/* translators: %s: post type */
|
||||
sprintf( __( 'The %s does not support trashing.', 'woocommerce-rest-api' ), $this->post_type ),
|
||||
sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ),
|
||||
array(
|
||||
'status' => 501,
|
||||
)
|
||||
|
@ -1435,7 +1435,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
return new WP_Error(
|
||||
'woocommerce_rest_already_trashed',
|
||||
/* translators: %s: post type */
|
||||
sprintf( __( 'The %s has already been deleted.', 'woocommerce-rest-api' ), $this->post_type ),
|
||||
sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ),
|
||||
array(
|
||||
'status' => 410,
|
||||
)
|
||||
|
@ -1451,7 +1451,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
return new WP_Error(
|
||||
'woocommerce_rest_cannot_delete',
|
||||
/* translators: %s: post type */
|
||||
sprintf( __( 'The %s cannot be deleted.', 'woocommerce-rest-api' ), $this->post_type ),
|
||||
sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ),
|
||||
array(
|
||||
'status' => 500,
|
||||
)
|
||||
|
@ -1489,185 +1489,185 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'Product slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'permalink' => array(
|
||||
'description' => __( 'Product URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the product was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the product was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the product was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the product was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Product type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'simple',
|
||||
'enum' => array_keys( wc_get_product_types() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Product status (post status).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product status (post status).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'publish',
|
||||
'enum' => array_merge( array_keys( get_post_statuses() ), array( 'future' ) ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'featured' => array(
|
||||
'description' => __( 'Featured product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Featured product.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'catalog_visibility' => array(
|
||||
'description' => __( 'Catalog visibility.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Catalog visibility.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'visible',
|
||||
'enum' => array( 'visible', 'catalog', 'search', 'hidden' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Product description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'short_description' => array(
|
||||
'description' => __( 'Product short description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product short description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Unique identifier.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Current product price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Current product price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'regular_price' => array(
|
||||
'description' => __( 'Product regular price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product regular price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sale_price' => array(
|
||||
'description' => __( 'Product sale price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product sale price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from' => array(
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from_gmt' => array(
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to' => array(
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to_gmt' => array(
|
||||
'description' => __( 'End date of sale price, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'End date of sale price, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'price_html' => array(
|
||||
'description' => __( 'Price formatted in HTML.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Price formatted in HTML.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'on_sale' => array(
|
||||
'description' => __( 'Shows if the product is on sale.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product is on sale.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'purchasable' => array(
|
||||
'description' => __( 'Shows if the product can be bought.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product can be bought.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_sales' => array(
|
||||
'description' => __( 'Amount of sales.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of sales.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'virtual' => array(
|
||||
'description' => __( 'If the product is virtual.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the product is virtual.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloadable' => array(
|
||||
'description' => __( 'If the product is downloadable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the product is downloadable.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloads' => array(
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'File ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'File name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -1675,156 +1675,156 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
),
|
||||
),
|
||||
'download_limit' => array(
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'download_expiry' => array(
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'external_url' => array(
|
||||
'description' => __( 'Product external URL. Only for external products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product external URL. Only for external products.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'button_text' => array(
|
||||
'description' => __( 'Product external button text. Only for external products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product external button text. Only for external products.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_status' => array(
|
||||
'description' => __( 'Tax status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'taxable',
|
||||
'enum' => array( 'taxable', 'shipping', 'none' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'manage_stock' => array(
|
||||
'description' => __( 'Stock management at product level.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock management at product level.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'stock_quantity' => array(
|
||||
'description' => __( 'Stock quantity.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock quantity.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'in_stock' => array(
|
||||
'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders' => array(
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'no',
|
||||
'enum' => array( 'no', 'notify', 'yes' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders_allowed' => array(
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'backordered' => array(
|
||||
'description' => __( 'Shows if the product is on backordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sold_individually' => array(
|
||||
'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'weight' => array(
|
||||
/* translators: %s: weight unit */
|
||||
'description' => sprintf( __( 'Product weight (%s).', 'woocommerce-rest-api' ), $weight_unit ),
|
||||
'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'dimensions' => array(
|
||||
'description' => __( 'Product dimensions.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product dimensions.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'length' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Product length (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'width' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Product width (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'height' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Product height (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping_required' => array(
|
||||
'description' => __( 'Shows if the product need to be shipped.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product need to be shipped.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_taxable' => array(
|
||||
'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_class' => array(
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'shipping_class_id' => array(
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'reviews_allowed' => array(
|
||||
'description' => __( 'Allow reviews.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Allow reviews.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'average_rating' => array(
|
||||
'description' => __( 'Reviews average rating.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviews average rating.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'rating_count' => array(
|
||||
'description' => __( 'Amount of reviews that the product have.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of reviews that the product have.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'related_ids' => array(
|
||||
'description' => __( 'List of related products IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of related products IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1833,7 +1833,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'upsell_ids' => array(
|
||||
'description' => __( 'List of up-sell products IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of up-sell products IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1841,7 +1841,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'cross_sell_ids' => array(
|
||||
'description' => __( 'List of cross-sell products IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of cross-sell products IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1849,35 +1849,35 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'parent_id' => array(
|
||||
'description' => __( 'Product parent ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product parent ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'purchase_note' => array(
|
||||
'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'categories' => array(
|
||||
'description' => __( 'List of categories.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of categories.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Category ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Category name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'Category slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1886,25 +1886,25 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
),
|
||||
),
|
||||
'tags' => array(
|
||||
'description' => __( 'List of tags.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of tags.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tag ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Tag name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'Tag slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1913,59 +1913,59 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
),
|
||||
),
|
||||
'images' => array(
|
||||
'description' => __( 'List of images.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of images.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'position' => array(
|
||||
'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -1973,41 +1973,41 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
),
|
||||
),
|
||||
'attributes' => array(
|
||||
'description' => __( 'List of attributes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of attributes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Attribute ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'position' => array(
|
||||
'description' => __( 'Attribute position.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute position.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'visible' => array(
|
||||
'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'variation' => array(
|
||||
'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'options' => array(
|
||||
'description' => __( 'List of available term names of the attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of available term names of the attribute.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
|
@ -2018,24 +2018,24 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
),
|
||||
),
|
||||
'default_attributes' => array(
|
||||
'description' => __( 'Defaults variation attributes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Defaults variation attributes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Attribute ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'option' => array(
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -2043,7 +2043,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
),
|
||||
),
|
||||
'variations' => array(
|
||||
'description' => __( 'List of variations IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of variations IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
|
@ -2052,7 +2052,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'grouped_products' => array(
|
||||
'description' => __( 'List of grouped products ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of grouped products ID.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -2060,30 +2060,30 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -2107,63 +2107,63 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
$params['orderby']['enum'] = array_merge( $params['orderby']['enum'], array( 'menu_order' ) );
|
||||
|
||||
$params['slug'] = array(
|
||||
'description' => __( 'Limit result set to products with a specific slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with a specific slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['status'] = array(
|
||||
'default' => 'any',
|
||||
'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_merge( array( 'any', 'future', 'trash' ), array_keys( get_post_statuses() ) ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['type'] = array(
|
||||
'description' => __( 'Limit result set to products assigned a specific type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products assigned a specific type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_keys( wc_get_product_types() ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['sku'] = array(
|
||||
'description' => __( 'Limit result set to products with specific SKU(s). Use commas to separate.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with specific SKU(s). Use commas to separate.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['featured'] = array(
|
||||
'description' => __( 'Limit result set to featured products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to featured products.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => 'wc_string_to_bool',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['category'] = array(
|
||||
'description' => __( 'Limit result set to products assigned a specific category ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products assigned a specific category ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['tag'] = array(
|
||||
'description' => __( 'Limit result set to products assigned a specific tag ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products assigned a specific tag ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['shipping_class'] = array(
|
||||
'description' => __( 'Limit result set to products assigned a specific shipping class ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products assigned a specific shipping class ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['attribute'] = array(
|
||||
'description' => __( 'Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['attribute_term'] = array(
|
||||
'description' => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
@ -2171,7 +2171,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
|
||||
if ( wc_tax_enabled() ) {
|
||||
$params['tax_class'] = array(
|
||||
'description' => __( 'Limit result set to products with a specific tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with a specific tax class.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_merge( array( 'standard' ), WC_Tax::get_tax_class_slugs() ),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -2180,25 +2180,25 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
}
|
||||
|
||||
$params['in_stock'] = array(
|
||||
'description' => __( 'Limit result set to products in stock or out of stock.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products in stock or out of stock.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => 'wc_string_to_bool',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['on_sale'] = array(
|
||||
'description' => __( 'Limit result set to products on sale.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products on sale.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => 'wc_string_to_bool',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['min_price'] = array(
|
||||
'description' => __( 'Limit result set to products based on a minimum price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products based on a minimum price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['max_price'] = array(
|
||||
'description' => __( 'Limit result set to products based on a maximum price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products based on a maximum price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
|
|
|
@ -42,7 +42,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
$this->namespace, '/' . $this->rest_base, array(
|
||||
'args' => array(
|
||||
'group' => array(
|
||||
'description' => __( 'Settings group ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Settings group ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -59,7 +59,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/batch', array(
|
||||
'args' => array(
|
||||
'group' => array(
|
||||
'description' => __( 'Settings group ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Settings group ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -77,11 +77,11 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\w-]+)', array(
|
||||
'args' => array(
|
||||
'group' => array(
|
||||
'description' => __( 'Settings group ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Settings group ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -156,13 +156,13 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_group_settings( $group_id ) {
|
||||
if ( empty( $group_id ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$settings = apply_filters( 'woocommerce_settings-' . $group_id, array() );
|
||||
|
||||
if ( empty( $settings ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$filtered_settings = array();
|
||||
|
@ -231,7 +231,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_setting( $group_id, $setting_id ) {
|
||||
if ( empty( $setting_id ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$settings = $this->get_group_settings( $group_id );
|
||||
|
@ -243,13 +243,13 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
$array_key = array_keys( wp_list_pluck( $settings, 'id' ), $setting_id );
|
||||
|
||||
if ( empty( $array_key ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$setting = $settings[ $array_key[0] ];
|
||||
|
||||
if ( ! $this->is_setting_type_valid( $setting['type'] ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
return $setting;
|
||||
|
@ -373,7 +373,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -388,7 +388,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function update_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -502,7 +502,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_title',
|
||||
|
@ -511,7 +511,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -520,7 +520,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -529,7 +529,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Setting value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'array', 'null' ),
|
||||
'items' => array(
|
||||
'type' => array( 'string', 'null' ),
|
||||
|
@ -537,7 +537,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'default' => array(
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'array', 'null' ),
|
||||
'items' => array(
|
||||
'type' => array( 'string', 'null' ),
|
||||
|
@ -546,7 +546,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'tip' => array(
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -555,7 +555,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'placeholder' => array(
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -564,7 +564,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Type of setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Type of setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -574,7 +574,7 @@ class WC_REST_Setting_Options_V2_Controller extends WC_REST_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'options' => array(
|
||||
'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -60,7 +60,7 @@ class WC_REST_Settings_V2_Controller extends WC_REST_Controller {
|
|||
public function get_items( $request ) {
|
||||
$groups = apply_filters( 'woocommerce_settings_groups', array() );
|
||||
if ( empty( $groups ) ) {
|
||||
return new WP_Error( 'rest_setting_groups_empty', __( 'No setting groups have been registered.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'rest_setting_groups_empty', __( 'No setting groups have been registered.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
$defaults = $this->group_defaults();
|
||||
|
@ -176,7 +176,7 @@ class WC_REST_Settings_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -195,31 +195,31 @@ class WC_REST_Settings_V2_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'parent_id' => array(
|
||||
'description' => __( 'ID of parent grouping.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ID of parent grouping.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sub_groups' => array(
|
||||
'description' => __( 'IDs for settings sub groups.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'IDs for settings sub groups.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -51,7 +51,7 @@ class WC_REST_Shipping_Methods_V2_Controller extends WC_REST_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\w-]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -76,7 +76,7 @@ class WC_REST_Shipping_Methods_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'shipping_methods', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class WC_REST_Shipping_Methods_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'shipping_methods', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class WC_REST_Shipping_Methods_V2_Controller extends WC_REST_Controller {
|
|||
$wc_shipping = WC_Shipping::instance();
|
||||
$methods = $wc_shipping->get_shipping_methods();
|
||||
if ( empty( $methods[ $request['id'] ] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$method = $methods[ $request['id'] ];
|
||||
|
@ -195,19 +195,19 @@ class WC_REST_Shipping_Methods_V2_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Method ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Method ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => __( 'Shipping method title.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method title.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Shipping method description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -26,7 +26,7 @@ class WC_REST_Shipping_Zone_Locations_V2_Controller extends WC_REST_Shipping_Zon
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)/locations', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique ID for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique ID for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -85,7 +85,7 @@ class WC_REST_Shipping_Zone_Locations_V2_Controller extends WC_REST_Shipping_Zon
|
|||
}
|
||||
|
||||
if ( 0 === $zone->get_id() ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_locations_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce-rest-api' ), array( 'status' => 403 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_locations_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) );
|
||||
}
|
||||
|
||||
$raw_locations = $request->get_json_params();
|
||||
|
@ -166,12 +166,12 @@ class WC_REST_Shipping_Zone_Locations_V2_Controller extends WC_REST_Shipping_Zon
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'code' => array(
|
||||
'description' => __( 'Shipping zone location code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping zone location code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Shipping zone location type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping zone location type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'country',
|
||||
'enum' => array(
|
||||
|
|
|
@ -26,7 +26,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d]+)/methods', array(
|
||||
'args' => array(
|
||||
'zone_id' => array(
|
||||
'description' => __( 'Unique ID for the zone.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique ID for the zone.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -44,7 +44,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
'method_id' => array(
|
||||
'required' => true,
|
||||
'readonly' => false,
|
||||
'description' => __( 'Shipping method ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method ID.', 'woocommerce' ),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
@ -57,11 +57,11 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'zone_id' => array(
|
||||
'description' => __( 'Unique ID for the zone.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique ID for the zone.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'instance_id' => array(
|
||||
'description' => __( 'Unique ID for the instance.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique ID for the instance.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -84,7 +84,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -118,7 +118,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
}
|
||||
|
||||
if ( false === $method ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$data = $this->prepare_item_for_response( $method, $request );
|
||||
|
@ -174,7 +174,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
}
|
||||
|
||||
if ( false === $method ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( 'Resource cannot be created.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( 'Resource cannot be created.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
$method = $this->update_fields( $instance_id, $method, $request );
|
||||
|
@ -212,7 +212,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
}
|
||||
|
||||
if ( false === $method ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$method = $this->update_fields( $instance_id, $method, $request );
|
||||
|
@ -227,7 +227,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
if ( $force ) {
|
||||
$zone->delete_shipping_method( $instance_id );
|
||||
} else {
|
||||
return new WP_Error( 'rest_trash_not_supported', __( 'Shipping methods do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'rest_trash_not_supported', __( 'Shipping methods do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
}
|
||||
|
||||
if ( false === $method ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$method = $this->update_fields( $instance_id, $method, $request );
|
||||
|
@ -311,7 +311,7 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
}
|
||||
|
||||
if ( $errors_found ) {
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
update_option( $method->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $method->id . '_instance_settings_values', $instance_settings, $method ) );
|
||||
|
@ -433,100 +433,100 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Shipping method instance ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method instance ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'instance_id' => array(
|
||||
'description' => __( 'Shipping method instance ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method instance ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => __( 'Shipping method customer facing title.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method customer facing title.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'order' => array(
|
||||
'description' => __( 'Shipping method sort order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method sort order.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'enabled' => array(
|
||||
'description' => __( 'Shipping method enabled status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method enabled status.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'method_id' => array(
|
||||
'description' => __( 'Shipping method ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'method_title' => array(
|
||||
'description' => __( 'Shipping method title.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method title.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'method_description' => array(
|
||||
'description' => __( 'Shipping method description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'settings' => array(
|
||||
'description' => __( 'Shipping method settings.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping method settings.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Type of setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Type of setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Setting value.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'default' => array(
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'tip' => array(
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'placeholder' => array(
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -38,7 +38,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
'name' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Shipping zone name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping zone name.', 'woocommerce' ),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
@ -51,7 +51,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique ID for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique ID for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -74,7 +74,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -151,7 +151,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $zone->get_id() ) ) );
|
||||
return $response;
|
||||
} else {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( "Resource cannot be created. Check to make sure 'order' and 'name' are present.", 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( "Resource cannot be created. Check to make sure 'order' and 'name' are present.", 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
}
|
||||
|
||||
if ( 0 === $zone->get_id() ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce-rest-api' ), array( 'status' => 403 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) );
|
||||
}
|
||||
|
||||
$zone_changed = false;
|
||||
|
@ -211,7 +211,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
if ( $force ) {
|
||||
$zone->delete();
|
||||
} else {
|
||||
return new WP_Error( 'rest_trash_not_supported', __( 'Shipping zones do not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'rest_trash_not_supported', __( 'Shipping zones do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
@ -278,13 +278,13 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Shipping zone name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping zone name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -292,7 +292,7 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
|
|||
),
|
||||
),
|
||||
'order' => array(
|
||||
'description' => __( 'Shipping zone order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping zone order.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
|
|
@ -56,7 +56,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -84,7 +84,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function update_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'system_status', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -124,97 +124,97 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
public function get_tools() {
|
||||
$tools = array(
|
||||
'clear_transients' => array(
|
||||
'name' => __( 'WooCommerce transients', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Clear transients', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'WooCommerce transients', 'woocommerce' ),
|
||||
'button' => __( 'Clear transients', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ),
|
||||
),
|
||||
'clear_expired_transients' => array(
|
||||
'name' => __( 'Expired transients', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Clear transients', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Expired transients', 'woocommerce' ),
|
||||
'button' => __( 'Clear transients', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ),
|
||||
),
|
||||
'delete_orphaned_variations' => array(
|
||||
'name' => __( 'Orphaned variations', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Delete orphaned variations', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will delete all variations which have no parent.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Orphaned variations', 'woocommerce' ),
|
||||
'button' => __( 'Delete orphaned variations', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will delete all variations which have no parent.', 'woocommerce' ),
|
||||
),
|
||||
'clear_expired_download_permissions' => array(
|
||||
'name' => __( 'Used-up download permissions', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Clean up download permissions', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will delete expired download permissions and permissions with 0 remaining downloads.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Used-up download permissions', 'woocommerce' ),
|
||||
'button' => __( 'Clean up download permissions', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will delete expired download permissions and permissions with 0 remaining downloads.', 'woocommerce' ),
|
||||
),
|
||||
'regenerate_product_lookup_tables' => array(
|
||||
'name' => __( 'Product lookup tables', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Regenerate', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will regenerate product lookup table data. This process may take a while.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Product lookup tables', 'woocommerce' ),
|
||||
'button' => __( 'Regenerate', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will regenerate product lookup table data. This process may take a while.', 'woocommerce' ),
|
||||
),
|
||||
'recount_terms' => array(
|
||||
'name' => __( 'Term counts', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Recount terms', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Term counts', 'woocommerce' ),
|
||||
'button' => __( 'Recount terms', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ),
|
||||
),
|
||||
'reset_roles' => array(
|
||||
'name' => __( 'Capabilities', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Reset capabilities', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Capabilities', 'woocommerce' ),
|
||||
'button' => __( 'Reset capabilities', 'woocommerce' ),
|
||||
'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ),
|
||||
),
|
||||
'clear_sessions' => array(
|
||||
'name' => __( 'Clear customer sessions', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Clear', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Clear customer sessions', 'woocommerce' ),
|
||||
'button' => __( 'Clear', 'woocommerce' ),
|
||||
'desc' => sprintf(
|
||||
'<strong class="red">%1$s</strong> %2$s',
|
||||
__( 'Note:', 'woocommerce-rest-api' ),
|
||||
__( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce-rest-api' )
|
||||
__( 'Note:', 'woocommerce' ),
|
||||
__( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce' )
|
||||
),
|
||||
),
|
||||
'clear_template_cache' => array(
|
||||
'name' => __( 'Clear template cache', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Clear', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Clear template cache', 'woocommerce' ),
|
||||
'button' => __( 'Clear', 'woocommerce' ),
|
||||
'desc' => sprintf(
|
||||
'<strong class="red">%1$s</strong> %2$s',
|
||||
__( 'Note:', 'woocommerce-rest-api' ),
|
||||
__( 'This tool will empty the template cache.', 'woocommerce-rest-api' )
|
||||
__( 'Note:', 'woocommerce' ),
|
||||
__( 'This tool will empty the template cache.', 'woocommerce' )
|
||||
),
|
||||
),
|
||||
'install_pages' => array(
|
||||
'name' => __( 'Create default WooCommerce pages', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Create pages', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Create default WooCommerce pages', 'woocommerce' ),
|
||||
'button' => __( 'Create pages', 'woocommerce' ),
|
||||
'desc' => sprintf(
|
||||
'<strong class="red">%1$s</strong> %2$s',
|
||||
__( 'Note:', 'woocommerce-rest-api' ),
|
||||
__( 'This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce-rest-api' )
|
||||
__( 'Note:', 'woocommerce' ),
|
||||
__( 'This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce' )
|
||||
),
|
||||
),
|
||||
'delete_taxes' => array(
|
||||
'name' => __( 'Delete WooCommerce tax rates', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Delete tax rates', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Delete WooCommerce tax rates', 'woocommerce' ),
|
||||
'button' => __( 'Delete tax rates', 'woocommerce' ),
|
||||
'desc' => sprintf(
|
||||
'<strong class="red">%1$s</strong> %2$s',
|
||||
__( 'Note:', 'woocommerce-rest-api' ),
|
||||
__( 'This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce-rest-api' )
|
||||
__( 'Note:', 'woocommerce' ),
|
||||
__( 'This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce' )
|
||||
),
|
||||
),
|
||||
'regenerate_thumbnails' => array(
|
||||
'name' => __( 'Regenerate shop thumbnails', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Regenerate', 'woocommerce-rest-api' ),
|
||||
'desc' => __( 'This will regenerate all shop thumbnails to match your theme and/or image settings.', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Regenerate shop thumbnails', 'woocommerce' ),
|
||||
'button' => __( 'Regenerate', 'woocommerce' ),
|
||||
'desc' => __( 'This will regenerate all shop thumbnails to match your theme and/or image settings.', 'woocommerce' ),
|
||||
),
|
||||
'db_update_routine' => array(
|
||||
'name' => __( 'Update database', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Update database', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Update database', 'woocommerce' ),
|
||||
'button' => __( 'Update database', 'woocommerce' ),
|
||||
'desc' => sprintf(
|
||||
'<strong class="red">%1$s</strong> %2$s',
|
||||
__( 'Note:', 'woocommerce-rest-api' ),
|
||||
__( 'This tool will update your WooCommerce database to the latest version. Please ensure you make sufficient backups before proceeding.', 'woocommerce-rest-api' )
|
||||
__( 'Note:', 'woocommerce' ),
|
||||
__( 'This tool will update your WooCommerce database to the latest version. Please ensure you make sufficient backups before proceeding.', 'woocommerce' )
|
||||
),
|
||||
),
|
||||
);
|
||||
if ( method_exists( 'WC_Install', 'verify_base_tables' ) ) {
|
||||
$tools['verify_db_tables'] = array(
|
||||
'name' => __( 'Verify base database tables', 'woocommerce-rest-api' ),
|
||||
'button' => __( 'Verify database', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Verify base database tables', 'woocommerce' ),
|
||||
'button' => __( 'Verify database', 'woocommerce' ),
|
||||
'desc' => sprintf(
|
||||
__( 'Verify if all base database tables are present.', 'woocommerce-rest-api' )
|
||||
__( 'Verify if all base database tables are present.', 'woocommerce' )
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
public function get_item( $request ) {
|
||||
$tools = $this->get_tools();
|
||||
if ( empty( $tools[ $request['id'] ] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
$tool = $tools[ $request['id'] ];
|
||||
return rest_ensure_response(
|
||||
|
@ -291,7 +291,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
public function update_item( $request ) {
|
||||
$tools = $this->get_tools();
|
||||
if ( empty( $tools[ $request['id'] ] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$tool = $tools[ $request['id'] ];
|
||||
|
@ -349,7 +349,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier for the tool.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier for the tool.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -357,7 +357,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Tool name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tool name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -365,7 +365,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'action' => array(
|
||||
'description' => __( 'What running the tool will do.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'What running the tool will do.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -373,7 +373,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Tool description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tool description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -381,12 +381,12 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'success' => array(
|
||||
'description' => __( 'Did the tool run successfully?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Did the tool run successfully?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'message' => array(
|
||||
'description' => __( 'Tool return message.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tool return message.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -453,12 +453,12 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
WC_Cache_Helper::get_transient_version( 'shipping', true );
|
||||
$message = __( 'Product transients cleared', 'woocommerce-rest-api' );
|
||||
$message = __( 'Product transients cleared', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'clear_expired_transients':
|
||||
/* translators: %d: amount of expired transients */
|
||||
$message = sprintf( __( '%d transients rows cleared', 'woocommerce-rest-api' ), wc_delete_expired_transients() );
|
||||
$message = sprintf( __( '%d transients rows cleared', 'woocommerce' ), wc_delete_expired_transients() );
|
||||
break;
|
||||
|
||||
case 'delete_orphaned_variations':
|
||||
|
@ -472,7 +472,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
)
|
||||
);
|
||||
/* translators: %d: amount of orphaned variations */
|
||||
$message = sprintf( __( '%d orphaned variations deleted', 'woocommerce-rest-api' ), $result );
|
||||
$message = sprintf( __( '%d orphaned variations deleted', 'woocommerce' ), $result );
|
||||
break;
|
||||
|
||||
case 'clear_expired_download_permissions':
|
||||
|
@ -487,20 +487,20 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
)
|
||||
);
|
||||
/* translators: %d: amount of permissions */
|
||||
$message = sprintf( __( '%d permissions deleted', 'woocommerce-rest-api' ), $result );
|
||||
$message = sprintf( __( '%d permissions deleted', 'woocommerce' ), $result );
|
||||
break;
|
||||
|
||||
case 'regenerate_product_lookup_tables':
|
||||
if ( ! wc_update_product_lookup_tables_is_running() ) {
|
||||
wc_update_product_lookup_tables();
|
||||
}
|
||||
$message = __( 'Lookup tables are regenerating', 'woocommerce-rest-api' );
|
||||
$message = __( 'Lookup tables are regenerating', 'woocommerce' );
|
||||
break;
|
||||
case 'reset_roles':
|
||||
// Remove then re-add caps and roles.
|
||||
WC_Install::remove_roles();
|
||||
WC_Install::create_roles();
|
||||
$message = __( 'Roles successfully reset', 'woocommerce-rest-api' );
|
||||
$message = __( 'Roles successfully reset', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'recount_terms':
|
||||
|
@ -520,7 +520,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
)
|
||||
);
|
||||
_wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), true, false );
|
||||
$message = __( 'Terms successfully recounted', 'woocommerce-rest-api' );
|
||||
$message = __( 'Terms successfully recounted', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'clear_sessions':
|
||||
|
@ -528,12 +528,12 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
$result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok.
|
||||
wp_cache_flush();
|
||||
/* translators: %d: amount of sessions */
|
||||
$message = sprintf( __( 'Deleted all active sessions, and %d saved carts.', 'woocommerce-rest-api' ), absint( $result ) );
|
||||
$message = sprintf( __( 'Deleted all active sessions, and %d saved carts.', 'woocommerce' ), absint( $result ) );
|
||||
break;
|
||||
|
||||
case 'install_pages':
|
||||
WC_Install::create_pages();
|
||||
$message = __( 'All missing WooCommerce pages successfully installed', 'woocommerce-rest-api' );
|
||||
$message = __( 'All missing WooCommerce pages successfully installed', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'delete_taxes':
|
||||
|
@ -545,12 +545,12 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
} else {
|
||||
WC_Cache_Helper::incr_cache_prefix( 'taxes' );
|
||||
}
|
||||
$message = __( 'Tax rates successfully deleted', 'woocommerce-rest-api' );
|
||||
$message = __( 'Tax rates successfully deleted', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'regenerate_thumbnails':
|
||||
WC_Regenerate_Images::queue_image_regeneration();
|
||||
$message = __( 'Thumbnail regeneration has been scheduled to run in the background.', 'woocommerce-rest-api' );
|
||||
$message = __( 'Thumbnail regeneration has been scheduled to run in the background.', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'db_update_routine':
|
||||
|
@ -558,31 +558,31 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
// Used to fire an action added in WP_Background_Process::_construct() that calls WP_Background_Process::handle_cron_healthcheck().
|
||||
// This method will make sure the database updates are executed even if cron is disabled. Nothing will happen if the updates are already running.
|
||||
do_action( 'wp_' . $blog_id . '_wc_updater_cron' );
|
||||
$message = __( 'Database upgrade routine has been scheduled to run in the background.', 'woocommerce-rest-api' );
|
||||
$message = __( 'Database upgrade routine has been scheduled to run in the background.', 'woocommerce' );
|
||||
break;
|
||||
|
||||
case 'clear_template_cache':
|
||||
if ( function_exists( 'wc_clear_template_cache' ) ) {
|
||||
wc_clear_template_cache();
|
||||
$message = __( 'Template cache cleared.', 'woocommerce-rest-api' );
|
||||
$message = __( 'Template cache cleared.', 'woocommerce' );
|
||||
} else {
|
||||
$message = __( 'The active version of WooCommerce does not support template cache clearing.', 'woocommerce-rest-api' );
|
||||
$message = __( 'The active version of WooCommerce does not support template cache clearing.', 'woocommerce' );
|
||||
$ran = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'verify_db_tables':
|
||||
if ( ! method_exists( 'WC_Install', 'verify_base_tables' ) ) {
|
||||
$message = __( 'You need WooCommerce 4.2 or newer to run this tool.', 'woocommerce-rest-api' );
|
||||
$message = __( 'You need WooCommerce 4.2 or newer to run this tool.', 'woocommerce' );
|
||||
$ran = false;
|
||||
break;
|
||||
}
|
||||
// Try to manually create table again.
|
||||
$missing_tables = WC_Install::verify_base_tables( true, true );
|
||||
if ( 0 === count( $missing_tables ) ) {
|
||||
$message = __( 'Database verified successfully.', 'woocommerce-rest-api' );
|
||||
$message = __( 'Database verified successfully.', 'woocommerce' );
|
||||
} else {
|
||||
$message = __( 'Verifying database... One or more tables are still missing: ', 'woocommerce-rest-api' );
|
||||
$message = __( 'Verifying database... One or more tables are still missing: ', 'woocommerce' );
|
||||
$message .= implode( ', ', $missing_tables );
|
||||
$ran = false;
|
||||
}
|
||||
|
@ -599,13 +599,13 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
|
|||
$callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback;
|
||||
$ran = false;
|
||||
/* translators: %s: callback string */
|
||||
$message = sprintf( __( 'There was an error calling %s', 'woocommerce-rest-api' ), $callback_string );
|
||||
$message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string );
|
||||
} else {
|
||||
$message = __( 'Tool ran.', 'woocommerce-rest-api' );
|
||||
$message = __( 'Tool ran.', 'woocommerce' );
|
||||
}
|
||||
} else {
|
||||
$ran = false;
|
||||
$message = __( 'There was an error calling this tool. There is no callback present.', 'woocommerce-rest-api' );
|
||||
$message = __( 'There was an error calling this tool. There is no callback present.', 'woocommerce' );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -90,195 +90,195 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'environment' => array(
|
||||
'description' => __( 'Environment.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Environment.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'home_url' => array(
|
||||
'description' => __( 'Home URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Home URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'site_url' => array(
|
||||
'description' => __( 'Site URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Site URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'version' => array(
|
||||
'description' => __( 'WooCommerce version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WooCommerce version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'log_directory' => array(
|
||||
'description' => __( 'Log directory.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Log directory.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'log_directory_writable' => array(
|
||||
'description' => __( 'Is log directory writable?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is log directory writable?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'wp_version' => array(
|
||||
'description' => __( 'WordPress version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WordPress version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'wp_multisite' => array(
|
||||
'description' => __( 'Is WordPress multisite?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is WordPress multisite?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'wp_memory_limit' => array(
|
||||
'description' => __( 'WordPress memory limit.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WordPress memory limit.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'wp_debug_mode' => array(
|
||||
'description' => __( 'Is WordPress debug mode active?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'wp_cron' => array(
|
||||
'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'language' => array(
|
||||
'description' => __( 'WordPress language.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WordPress language.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'server_info' => array(
|
||||
'description' => __( 'Server info.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Server info.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'php_version' => array(
|
||||
'description' => __( 'PHP version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'PHP version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'php_post_max_size' => array(
|
||||
'description' => __( 'PHP post max size.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'PHP post max size.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'php_max_execution_time' => array(
|
||||
'description' => __( 'PHP max execution time.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'PHP max execution time.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'php_max_input_vars' => array(
|
||||
'description' => __( 'PHP max input vars.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'PHP max input vars.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'curl_version' => array(
|
||||
'description' => __( 'cURL version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'cURL version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'suhosin_installed' => array(
|
||||
'description' => __( 'Is SUHOSIN installed?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is SUHOSIN installed?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'max_upload_size' => array(
|
||||
'description' => __( 'Max upload size.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Max upload size.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'mysql_version' => array(
|
||||
'description' => __( 'MySQL version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'MySQL version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'mysql_version_string' => array(
|
||||
'description' => __( 'MySQL version string.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'MySQL version string.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'default_timezone' => array(
|
||||
'description' => __( 'Default timezone.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default timezone.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'fsockopen_or_curl_enabled' => array(
|
||||
'description' => __( 'Is fsockopen/cURL enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is fsockopen/cURL enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'soapclient_enabled' => array(
|
||||
'description' => __( 'Is SoapClient class enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is SoapClient class enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'domdocument_enabled' => array(
|
||||
'description' => __( 'Is DomDocument class enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is DomDocument class enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'gzip_enabled' => array(
|
||||
'description' => __( 'Is GZip enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is GZip enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'mbstring_enabled' => array(
|
||||
'description' => __( 'Is mbstring enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is mbstring enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'remote_post_successful' => array(
|
||||
'description' => __( 'Remote POST successful?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Remote POST successful?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'remote_post_response' => array(
|
||||
'description' => __( 'Remote POST response.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Remote POST response.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'remote_get_successful' => array(
|
||||
'description' => __( 'Remote GET successful?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Remote GET successful?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'remote_get_response' => array(
|
||||
'description' => __( 'Remote GET response.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Remote GET response.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -286,31 +286,31 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'database' => array(
|
||||
'description' => __( 'Database.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Database.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'wc_database_version' => array(
|
||||
'description' => __( 'WC database version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WC database version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'database_prefix' => array(
|
||||
'description' => __( 'Database prefix.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Database prefix.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'maxmind_geoip_database' => array(
|
||||
'description' => __( 'MaxMind GeoIP database.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'MaxMind GeoIP database.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'database_tables' => array(
|
||||
'description' => __( 'Database tables.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Database tables.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -321,7 +321,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'active_plugins' => array(
|
||||
'description' => __( 'Active plugins.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Active plugins.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -330,7 +330,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'inactive_plugins' => array(
|
||||
'description' => __( 'Inactive plugins.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Inactive plugins.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -339,7 +339,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'dropins_mu_plugins' => array(
|
||||
'description' => __( 'Dropins & MU plugins.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Dropins & MU plugins.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -348,62 +348,62 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'theme' => array(
|
||||
'description' => __( 'Theme.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Theme.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'name' => array(
|
||||
'description' => __( 'Theme name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Theme name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'version' => array(
|
||||
'description' => __( 'Theme version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Theme version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'version_latest' => array(
|
||||
'description' => __( 'Latest version of theme.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Latest version of theme.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'author_url' => array(
|
||||
'description' => __( 'Theme author URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Theme author URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'is_child_theme' => array(
|
||||
'description' => __( 'Is this theme a child theme?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is this theme a child theme?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'has_woocommerce_support' => array(
|
||||
'description' => __( 'Does the theme declare WooCommerce support?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Does the theme declare WooCommerce support?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'has_woocommerce_file' => array(
|
||||
'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'has_outdated_templates' => array(
|
||||
'description' => __( 'Does this theme have outdated templates?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Does this theme have outdated templates?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'overrides' => array(
|
||||
'description' => __( 'Template overrides.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Template overrides.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -412,19 +412,19 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'parent_name' => array(
|
||||
'description' => __( 'Parent theme name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Parent theme name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'parent_version' => array(
|
||||
'description' => __( 'Parent theme version.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Parent theme version.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'parent_author_url' => array(
|
||||
'description' => __( 'Parent theme author URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Parent theme author URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view' ),
|
||||
|
@ -433,67 +433,67 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'settings' => array(
|
||||
'description' => __( 'Settings.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Settings.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'api_enabled' => array(
|
||||
'description' => __( 'REST API enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'REST API enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'force_ssl' => array(
|
||||
'description' => __( 'SSL forced?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'SSL forced?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'currency' => array(
|
||||
'description' => __( 'Currency.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Currency.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'currency_symbol' => array(
|
||||
'description' => __( 'Currency symbol.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Currency symbol.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'currency_position' => array(
|
||||
'description' => __( 'Currency position.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Currency position.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'thousand_separator' => array(
|
||||
'description' => __( 'Thousand separator.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Thousand separator.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'decimal_separator' => array(
|
||||
'description' => __( 'Decimal separator.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Decimal separator.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'number_of_decimals' => array(
|
||||
'description' => __( 'Number of decimals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of decimals.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'geolocation_enabled' => array(
|
||||
'description' => __( 'Geolocation enabled?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Geolocation enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'taxonomies' => array(
|
||||
'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -502,7 +502,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'product_visibility_terms' => array(
|
||||
'description' => __( 'Terms in the product visibility taxonomy.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Terms in the product visibility taxonomy.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -513,19 +513,19 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'security' => array(
|
||||
'description' => __( 'Security.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Security.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'secure_connection' => array(
|
||||
'description' => __( 'Is the connection to your store secure?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is the connection to your store secure?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'hide_errors' => array(
|
||||
'description' => __( 'Hide errors from visitors?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Hide errors from visitors?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -533,7 +533,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'pages' => array(
|
||||
'description' => __( 'WooCommerce pages.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WooCommerce pages.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -542,7 +542,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'post_type_counts' => array(
|
||||
'description' => __( 'Total post count.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Total post count.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -657,7 +657,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
$curl_version = curl_version();
|
||||
$curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
|
||||
} elseif ( extension_loaded( 'curl' ) ) {
|
||||
$curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce-rest-api' );
|
||||
$curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce' );
|
||||
}
|
||||
|
||||
// WP memory limit.
|
||||
|
@ -1156,23 +1156,23 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
public function get_pages() {
|
||||
// WC pages to check against.
|
||||
$check_pages = array(
|
||||
_x( 'Shop base', 'Page setting', 'woocommerce-rest-api' ) => array(
|
||||
_x( 'Shop base', 'Page setting', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_shop_page_id',
|
||||
'shortcode' => '',
|
||||
),
|
||||
_x( 'Cart', 'Page setting', 'woocommerce-rest-api' ) => array(
|
||||
_x( 'Cart', 'Page setting', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_cart_page_id',
|
||||
'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']',
|
||||
),
|
||||
_x( 'Checkout', 'Page setting', 'woocommerce-rest-api' ) => array(
|
||||
_x( 'Checkout', 'Page setting', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_checkout_page_id',
|
||||
'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']',
|
||||
),
|
||||
_x( 'My account', 'Page setting', 'woocommerce-rest-api' ) => array(
|
||||
_x( 'My account', 'Page setting', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_myaccount_page_id',
|
||||
'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']',
|
||||
),
|
||||
_x( 'Terms and conditions', 'Page setting', 'woocommerce-rest-api' ) => array(
|
||||
_x( 'Terms and conditions', 'Page setting', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_terms_page_id',
|
||||
'shortcode' => '',
|
||||
),
|
||||
|
|
|
@ -67,32 +67,32 @@ class WC_REST_Webhook_Deliveries_V2_Controller extends WC_REST_Webhook_Deliverie
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'duration' => array(
|
||||
'description' => __( 'The delivery duration, in seconds.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The delivery duration, in seconds.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'summary' => array(
|
||||
'description' => __( 'A friendly summary of the response including the HTTP response code, message, and body.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A friendly summary of the response including the HTTP response code, message, and body.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'request_url' => array(
|
||||
'description' => __( 'The URL where the webhook was delivered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The URL where the webhook was delivered.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'request_headers' => array(
|
||||
'description' => __( 'Request headers.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Request headers.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -101,25 +101,25 @@ class WC_REST_Webhook_Deliveries_V2_Controller extends WC_REST_Webhook_Deliverie
|
|||
),
|
||||
),
|
||||
'request_body' => array(
|
||||
'description' => __( 'Request body.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Request body.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'response_code' => array(
|
||||
'description' => __( 'The HTTP response code from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The HTTP response code from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'response_message' => array(
|
||||
'description' => __( 'The HTTP response message from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The HTTP response message from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'response_headers' => array(
|
||||
'description' => __( 'Array of the response headers from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Array of the response headers from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
@ -128,19 +128,19 @@ class WC_REST_Webhook_Deliveries_V2_Controller extends WC_REST_Webhook_Deliverie
|
|||
),
|
||||
),
|
||||
'response_body' => array(
|
||||
'description' => __( 'The response body from the receiving server.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The response body from the receiving server.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the webhook delivery was logged, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the webhook delivery was logged, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the webhook delivery was logged, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the webhook delivery was logged, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -36,7 +36,7 @@ class WC_REST_Webhooks_V2_Controller extends WC_REST_Webhooks_V1_Controller {
|
|||
$webhook = wc_get_webhook( $id );
|
||||
|
||||
if ( empty( $webhook ) || is_null( $webhook ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
@ -95,42 +95,42 @@ class WC_REST_Webhooks_V2_Controller extends WC_REST_Webhooks_V1_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'A friendly name for the webhook.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A friendly name for the webhook.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Webhook status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'active',
|
||||
'enum' => array_keys( wc_get_webhook_statuses() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'topic' => array(
|
||||
'description' => __( 'Webhook topic.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook topic.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'resource' => array(
|
||||
'description' => __( 'Webhook resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'event' => array(
|
||||
'description' => __( 'Webhook event.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Webhook event.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'hooks' => array(
|
||||
'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -139,37 +139,37 @@ class WC_REST_Webhooks_V2_Controller extends WC_REST_Webhooks_V1_Controller {
|
|||
),
|
||||
),
|
||||
'delivery_url' => array(
|
||||
'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'secret' => array(
|
||||
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the webhook was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the webhook was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the webhook was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the webhook was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -139,7 +139,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
|
||||
if ( $total > $limit ) {
|
||||
/* translators: %s: items limit */
|
||||
return new WP_Error( 'woocommerce_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce-rest-api' ), $limit ), array( 'status' => 413 ) );
|
||||
return new WP_Error( 'woocommerce_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), array( 'status' => 413 ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -288,7 +288,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
if ( array_key_exists( $value, $setting['options'] ) ) {
|
||||
return $value;
|
||||
} else {
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! is_array( $values ) ) {
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$final_values = array();
|
||||
|
@ -329,7 +329,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
public function validate_setting_image_width_field( $values, $setting ) {
|
||||
if ( ! is_array( $values ) ) {
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$current = $setting['value'];
|
||||
|
@ -372,7 +372,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
$value = isset( $setting['default'] ) ? $setting['default'] : 'no';
|
||||
return $value;
|
||||
} else {
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'create' => array(
|
||||
'description' => __( 'List of created resources.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of created resources.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
|
@ -440,7 +440,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
),
|
||||
),
|
||||
'update' => array(
|
||||
'description' => __( 'List of updated resources.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of updated resources.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
|
@ -448,7 +448,7 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
),
|
||||
),
|
||||
'delete' => array(
|
||||
'description' => __( 'List of delete resources.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of delete resources.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
*/
|
||||
protected function get_object( $id ) {
|
||||
// translators: %s: Class method name.
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce-rest-api' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$object = $this->get_object( (int) $request['id'] );
|
||||
|
||||
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'read', $object->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -69,7 +69,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$object = $this->get_object( (int) $request['id'] );
|
||||
|
||||
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $object->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -85,7 +85,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$object = $this->get_object( (int) $request['id'] );
|
||||
|
||||
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -113,7 +113,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
*/
|
||||
protected function prepare_object_for_response( $object, $request ) {
|
||||
// translators: %s: Class method name.
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce-rest-api' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
*/
|
||||
protected function prepare_object_for_database( $request, $creating = false ) {
|
||||
// translators: %s: Class method name.
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce-rest-api' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +139,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$object = $this->get_object( (int) $request['id'] );
|
||||
|
||||
if ( ! $object || 0 === $object->get_id() ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$data = $this->prepare_object_for_response( $object, $request );
|
||||
|
@ -187,7 +187,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$object = $this->save_object( $request, true );
|
||||
|
@ -234,7 +234,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$object = $this->get_object( (int) $request['id'] );
|
||||
|
||||
if ( ! $object || 0 === $object->get_id() ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$object = $this->save_object( $request, false );
|
||||
|
@ -417,7 +417,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$result = false;
|
||||
|
||||
if ( ! $object || 0 === $object->get_id() ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) );
|
||||
|
@ -434,7 +434,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -448,14 +448,14 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
// If we don't support trashing for this type, error out.
|
||||
if ( ! $supports_trash ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
// Otherwise, only trash if we haven't already.
|
||||
if ( is_callable( array( $object, 'get_status' ) ) ) {
|
||||
if ( 'trash' === $object->get_status() ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 410 ) );
|
||||
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
|
||||
}
|
||||
|
||||
$object->delete();
|
||||
|
@ -465,7 +465,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
if ( ! $result ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -511,7 +511,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['page'] = array(
|
||||
'description' => __( 'Current page of the collection.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Current page of the collection.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => 1,
|
||||
'sanitize_callback' => 'absint',
|
||||
|
@ -519,7 +519,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
'minimum' => 1,
|
||||
);
|
||||
$params['per_page'] = array(
|
||||
'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => 10,
|
||||
'minimum' => 1,
|
||||
|
@ -528,25 +528,25 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['search'] = array(
|
||||
'description' => __( 'Limit results to those matching a string.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit results to those matching a string.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['after'] = array(
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['before'] = array(
|
||||
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -555,7 +555,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -564,20 +564,20 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'date',
|
||||
'enum' => array(
|
||||
|
@ -593,7 +593,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
if ( $this->hierarchical ) {
|
||||
$params['parent'] = array(
|
||||
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -602,7 +602,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
'default' => array(),
|
||||
);
|
||||
$params['parent_exclude'] = array(
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
|
|
@ -76,43 +76,43 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the customer was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the customer was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the customer was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the customer was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the customer was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the customer was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'The email address for the customer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The email address for the customer.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'first_name' => array(
|
||||
'description' => __( 'Customer first name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer first name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -120,7 +120,7 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
|
|||
),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Customer last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -128,13 +128,13 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
|
|||
),
|
||||
),
|
||||
'role' => array(
|
||||
'description' => __( 'Customer role.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer role.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'username' => array(
|
||||
'description' => __( 'Customer login name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer login name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -142,157 +142,157 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
|
|||
),
|
||||
),
|
||||
'password' => array(
|
||||
'description' => __( 'Customer password.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer password.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'billing' => array(
|
||||
'description' => __( 'List of billing address data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of billing address data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'email' => array(
|
||||
'description' => __( 'Email address.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Email address.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'phone' => array(
|
||||
'description' => __( 'Phone number.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Phone number.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping' => array(
|
||||
'description' => __( 'List of shipping address data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of shipping address data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'first_name' => array(
|
||||
'description' => __( 'First name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'First name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => __( 'Last name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Last name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'company' => array(
|
||||
'description' => __( 'Company name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Company name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_1' => array(
|
||||
'description' => __( 'Address line 1', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 1', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'address_2' => array(
|
||||
'description' => __( 'Address line 2', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Address line 2', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'city' => array(
|
||||
'description' => __( 'City name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'City name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'state' => array(
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'description' => __( 'Postal code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Postal code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'country' => array(
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO code of the country.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'is_paying_customer' => array(
|
||||
'description' => __( 'Is the customer a paying customer?', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Is the customer a paying customer?', 'woocommerce' ),
|
||||
'type' => 'bool',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'avatar_url' => array(
|
||||
'description' => __( 'Avatar URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Avatar URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
|
|
@ -56,7 +56,7 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
||||
'args' => array(
|
||||
'continent' => array(
|
||||
'description' => __( '2 character continent code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( '2 character continent code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -182,7 +182,7 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
public function get_item( $request ) {
|
||||
$data = $this->get_continent( strtoupper( $request['location'] ), $request );
|
||||
if ( empty( $data ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
return $this->prepare_item_for_response( $data, $request );
|
||||
}
|
||||
|
@ -247,19 +247,19 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( '2 character continent code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( '2 character continent code.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Full name of continent.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Full name of continent.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'countries' => array(
|
||||
'type' => 'array',
|
||||
'description' => __( 'List of countries on this continent.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of countries on this continent.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'items' => array(
|
||||
|
@ -269,49 +269,49 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'currency_code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Default ISO4127 alpha-3 currency code for the country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default ISO4127 alpha-3 currency code for the country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'currency_pos' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Currency symbol position for this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Currency symbol position for this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'decimal_sep' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Decimal separator for displayed prices for this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Decimal separator for displayed prices for this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'dimension_unit' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'The unit lengths are defined in for this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The unit lengths are defined in for this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Full name of country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Full name of country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'num_decimals' => array(
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Number of decimal points shown in displayed prices for this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of decimal points shown in displayed prices for this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'states' => array(
|
||||
'type' => 'array',
|
||||
'description' => __( 'List of states in this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of states in this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'items' => array(
|
||||
|
@ -321,13 +321,13 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'State code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'State code.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Full name of state.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Full name of state.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
|
@ -336,13 +336,13 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
),
|
||||
'thousand_sep' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Thousands separator for displayed prices in this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Thousands separator for displayed prices in this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'weight_unit' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'The unit weights are defined in for this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The unit weights are defined in for this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
|
|
|
@ -58,7 +58,7 @@ class WC_REST_Data_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -72,7 +72,7 @@ class WC_REST_Data_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -90,15 +90,15 @@ class WC_REST_Data_Controller extends WC_REST_Controller {
|
|||
$resources = array(
|
||||
array(
|
||||
'slug' => 'continents',
|
||||
'description' => __( 'List of supported continents, countries, and states.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of supported continents, countries, and states.', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'slug' => 'countries',
|
||||
'description' => __( 'List of supported states in a given country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of supported states in a given country.', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'slug' => 'currencies',
|
||||
'description' => __( 'List of supported currencies.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of supported currencies.', 'woocommerce' ),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -165,13 +165,13 @@ class WC_REST_Data_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'Data resource ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Data resource ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Data resource description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Data resource description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -56,7 +56,7 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
||||
'args' => array(
|
||||
'location' => array(
|
||||
'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -130,7 +130,7 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
public function get_item( $request ) {
|
||||
$data = $this->get_country( strtoupper( $request['location'] ), $request );
|
||||
if ( empty( $data ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_data_invalid_location', __( 'There are no locations matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
return $this->prepare_item_for_response( $data, $request );
|
||||
}
|
||||
|
@ -197,19 +197,19 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Full name of country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Full name of country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'states' => array(
|
||||
'type' => 'array',
|
||||
'description' => __( 'List of states in this country.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of states in this country.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
'items' => array(
|
||||
|
@ -219,13 +219,13 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'State code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'State code.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Full name of state.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Full name of state.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
|
|
|
@ -63,7 +63,7 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
'permission_callback' => array( $this, 'get_item_permissions_check' ),
|
||||
'args' => array(
|
||||
'location' => array(
|
||||
'description' => __( 'ISO4217 currency code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO4217 currency code.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -123,7 +123,7 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
public function get_item( $request ) {
|
||||
$data = $this->get_currency( strtoupper( $request['currency'] ), $request );
|
||||
if ( empty( $data ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_data_invalid_currency', __( 'There are no currencies matching these parameters.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_data_invalid_currency', __( 'There are no currencies matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
return $this->prepare_item_for_response( $data, $request );
|
||||
}
|
||||
|
@ -197,19 +197,19 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'ISO4217 currency code.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ISO4217 currency code.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Full name of currency.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Full name of currency.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'symbol' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Currency symbol.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Currency symbol.', 'woocommerce' ),
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
|
|
|
@ -35,7 +35,7 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Order_Notes_V2_Controller {
|
|||
public function prepare_item_for_response( $note, $request ) {
|
||||
$data = array(
|
||||
'id' => (int) $note->comment_ID,
|
||||
'author' => __( 'woocommerce', 'woocommerce-rest-api' ) === $note->comment_author ? 'system' : $note->comment_author,
|
||||
'author' => __( 'woocommerce', 'woocommerce' ) === $note->comment_author ? 'system' : $note->comment_author,
|
||||
'date_created' => wc_rest_prepare_date_response( $note->comment_date ),
|
||||
'date_created_gmt' => wc_rest_prepare_date_response( $note->comment_date_gmt ),
|
||||
'note' => $note->comment_content,
|
||||
|
@ -70,20 +70,20 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Order_Notes_V2_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order || $this->post_type !== $order->get_type() ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
// Create the note.
|
||||
$note_id = $order->add_order_note( $request['note'], $request['customer_note'], $request['added_by_user'] );
|
||||
|
||||
if ( ! $note_id ) {
|
||||
return new WP_Error( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
$note = get_comment( $note_id );
|
||||
|
@ -119,42 +119,42 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Order_Notes_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'author' => array(
|
||||
'description' => __( 'Order note author.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order note author.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the order note was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the order note was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'note' => array(
|
||||
'description' => __( 'Order note content.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order note content.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'customer_note' => array(
|
||||
'description' => __( 'If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'added_by_user' => array(
|
||||
'description' => __( 'If true, this note will be attributed to the current user. If false, the note will be attributed to the system.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If true, this note will be attributed to the current user. If false, the note will be attributed to the system.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'edit' ),
|
||||
|
|
|
@ -37,11 +37,11 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Order_Refunds_V2_Controll
|
|||
$order = wc_get_order( (int) $request['order_id'] );
|
||||
|
||||
if ( ! $order ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
|
||||
}
|
||||
|
||||
if ( 0 > $request['amount'] ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Create the refund.
|
||||
|
@ -61,7 +61,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Order_Refunds_V2_Controll
|
|||
}
|
||||
|
||||
if ( ! $refund ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce-rest-api' ), 500 );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
|
|||
if ( is_array( $item ) ) {
|
||||
if ( empty( $item['id'] ) ) {
|
||||
if ( empty( $item['code'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon', __( 'Coupon code is required.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
$results = $order->apply_coupon( wc_clean( $item['code'] ) );
|
||||
|
@ -157,7 +157,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
|
|||
if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] ) {
|
||||
// Make sure customer exists.
|
||||
if ( false === get_user_by( 'id', $request['customer_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce-rest-api' ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 );
|
||||
}
|
||||
|
||||
// Make sure customer is part of blog.
|
||||
|
@ -257,7 +257,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
|
|||
|
||||
$params['status'] = array(
|
||||
'default' => 'any',
|
||||
'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
|
|
|
@ -114,23 +114,23 @@ class WC_REST_Payment_Gateways_Controller extends WC_REST_Payment_Gateways_V2_Co
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Payment gateway ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => __( 'Payment gateway title on checkout.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway title on checkout.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Payment gateway description on checkout.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway description on checkout.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'order' => array(
|
||||
'description' => __( 'Payment gateway sort order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway sort order.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -138,24 +138,24 @@ class WC_REST_Payment_Gateways_Controller extends WC_REST_Payment_Gateways_V2_Co
|
|||
),
|
||||
),
|
||||
'enabled' => array(
|
||||
'description' => __( 'Payment gateway enabled status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway enabled status.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'method_title' => array(
|
||||
'description' => __( 'Payment gateway method title.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway method title.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'method_description' => array(
|
||||
'description' => __( 'Payment gateway method description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway method description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'method_supports' => array(
|
||||
'description' => __( 'Supported features for this payment gateway.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Supported features for this payment gateway.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -164,54 +164,54 @@ class WC_REST_Payment_Gateways_Controller extends WC_REST_Payment_Gateways_V2_Co
|
|||
),
|
||||
),
|
||||
'settings' => array(
|
||||
'description' => __( 'Payment gateway settings.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Payment gateway settings.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Type of setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Type of setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Setting value.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'default' => array(
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'tip' => array(
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'placeholder' => array(
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -54,7 +54,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -68,7 +68,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -84,7 +84,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( (int) $request['id'] );
|
||||
|
||||
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'read', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -100,7 +100,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( (int) $request['id'] );
|
||||
|
||||
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -116,7 +116,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( (int) $request['id'] );
|
||||
|
||||
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -131,7 +131,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'batch' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -148,9 +148,9 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( $id );
|
||||
|
||||
if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
} elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$data = $this->prepare_item_for_response( $post, $request );
|
||||
|
@ -172,7 +172,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$post = $this->prepare_item_for_database( $request );
|
||||
|
@ -255,9 +255,9 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( $id );
|
||||
|
||||
if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
} elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$post = $this->prepare_item_for_database( $request );
|
||||
|
@ -418,7 +418,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$supports_trash = EMPTY_TRASH_DAYS > 0;
|
||||
|
@ -435,7 +435,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
|
||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -448,13 +448,13 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
// If we don't support trashing for this type, error out.
|
||||
if ( ! $supports_trash ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
// Otherwise, only trash if we haven't already.
|
||||
if ( 'trash' === $post->post_status ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 410 ) );
|
||||
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
|
||||
}
|
||||
|
||||
// (Note that internally this falls through to `wp_delete_post` if
|
||||
|
@ -464,7 +464,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
|
||||
if ( ! $result ) {
|
||||
/* translators: %s: post type */
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -621,19 +621,19 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['after'] = array(
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['before'] = array(
|
||||
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -642,7 +642,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -651,20 +651,20 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'date',
|
||||
'enum' => array(
|
||||
|
@ -682,7 +682,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
|
||||
if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) {
|
||||
$params['parent'] = array(
|
||||
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -691,7 +691,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
'default' => array(),
|
||||
);
|
||||
$params['parent_exclude'] = array(
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -704,7 +704,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
if ( 'wc/v1' === $this->namespace ) {
|
||||
$params['filter'] = array(
|
||||
'type' => 'object',
|
||||
'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,13 +100,13 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Category name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -114,7 +114,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
|
|||
),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -122,12 +122,12 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
|
|||
),
|
||||
),
|
||||
'parent' => array(
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'HTML description of the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -135,71 +135,71 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
|
|||
),
|
||||
),
|
||||
'display' => array(
|
||||
'description' => __( 'Category archive display type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category archive display type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'default',
|
||||
'enum' => array( 'default', 'products', 'subcategories', 'both' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'image' => array(
|
||||
'description' => __( 'Image data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -52,23 +52,23 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
|
||||
'product_id' => array(
|
||||
'required' => true,
|
||||
'description' => __( 'Unique identifier for the product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
'review' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Review content.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Review content.', 'woocommerce' ),
|
||||
),
|
||||
'reviewer' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Name of the reviewer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Name of the reviewer.', 'woocommerce' ),
|
||||
),
|
||||
'reviewer_email' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'description' => __( 'Email of the reviewer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Email of the reviewer.', 'woocommerce' ),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
@ -81,7 +81,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -107,7 +107,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -136,7 +136,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_product_reviews_permissions( 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -153,7 +153,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$review = get_comment( $id );
|
||||
|
||||
if ( $review && ! wc_rest_check_product_reviews_permissions( 'read', $review->comment_ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -167,7 +167,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_product_reviews_permissions( 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -184,7 +184,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$review = get_comment( $id );
|
||||
|
||||
if ( $review && ! wc_rest_check_product_reviews_permissions( 'edit', $review->comment_ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -201,7 +201,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$review = get_comment( $id );
|
||||
|
||||
if ( $review && ! wc_rest_check_product_reviews_permissions( 'delete', $review->comment_ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -215,7 +215,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function batch_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_product_reviews_permissions( 'create' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -371,13 +371,13 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function create_item( $request ) {
|
||||
if ( ! empty( $request['id'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_review_exists', __( 'Cannot create existing product review.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_review_exists', __( 'Cannot create existing product review.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$product_id = (int) $request['product_id'];
|
||||
|
||||
if ( 'product' !== get_post_type( $product_id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$prepared_review = $this->prepare_item_for_database( $request );
|
||||
|
@ -391,7 +391,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
* Do not allow a comment to be created with missing or empty comment_content. See wp_handle_comment_submission().
|
||||
*/
|
||||
if ( empty( $prepared_review['comment_content'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_review_content_invalid', __( 'Invalid review content.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_review_content_invalid', __( 'Invalid review content.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
// Setting remaining values before wp_insert_comment so we can use wp_allow_comment().
|
||||
|
@ -416,7 +416,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_review );
|
||||
if ( is_wp_error( $check_comment_lengths ) ) {
|
||||
$error_code = str_replace( array( 'comment_author', 'comment_content' ), array( 'reviewer', 'review_content' ), $check_comment_lengths->get_error_code() );
|
||||
return new WP_Error( 'woocommerce_rest_' . $error_code, __( 'Product review field exceeds maximum length allowed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_' . $error_code, __( 'Product review field exceeds maximum length allowed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$prepared_review['comment_parent'] = 0;
|
||||
|
@ -457,7 +457,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$review_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_review ) ) );
|
||||
|
||||
if ( ! $review_id ) {
|
||||
return new WP_Error( 'woocommerce_rest_review_failed_create', __( 'Creating product review failed.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_review_failed_create', __( 'Creating product review failed.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
if ( isset( $request['status'] ) ) {
|
||||
|
@ -527,7 +527,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$id = (int) $review->comment_ID;
|
||||
|
||||
if ( isset( $request['type'] ) && 'review' !== get_comment_type( $id ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_review_invalid_type', __( 'Sorry, you are not allowed to change the comment type.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_review_invalid_type', __( 'Sorry, you are not allowed to change the comment type.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$prepared_args = $this->prepare_item_for_database( $request );
|
||||
|
@ -537,7 +537,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
|
||||
if ( ! empty( $prepared_args['comment_post_ID'] ) ) {
|
||||
if ( 'product' !== get_post_type( (int) $prepared_args['comment_post_ID'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$change = $this->handle_status_param( $request['status'], $id );
|
||||
|
||||
if ( ! $change ) {
|
||||
return new WP_Error( 'woocommerce_rest_review_failed_edit', __( 'Updating review status failed.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_review_failed_edit', __( 'Updating review status failed.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
} elseif ( ! empty( $prepared_args ) ) {
|
||||
if ( is_wp_error( $prepared_args ) ) {
|
||||
|
@ -554,7 +554,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_review_content_invalid', __( 'Invalid review content.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_review_content_invalid', __( 'Invalid review content.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$prepared_args['comment_ID'] = $id;
|
||||
|
@ -562,13 +562,13 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args );
|
||||
if ( is_wp_error( $check_comment_lengths ) ) {
|
||||
$error_code = str_replace( array( 'comment_author', 'comment_content' ), array( 'reviewer', 'review_content' ), $check_comment_lengths->get_error_code() );
|
||||
return new WP_Error( 'woocommerce_rest_' . $error_code, __( 'Product review field exceeds maximum length allowed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_' . $error_code, __( 'Product review field exceeds maximum length allowed.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$updated = wp_update_comment( wp_slash( (array) $prepared_args ) );
|
||||
|
||||
if ( false === $updated ) {
|
||||
return new WP_Error( 'woocommerce_rest_comment_failed_edit', __( 'Updating review failed.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_comment_failed_edit', __( 'Updating review failed.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
if ( isset( $request['status'] ) ) {
|
||||
|
@ -639,11 +639,11 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
// If this type doesn't support trashing, error out.
|
||||
if ( ! $supports_trash ) {
|
||||
/* translators: %s: force=true */
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( "The object does not support trashing. Set '%s' to delete.", 'woocommerce-rest-api' ), 'force=true' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( "The object does not support trashing. Set '%s' to delete.", 'woocommerce' ), 'force=true' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
if ( 'trash' === $review->comment_approved ) {
|
||||
return new WP_Error( 'woocommerce_rest_already_trashed', __( 'The object has already been trashed.', 'woocommerce-rest-api' ), array( 'status' => 410 ) );
|
||||
return new WP_Error( 'woocommerce_rest_already_trashed', __( 'The object has already been trashed.', 'woocommerce' ), array( 'status' => 410 ) );
|
||||
}
|
||||
|
||||
$result = wp_trash_comment( $review->comment_ID );
|
||||
|
@ -652,7 +652,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $result ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The object cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The object cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -828,48 +828,48 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the review was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the review was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'product_id' => array(
|
||||
'description' => __( 'Unique identifier for the product that the review belongs to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the product that the review belongs to.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Status of the review.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Status of the review.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'approved',
|
||||
'enum' => array( 'approved', 'hold', 'spam', 'unspam', 'trash', 'untrash' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'reviewer' => array(
|
||||
'description' => __( 'Reviewer name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviewer name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'reviewer_email' => array(
|
||||
'description' => __( 'Reviewer email.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviewer email.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'review' => array(
|
||||
'description' => __( 'The content of the review.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The content of the review.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
|
@ -877,12 +877,12 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
),
|
||||
),
|
||||
'rating' => array(
|
||||
'description' => __( 'Review rating (0 to 5).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Review rating (0 to 5).', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'verified' => array(
|
||||
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -897,14 +897,14 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
foreach ( $avatar_sizes as $size ) {
|
||||
$avatar_properties[ $size ] = array(
|
||||
/* translators: %d: avatar image size in pixels */
|
||||
'description' => sprintf( __( 'Avatar URL with image size of %d pixels.', 'woocommerce-rest-api' ), $size ),
|
||||
'description' => sprintf( __( 'Avatar URL with image size of %d pixels.', 'woocommerce' ), $size ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'embed', 'view', 'edit' ),
|
||||
);
|
||||
}
|
||||
$schema['properties']['reviewer_avatar_urls'] = array(
|
||||
'description' => __( 'Avatar URLs for the object reviewer.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Avatar URLs for the object reviewer.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -926,17 +926,17 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['after'] = array(
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
);
|
||||
$params['before'] = array(
|
||||
'description' => __( 'Limit response to reviews published before a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit response to reviews published before a given ISO8601 compliant date.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
);
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -944,7 +944,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
'default' => array(),
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -952,11 +952,11 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
'default' => array(),
|
||||
);
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
);
|
||||
$params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
'enum' => array(
|
||||
|
@ -965,7 +965,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
),
|
||||
);
|
||||
$params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'date_gmt',
|
||||
'enum' => array(
|
||||
|
@ -977,14 +977,14 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
),
|
||||
);
|
||||
$params['reviewer'] = array(
|
||||
'description' => __( 'Limit result set to reviews assigned to specific user IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to reviews assigned to specific user IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
$params['reviewer_exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes reviews assigned to specific user IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes reviews assigned to specific user IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -992,13 +992,13 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
);
|
||||
$params['reviewer_email'] = array(
|
||||
'default' => null,
|
||||
'description' => __( 'Limit result set to that from a specific author email.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to that from a specific author email.', 'woocommerce' ),
|
||||
'format' => 'email',
|
||||
'type' => 'string',
|
||||
);
|
||||
$params['product'] = array(
|
||||
'default' => array(),
|
||||
'description' => __( 'Limit result set to reviews assigned to specific product IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to reviews assigned to specific product IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1006,7 +1006,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
);
|
||||
$params['status'] = array(
|
||||
'default' => 'approved',
|
||||
'description' => __( 'Limit result set to reviews assigned a specific status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to reviews assigned a specific status.', 'woocommerce' ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'type' => 'string',
|
||||
'enum' => array(
|
||||
|
@ -1040,7 +1040,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
protected function get_review( $id ) {
|
||||
$id = (int) $id;
|
||||
$error = new WP_Error( 'woocommerce_rest_review_invalid_id', __( 'Invalid review ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
$error = new WP_Error( 'woocommerce_rest_review_invalid_id', __( 'Invalid review ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
|
||||
if ( 0 >= $id ) {
|
||||
return $error;
|
||||
|
@ -1055,7 +1055,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$post = get_post( (int) $review->comment_post_ID );
|
||||
|
||||
if ( 'product' !== get_post_type( (int) $review->comment_post_ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
|||
if ( ! $parent ) {
|
||||
return new WP_Error(
|
||||
// Translators: %d parent ID.
|
||||
"woocommerce_rest_{$this->post_type}_invalid_parent", sprintf( __( 'Cannot set attributes due to invalid parent product.', 'woocommerce-rest-api' ), $variation->get_parent_id() ), array(
|
||||
"woocommerce_rest_{$this->post_type}_invalid_parent", sprintf( __( 'Cannot set attributes due to invalid parent product.', 'woocommerce' ), $variation->get_parent_id() ), array(
|
||||
'status' => 404,
|
||||
)
|
||||
);
|
||||
|
@ -368,7 +368,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
|||
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
/* translators: %s: attachment ID */
|
||||
throw new WC_REST_Exception( 'woocommerce_variation_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce-rest-api' ), $attachment_id ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_variation_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 );
|
||||
}
|
||||
|
||||
$variation->set_image_id( $attachment_id );
|
||||
|
@ -405,126 +405,126 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Variation description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'permalink' => array(
|
||||
'description' => __( 'Variation URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Unique identifier.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Current variation price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Current variation price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'regular_price' => array(
|
||||
'description' => __( 'Variation regular price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation regular price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sale_price' => array(
|
||||
'description' => __( 'Variation sale price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation sale price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from' => array(
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from_gmt' => array(
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to' => array(
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to_gmt' => array(
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'on_sale' => array(
|
||||
'description' => __( 'Shows if the variation is on sale.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the variation is on sale.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Variation status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'publish',
|
||||
'enum' => array_keys( get_post_statuses() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'purchasable' => array(
|
||||
'description' => __( 'Shows if the variation can be bought.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the variation can be bought.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'virtual' => array(
|
||||
'description' => __( 'If the variation is virtual.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the variation is virtual.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloadable' => array(
|
||||
'description' => __( 'If the variation is downloadable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the variation is downloadable.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloads' => array(
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'File ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'File name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -532,179 +532,179 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
|||
),
|
||||
),
|
||||
'download_limit' => array(
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'download_expiry' => array(
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_status' => array(
|
||||
'description' => __( 'Tax status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'taxable',
|
||||
'enum' => array( 'taxable', 'shipping', 'none' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'manage_stock' => array(
|
||||
'description' => __( 'Stock management at variation level.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock management at variation level.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'stock_quantity' => array(
|
||||
'description' => __( 'Stock quantity.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock quantity.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'stock_status' => array(
|
||||
'description' => __( 'Controls the stock status of the product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Controls the stock status of the product.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'instock',
|
||||
'enum' => array_keys( wc_get_product_stock_status_options() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders' => array(
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'no',
|
||||
'enum' => array( 'no', 'notify', 'yes' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders_allowed' => array(
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'backordered' => array(
|
||||
'description' => __( 'Shows if the variation is on backordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'weight' => array(
|
||||
/* translators: %s: weight unit */
|
||||
'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce-rest-api' ), $weight_unit ),
|
||||
'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'dimensions' => array(
|
||||
'description' => __( 'Variation dimensions.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation dimensions.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'length' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Variation length (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'width' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Variation width (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'height' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Variation height (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping_class' => array(
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'shipping_class_id' => array(
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'image' => array(
|
||||
'description' => __( 'Variation image data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Variation image data.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'attributes' => array(
|
||||
'description' => __( 'List of attributes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of attributes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Attribute ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'option' => array(
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -712,30 +712,30 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
|||
),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -848,7 +848,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
|||
);
|
||||
|
||||
$params['stock_status'] = array(
|
||||
'description' => __( 'Limit result set to products with specified stock status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with specified stock status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_keys( wc_get_product_stock_status_options() ),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
|
|
@ -250,7 +250,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
/* translators: %s: image ID */
|
||||
throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce-rest-api' ), $attachment_id ), 400 );
|
||||
throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 );
|
||||
}
|
||||
|
||||
$featured_image = $product->get_image_id();
|
||||
|
@ -313,7 +313,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
|
||||
if ( 'variation' === $product->get_type() ) {
|
||||
return new WP_Error(
|
||||
"woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce-rest-api' ), array(
|
||||
"woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array(
|
||||
'status' => 404,
|
||||
)
|
||||
);
|
||||
|
@ -698,183 +698,183 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'Product slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'permalink' => array(
|
||||
'description' => __( 'Product URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the product was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the product was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the product was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the product was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Product type.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product type.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'simple',
|
||||
'enum' => array_keys( wc_get_product_types() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'status' => array(
|
||||
'description' => __( 'Product status (post status).', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product status (post status).', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'publish',
|
||||
'enum' => array_merge( array_keys( get_post_statuses() ), array( 'future' ) ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'featured' => array(
|
||||
'description' => __( 'Featured product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Featured product.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'catalog_visibility' => array(
|
||||
'description' => __( 'Catalog visibility.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Catalog visibility.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'visible',
|
||||
'enum' => array( 'visible', 'catalog', 'search', 'hidden' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'Product description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'short_description' => array(
|
||||
'description' => __( 'Product short description.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product short description.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sku' => array(
|
||||
'description' => __( 'Unique identifier.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'price' => array(
|
||||
'description' => __( 'Current product price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Current product price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'regular_price' => array(
|
||||
'description' => __( 'Product regular price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product regular price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sale_price' => array(
|
||||
'description' => __( 'Product sale price.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product sale price.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from' => array(
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_from_gmt' => array(
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to' => array(
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_on_sale_to_gmt' => array(
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'price_html' => array(
|
||||
'description' => __( 'Price formatted in HTML.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Price formatted in HTML.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'on_sale' => array(
|
||||
'description' => __( 'Shows if the product is on sale.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product is on sale.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'purchasable' => array(
|
||||
'description' => __( 'Shows if the product can be bought.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product can be bought.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total_sales' => array(
|
||||
'description' => __( 'Amount of sales.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of sales.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'virtual' => array(
|
||||
'description' => __( 'If the product is virtual.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the product is virtual.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloadable' => array(
|
||||
'description' => __( 'If the product is downloadable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If the product is downloadable.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'downloads' => array(
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of downloadable files.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'File ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'File name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'file' => array(
|
||||
'description' => __( 'File URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'File URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -882,157 +882,157 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
),
|
||||
),
|
||||
'download_limit' => array(
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'download_expiry' => array(
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => -1,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'external_url' => array(
|
||||
'description' => __( 'Product external URL. Only for external products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product external URL. Only for external products.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'button_text' => array(
|
||||
'description' => __( 'Product external button text. Only for external products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product external button text. Only for external products.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_status' => array(
|
||||
'description' => __( 'Tax status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'taxable',
|
||||
'enum' => array( 'taxable', 'shipping', 'none' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'tax_class' => array(
|
||||
'description' => __( 'Tax class.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tax class.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'manage_stock' => array(
|
||||
'description' => __( 'Stock management at product level.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock management at product level.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'stock_quantity' => array(
|
||||
'description' => __( 'Stock quantity.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Stock quantity.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'stock_status' => array(
|
||||
'description' => __( 'Controls the stock status of the product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Controls the stock status of the product.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'instock',
|
||||
'enum' => array_keys( wc_get_product_stock_status_options() ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders' => array(
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'default' => 'no',
|
||||
'enum' => array( 'no', 'notify', 'yes' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'backorders_allowed' => array(
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'backordered' => array(
|
||||
'description' => __( 'Shows if the product is on backordered.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'sold_individually' => array(
|
||||
'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'weight' => array(
|
||||
/* translators: %s: weight unit */
|
||||
'description' => sprintf( __( 'Product weight (%s).', 'woocommerce-rest-api' ), $weight_unit ),
|
||||
'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'dimensions' => array(
|
||||
'description' => __( 'Product dimensions.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product dimensions.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'properties' => array(
|
||||
'length' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Product length (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'width' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Product width (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'height' => array(
|
||||
/* translators: %s: dimension unit */
|
||||
'description' => sprintf( __( 'Product height (%s).', 'woocommerce-rest-api' ), $dimension_unit ),
|
||||
'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'shipping_required' => array(
|
||||
'description' => __( 'Shows if the product need to be shipped.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows if the product need to be shipped.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_taxable' => array(
|
||||
'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'shipping_class' => array(
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'shipping_class_id' => array(
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Shipping class ID.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'reviews_allowed' => array(
|
||||
'description' => __( 'Allow reviews.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Allow reviews.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'average_rating' => array(
|
||||
'description' => __( 'Reviews average rating.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviews average rating.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'rating_count' => array(
|
||||
'description' => __( 'Amount of reviews that the product have.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of reviews that the product have.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'related_ids' => array(
|
||||
'description' => __( 'List of related products IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of related products IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1041,7 +1041,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'upsell_ids' => array(
|
||||
'description' => __( 'List of up-sell products IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of up-sell products IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1049,7 +1049,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'cross_sell_ids' => array(
|
||||
'description' => __( 'List of cross-sell products IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of cross-sell products IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1057,35 +1057,35 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'parent_id' => array(
|
||||
'description' => __( 'Product parent ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product parent ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'purchase_note' => array(
|
||||
'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'categories' => array(
|
||||
'description' => __( 'List of categories.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of categories.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Category ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Category name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'Category slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Category slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1094,25 +1094,25 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
),
|
||||
),
|
||||
'tags' => array(
|
||||
'description' => __( 'List of tags.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of tags.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Tag ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Tag name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'Tag slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tag slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -1121,54 +1121,54 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
),
|
||||
),
|
||||
'images' => array(
|
||||
'description' => __( 'List of images.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of images.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Image ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'date_created' => array(
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_created_gmt' => array(
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified' => array(
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'date_modified_gmt' => array(
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
|
||||
'type' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'src' => array(
|
||||
'description' => __( 'Image URL.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image URL.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Image name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => __( 'Image alternative text.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Image alternative text.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -1176,41 +1176,41 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
),
|
||||
),
|
||||
'attributes' => array(
|
||||
'description' => __( 'List of attributes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of attributes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Attribute ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'position' => array(
|
||||
'description' => __( 'Attribute position.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute position.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'visible' => array(
|
||||
'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce-rest-api' ),
|
||||
'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'variation' => array(
|
||||
'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'options' => array(
|
||||
'description' => __( 'List of available term names of the attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of available term names of the attribute.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
|
@ -1221,24 +1221,24 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
),
|
||||
),
|
||||
'default_attributes' => array(
|
||||
'description' => __( 'Defaults variation attributes.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Defaults variation attributes.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Attribute ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Attribute name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attribute name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'option' => array(
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Selected attribute term name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -1246,7 +1246,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
),
|
||||
),
|
||||
'variations' => array(
|
||||
'description' => __( 'List of variations IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of variations IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
|
@ -1255,7 +1255,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'grouped_products' => array(
|
||||
'description' => __( 'List of grouped products ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'List of grouped products ID.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -1264,30 +1264,30 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'menu_order' => array(
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'meta_data' => array(
|
||||
'description' => __( 'Meta data.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta data.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Meta ID.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta ID.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'key' => array(
|
||||
'description' => __( 'Meta key.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta key.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Meta value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
@ -1310,7 +1310,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
|||
|
||||
unset( $params['in_stock'] );
|
||||
$params['stock_status'] = array(
|
||||
'description' => __( 'Limit result set to products with specified stock status.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to products with specified stock status.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_keys( wc_get_product_stock_status_options() ),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
|
|
@ -118,19 +118,19 @@ class WC_REST_Report_Coupons_Totals_Controller extends WC_REST_Reports_Controlle
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Coupon type name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupon type name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Amount of coupons.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of coupons.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -71,12 +71,12 @@ class WC_REST_Report_Customers_Totals_Controller extends WC_REST_Reports_Control
|
|||
$data = array(
|
||||
array(
|
||||
'slug' => 'paying',
|
||||
'name' => __( 'Paying customer', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Paying customer', 'woocommerce' ),
|
||||
'total' => $total_paying,
|
||||
),
|
||||
array(
|
||||
'slug' => 'non_paying',
|
||||
'name' => __( 'Non-paying customer', 'woocommerce-rest-api' ),
|
||||
'name' => __( 'Non-paying customer', 'woocommerce' ),
|
||||
'total' => $total_customers - $total_paying,
|
||||
),
|
||||
);
|
||||
|
@ -129,19 +129,19 @@ class WC_REST_Report_Customers_Totals_Controller extends WC_REST_Reports_Control
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Customer type name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customer type name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Amount of customers.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of customers.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -102,19 +102,19 @@ class WC_REST_Report_Orders_Totals_Controller extends WC_REST_Reports_Controller
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Order status name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order status name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Amount of orders.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of orders.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -108,19 +108,19 @@ class WC_REST_Report_Products_Totals_Controller extends WC_REST_Reports_Controll
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Product type name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Product type name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Amount of products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of products.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -54,7 +54,7 @@ class WC_REST_Report_Reviews_Totals_Controller extends WC_REST_Reports_Controlle
|
|||
$data[] = array(
|
||||
'slug' => 'rated_' . $i . '_out_of_5',
|
||||
/* translators: %s: average rating */
|
||||
'name' => sprintf( __( 'Rated %s out of 5', 'woocommerce-rest-api' ), $i ),
|
||||
'name' => sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $i ),
|
||||
'total' => (int) get_comments( $query_data ),
|
||||
);
|
||||
}
|
||||
|
@ -107,19 +107,19 @@ class WC_REST_Report_Reviews_Totals_Controller extends WC_REST_Reports_Controlle
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'Review type name.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Review type name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'total' => array(
|
||||
'description' => __( 'Amount of reviews.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Amount of reviews.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -36,35 +36,35 @@ class WC_REST_Reports_Controller extends WC_REST_Reports_V2_Controller {
|
|||
|
||||
$reports[] = array(
|
||||
'slug' => 'orders/totals',
|
||||
'description' => __( 'Orders totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Orders totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'products/totals',
|
||||
'description' => __( 'Products totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Products totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'customers/totals',
|
||||
'description' => __( 'Customers totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Customers totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'coupons/totals',
|
||||
'description' => __( 'Coupons totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Coupons totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'reviews/totals',
|
||||
'description' => __( 'Reviews totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Reviews totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'categories/totals',
|
||||
'description' => __( 'Categories totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Categories totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'tags/totals',
|
||||
'description' => __( 'Tags totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Tags totals.', 'woocommerce' ),
|
||||
);
|
||||
$reports[] = array(
|
||||
'slug' => 'attributes/totals',
|
||||
'description' => __( 'Attributes totals.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Attributes totals.', 'woocommerce' ),
|
||||
);
|
||||
|
||||
return $reports;
|
||||
|
|
|
@ -73,13 +73,13 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
*/
|
||||
public function get_group_settings( $group_id ) {
|
||||
if ( empty( $group_id ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$settings = apply_filters( 'woocommerce_settings-' . $group_id, array() ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
|
||||
if ( empty( $settings ) ) {
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$filtered_settings = array();
|
||||
|
@ -162,7 +162,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_title',
|
||||
|
@ -171,7 +171,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'group_id' => array(
|
||||
'description' => __( 'An identifier for the group this setting belongs to.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'An identifier for the group this setting belongs to.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_title',
|
||||
|
@ -180,7 +180,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -189,7 +189,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -198,7 +198,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'value' => array(
|
||||
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Setting value.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'array', 'null' ),
|
||||
'items' => array(
|
||||
'type' => array( 'string', 'null' ),
|
||||
|
@ -206,7 +206,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'default' => array(
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Default value for the setting.', 'woocommerce' ),
|
||||
'type' => array( 'string', 'array', 'null' ),
|
||||
'items' => array(
|
||||
'type' => array( 'string', 'null' ),
|
||||
|
@ -215,7 +215,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'tip' => array(
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -224,7 +224,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'placeholder' => array(
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -233,7 +233,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'type' => array(
|
||||
'description' => __( 'Type of setting.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Type of setting.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
|
@ -243,7 +243,7 @@ class WC_REST_Setting_Options_Controller extends WC_REST_Setting_Options_V2_Cont
|
|||
'readonly' => true,
|
||||
),
|
||||
'options' => array(
|
||||
'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -48,7 +48,7 @@ class WC_REST_Settings_Controller extends WC_REST_Settings_V2_Controller {
|
|||
*/
|
||||
public function update_items_permissions_check( $request ) {
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -80,27 +80,27 @@ class WC_REST_Settings_Controller extends WC_REST_Settings_V2_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'label' => array(
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'parent_id' => array(
|
||||
'description' => __( 'ID of parent grouping.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'ID of parent grouping.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'sub_groups' => array(
|
||||
'description' => __( 'IDs for settings sub groups.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'IDs for settings sub groups.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
|
|
@ -44,7 +44,7 @@ abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller
|
|||
$zone = WC_Shipping_Zones::get_zone_by( 'zone_id', $zone_id );
|
||||
|
||||
if ( false === $zone ) {
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_shipping_zone_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
return $zone;
|
||||
|
@ -58,11 +58,11 @@ abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( ! wc_shipping_enabled() ) {
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -76,11 +76,11 @@ abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller
|
|||
*/
|
||||
public function create_item_permissions_check( $request ) {
|
||||
if ( ! wc_shipping_enabled() ) {
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -94,11 +94,11 @@ abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller
|
|||
*/
|
||||
public function update_items_permissions_check( $request ) {
|
||||
if ( ! wc_shipping_enabled() ) {
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -112,11 +112,11 @@ abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller
|
|||
*/
|
||||
public function delete_items_permissions_check( $request ) {
|
||||
if ( ! wc_shipping_enabled() ) {
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -52,7 +52,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
array(
|
||||
'name' => array(
|
||||
'type' => 'string',
|
||||
'description' => __( 'Name for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Name for the resource.', 'woocommerce' ),
|
||||
'required' => true,
|
||||
),
|
||||
)
|
||||
|
@ -68,7 +68,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
|
@ -94,7 +94,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
'force' => array(
|
||||
'default' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -130,7 +130,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $permissions ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -149,7 +149,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $permissions ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -168,7 +168,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $permissions ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -187,7 +187,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $permissions ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -206,7 +206,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $permissions ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -225,7 +225,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
|
||||
if ( ! $permissions ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce-rest-api' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -242,7 +242,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
// Get taxonomy.
|
||||
$taxonomy = $this->get_taxonomy( $request );
|
||||
if ( ! $taxonomy || ! taxonomy_exists( $taxonomy ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Taxonomy does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Taxonomy does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
// Check permissions for a single term.
|
||||
|
@ -251,7 +251,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
$term = get_term( $id, $taxonomy );
|
||||
|
||||
if ( is_wp_error( $term ) || ! $term || $term->taxonomy !== $taxonomy ) {
|
||||
return new WP_Error( 'woocommerce_rest_term_invalid', __( 'Resource does not exist.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_term_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
return wc_rest_check_product_term_permissions( $taxonomy, $context, $term->term_id );
|
||||
|
@ -390,7 +390,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
if ( isset( $request['parent'] ) ) {
|
||||
if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
$args['parent'] = $request['parent'];
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
}
|
||||
if ( isset( $request['parent'] ) ) {
|
||||
if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
$prepared_args['parent'] = $request['parent'];
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
|
||||
// We don't support trashing for this type, error out.
|
||||
if ( ! $force ) {
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
|
||||
return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
|
||||
}
|
||||
|
||||
$term = get_term( (int) $request['id'], $taxonomy );
|
||||
|
@ -545,7 +545,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
|
||||
// Prevent deleting the default product category.
|
||||
if ( $default_category_id === (int) $request['id'] ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Default product category cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Default product category cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -553,7 +553,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
|
||||
$retval = wp_delete_term( $term->term_id, $term->taxonomy );
|
||||
if ( ! $retval ) {
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
|
||||
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -701,7 +701,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -710,7 +710,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
|
@ -720,14 +720,14 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
);
|
||||
if ( ! $taxonomy->hierarchical ) {
|
||||
$params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
}
|
||||
$params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'default' => 'asc',
|
||||
|
@ -738,7 +738,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by resource attribute.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Sort collection by resource attribute.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'default' => 'name',
|
||||
|
@ -754,27 +754,27 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['hide_empty'] = array(
|
||||
'description' => __( 'Whether to hide resources not assigned to any products.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Whether to hide resources not assigned to any products.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
if ( $taxonomy->hierarchical ) {
|
||||
$params['parent'] = array(
|
||||
'description' => __( 'Limit result set to resources assigned to a specific parent.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources assigned to a specific parent.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
}
|
||||
$params['product'] = array(
|
||||
'description' => __( 'Limit result set to resources assigned to a specific product.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources assigned to a specific product.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'default' => null,
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['slug'] = array(
|
||||
'description' => __( 'Limit result set to resources with a specific slug.', 'woocommerce-rest-api' ),
|
||||
'description' => __( 'Limit result set to resources with a specific slug.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
|
|
|
@ -58,7 +58,7 @@ class ImageAttachment {
|
|||
|
||||
if ( ! wp_attachment_is_image( $this->id ) ) {
|
||||
/* translators: %s: image ID */
|
||||
throw new \WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce-rest-api' ), $this->id ), 400 );
|
||||
throw new \WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $this->id ), 400 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue