mpty( $images ) ) { $images[] = [ 'id' => 0, 'date_created' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ), // Default to now. 'date_created_gmt' => wc_rest_prepare_date_response( time() ), // Default to now. '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', 'dokan-lite' ), 'alt' => __( 'Placeholder', 'dokan-lite' ), 'position' => 0, ]; } return $images; } /** * Get attribute taxonomy label. * * @param string $name Taxonomy name. * * @return string * @deprecated 2.8.0 */ protected function get_attribute_taxonomy_label( $name ) { $tax = get_taxonomy( $name ); $labels = get_taxonomy_labels( $tax ); return $labels->singular_name; } /** * Get product attribute taxonomy name. * * @param string $slug Taxonomy name. * @param WC_Product $product Product data. * * @since 2.8.0 * @return string */ protected function get_attribute_taxonomy_name( $slug, $product ) { $attributes = $product->get_attributes(); if ( ! isset( $attributes[ $slug ] ) ) { return str_replace( 'pa_', '', $slug ); } $attribute = $attributes[ $slug ]; // Taxonomy attribute name. if ( $attribute->is_taxonomy() ) { $taxonomy = $attribute->get_taxonomy_object(); return $taxonomy->attribute_label; } // Custom product attribute name. return $attribute->get_name(); } /** * Get default attributes. * * @param WC_Product $product Product instance. * * @return array */ protected function get_default_attributes( $product ) { $default = []; if ( $product->is_type( 'variable' ) ) { foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) { if ( 0 === strpos( $key, 'pa_' ) ) { $default[] = [ 'id' => wc_attribute_taxonomy_id_by_name( $key ), 'name' => $this->get_attribute_taxonomy_name( $key, $product ), 'option' => $value, ]; } else { $default[] = [ 'id' => 0, 'name' => $this->get_attribute_taxonomy_name( $key, $product ), 'option' => $value, ]; } } } return $default; } /** * Get attribute options. * * @param int $product_id Product ID. * @param array $attribute Attribute data. * * @return array */ protected function get_attribute_options( $product_id, $attribute ) { if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { return wc_get_product_terms( $product_id, $attribute['name'], [ 'fields' => 'names', ] ); } elseif ( isset( $attribute['value'] ) ) { return array_map( 'trim', explode( '|', $attribute['value'] ) ); } return []; } /** * Get the attributes for a product or product variation. * * @param WC_Product|WC_Product_Variation $product Product instance. * * @return array */ protected function get_attributes( $product ) { $attributes = []; if ( $product->is_type( 'variation' ) ) { $_product = wc_get_product( $product->get_parent_id() ); foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { $name = str_replace( 'attribute_', '', $attribute_name ); if ( ! $attribute ) { continue; } // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) { $option_term = get_term_by( 'slug', $attribute, $name ); $attributes[] = [ 'id' => wc_attribute_taxonomy_id_by_name( $name ), 'slug' => $attribute_name, 'name' => $this->get_attribute_taxonomy_name( $name, $_product ), 'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $attribute, ]; } else { $attributes[] = [ 'id' => 0, 'slug' => $attribute_name, 'name' => $this->get_attribute_taxonomy_name( $name, $_product ), 'option' => $attribute, ]; } } } else { foreach ( $product->get_attributes() as $attribute ) { $attributes[] = [ 'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name( $attribute['name'] ) : 0, 'slug' => $attribute['name'], 'name' => $this->get_attribute_taxonomy_name( $attribute['name'], $product ), 'position' => (int) $attribute['position'], 'visible' => (bool) $attribute['is_visible'], 'variation' => (bool) $attribute['is_variation'], 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), ]; } } return $attributes; } /** * Get the downloads for a product or product variation. * * @param WC_Product|WC_Product_Variation $product Product instance. * * @return array */ protected function get_downloads( $product ) { $downloads = []; if ( $product->is_downloadable() ) { foreach ( $product->get_downloads() as $file_id => $file ) { $downloads[] = [ 'id' => $file_id, // MD5 hash. 'name' => $file['name'], 'file' => $file['file'], ]; } } return $downloads; } /** * Set product images. * * @param WC_Product $product Product instance. * @param array $images Images data. * * @return WC_Product * @throws WC_REST_Exception REST API exceptions. */ protected function set_product_images( $product, $images ) { $images = is_array( $images ) ? array_filter( $images ) : []; if ( ! empty( $images ) ) { $gallery = []; foreach ( $images as $image ) { $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; if ( 0 === $attachment_id && isset( $image['src'] ) ) { $upload = wc_rest_upload_image_from_url( esc_url_raw( $image['src'] ) ); if ( is_wp_error( $upload ) ) { if ( ! apply_filters( 'woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images ) ) { throw new WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 ); } else { continue; } } $attachment_id = wc_rest_set_uploaded_image_as_attachment( $upload, $product->get_id() ); } 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.', 'dokan-lite' ), $attachment_id ), 400 ); } if ( isset( $image['position'] ) && 0 === absint( $image['position'] ) ) { $product->set_image_id( $attachment_id ); } else { $gallery[] = $attachment_id; } // Set the image alt if present. if ( ! empty( $image['alt'] ) ) { update_post_meta( $attachment_id, '_wp_attachment_image_alt', wc_clean( $image['alt'] ) ); } // Set the image name if present. if ( ! empty( $image['name'] ) ) { wp_update_post( [ 'ID' => $attachment_id, 'post_title' => $image['name'], ] ); } // Set the image source if present, for future reference. if ( ! empty( $image['src'] ) ) { update_post_meta( $attachment_id, '_wc_attachment_source', esc_url_raw( $image['src'] ) ); } } $product->set_gallery_image_ids( $gallery ); } else { $product->set_image_id( '' ); $product->set_gallery_image_ids( [] ); } return $product; } /** * Save product shipping data. * * @param WC_Product $product Product instance. * @param array $data Shipping data. * * @return WC_Product */ protected function save_product_shipping_data( $product, $data ) { // Virtual. if ( isset( $data['virtual'] ) && true === $data['virtual'] ) { $product->set_weight( '' ); $product->set_height( '' ); $product->set_length( '' ); $product->set_width( '' ); } else { if ( isset( $data['weight'] ) ) { $product->set_weight( $data['weight'] ); } // Height. if ( isset( $data['dimensions']['height'] ) ) { $product->set_height( $data['dimensions']['height'] ); } // Width. if ( isset( $data['dimensions']['width'] ) ) { $product->set_width( $data['dimensions']['width'] ); } // Length. if ( isset( $data['dimensions']['length'] ) ) { $product->set_length( $data['dimensions']['length'] ); } } // Shipping class. if ( isset( $data['shipping_class'] ) ) { $data_store = $product->get_data_store(); $shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) ); $product->set_shipping_class_id( $shipping_class_id ); } return $product; } /** * Save downloadable files. * * @param WC_Product $product Product instance. * @param array $downloads Downloads data. * @param int $deprecated Deprecated since 3.0. * * @return WC_Product */ protected function save_downloadable_files( $product, $downloads, $deprecated = 0 ) { if ( $deprecated ) { wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.' ); } $files = []; foreach ( $downloads as $key => $file ) { if ( empty( $file['file'] ) ) { continue; } $download = new WC_Product_Download(); $download->set_id( $key ); $download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) ); $download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) ); $files[] = $download; } $product->set_downloads( $files ); return $product; } /** * Save taxonomy terms. * * @param WC_Product $product Product instance. * @param array $terms Terms data. * @param string $taxonomy Taxonomy name. * * @return WC_Product */ protected function save_taxonomy_terms( $product, $terms, $taxonomy = 'cat' ) { $term_ids = wp_list_pluck( $terms, 'id' ); if ( 'cat' === $taxonomy ) { $product->set_category_ids( $term_ids ); } elseif ( 'tag' === $taxonomy ) { $product->set_tag_ids( $term_ids ); } return $product; } /** * Save default attributes. * * @param WC_Product $product Product instance. * @param WP_REST_Request $request Request data. * * @since 3.0.0 * * @return WC_Product */ protected function save_default_attributes( $product, $request ) { if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) { $product_attribute = new ProductAttribute( $request['default_attributes'] ); $product_attribute->set_default( $product ); } return $product; } /** * Returns all categories. * * @since 3.6.2 * * @return WP_REST_Response|WP_Error */ public function get_multistep_categories() { $categories_controller = new Categories(); $categories = apply_filters( 'dokan_rest_product_categories', $categories_controller->get() ); return rest_ensure_response( $categories ); } /** * Get the Product's schema, conforming to JSON Schema. * * @return array */ public function get_item_schema() { $weight_unit = get_option( 'woocommerce_weight_unit' ); $dimension_unit = get_option( 'woocommerce_dimension_unit' ); $schema = [ '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Unique identifier for the resource.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'name' => [ 'description' => __( 'Product name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'slug' => [ 'description' => __( 'Product slug.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'permalink' => [ 'description' => __( 'Product URL.', 'dokan-lite' ), 'type' => 'string', 'format' => 'uri', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_created' => [ 'description' => __( "The date the product was created, in the site's timezone.", 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_created_gmt' => [ 'description' => __( 'The date the product was created, as GMT.', 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_modified' => [ 'description' => __( "The date the product was last modified, in the site's timezone.", 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_modified_gmt' => [ 'description' => __( 'The date the product was last modified, as GMT.', 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'type' => [ 'description' => __( 'Product type.', 'dokan-lite' ), 'type' => 'string', 'default' => 'simple', 'enum' => array_keys( wc_get_product_types() ), 'context' => [ 'view', 'edit' ], ], 'status' => [ 'description' => __( 'Product status (post status).', 'dokan-lite' ), 'type' => 'string', 'default' => 'publish', 'enum' => array_keys( get_post_statuses() ), 'context' => [ 'view', 'edit' ], ], 'featured' => [ 'description' => __( 'Featured product.', 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'catalog_visibility' => [ 'description' => __( 'Catalog visibility.', 'dokan-lite' ), 'type' => 'string', 'default' => 'visible', 'enum' => [ 'visible', 'catalog', 'search', 'hidden' ], 'context' => [ 'view', 'edit' ], ], 'description' => [ 'description' => __( 'Product description.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'short_description' => [ 'description' => __( 'Product short description.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'sku' => [ 'description' => __( 'Unique identifier.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'price' => [ 'description' => __( 'Current product price.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'regular_price' => [ 'description' => __( 'Product regular price.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'sale_price' => [ 'description' => __( 'Product sale price.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'date_on_sale_from' => [ 'description' => __( "Start date of sale price, in the site's timezone.", 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], ], 'date_on_sale_from_gmt' => [ 'description' => __( 'Start date of sale price, as GMT.', 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], ], 'date_on_sale_to' => [ 'description' => __( "End date of sale price, in the site's timezone.", 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], ], 'date_on_sale_to_gmt' => [ 'description' => __( 'End date of sale price, as GMT.', 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], ], 'price_html' => [ 'description' => __( 'Price formatted in HTML.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'on_sale' => [ 'description' => __( 'Shows if the product is on sale.', 'dokan-lite' ), 'type' => 'boolean', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'purchasable' => [ 'description' => __( 'Shows if the product can be bought.', 'dokan-lite' ), 'type' => 'boolean', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'total_sales' => [ 'description' => __( 'Amount of sales.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'virtual' => [ 'description' => __( 'If the product is virtual.', 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'downloadable' => [ 'description' => __( 'If the product is downloadable.', 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'downloads' => [ 'description' => __( 'List of downloadable files.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'File MD5 hash.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'name' => [ 'description' => __( 'File name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'file' => [ 'description' => __( 'File URL.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], ], ], ], 'download_limit' => [ 'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'dokan-lite' ), 'type' => 'integer', 'default' => - 1, 'context' => [ 'view', 'edit' ], ], 'download_expiry' => [ 'description' => __( 'Number of days until access to downloadable files expires.', 'dokan-lite' ), 'type' => 'integer', 'default' => - 1, 'context' => [ 'view', 'edit' ], ], 'external_url' => [ 'description' => __( 'Product external URL. Only for external products.', 'dokan-lite' ), 'type' => 'string', 'format' => 'uri', 'context' => [ 'view', 'edit' ], ], 'button_text' => [ 'description' => __( 'Product external button text. Only for external products.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'tax_status' => [ 'description' => __( 'Tax status.', 'dokan-lite' ), 'type' => 'string', 'default' => 'taxable', 'enum' => [ 'taxable', 'shipping', 'none' ], 'context' => [ 'view', 'edit' ], ], 'tax_class' => [ 'description' => __( 'Tax class.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'manage_stock' => [ 'description' => __( 'Stock management at product level.', 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'stock_quantity' => [ 'description' => __( 'Stock quantity.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'in_stock' => [ 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'dokan-lite' ), 'type' => 'boolean', 'default' => true, 'context' => [ 'view', 'edit' ], ], 'backorders' => [ 'description' => __( 'If managing stock, this controls if backorders are allowed.', 'dokan-lite' ), 'type' => 'string', 'default' => 'no', 'enum' => [ 'no', 'notify', 'yes' ], 'context' => [ 'view', 'edit' ], ], 'backorders_allowed' => [ 'description' => __( 'Shows if backorders are allowed.', 'dokan-lite' ), 'type' => 'boolean', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'backordered' => [ 'description' => __( 'Shows if the product is on backordered.', 'dokan-lite' ), 'type' => 'boolean', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'sold_individually' => [ 'description' => __( 'Allow one item to be bought in a single order.', 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'weight' => [ /* translators: %s: weight unit */ 'description' => sprintf( __( 'Product weight (%s).', 'dokan-lite' ), $weight_unit ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'dimensions' => [ 'description' => __( 'Product dimensions.', 'dokan-lite' ), 'type' => 'object', 'context' => [ 'view', 'edit' ], 'properties' => [ 'length' => [ /* translators: %s: dimension unit */ 'description' => sprintf( __( 'Product length (%s).', 'dokan-lite' ), $dimension_unit ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'width' => [ /* translators: %s: dimension unit */ 'description' => sprintf( __( 'Product width (%s).', 'dokan-lite' ), $dimension_unit ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'height' => [ /* translators: %s: dimension unit */ 'description' => sprintf( __( 'Product height (%s).', 'dokan-lite' ), $dimension_unit ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], ], ], 'shipping_required' => [ 'description' => __( 'Shows if the product need to be shipped.', 'dokan-lite' ), 'type' => 'boolean', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'shipping_taxable' => [ 'description' => __( 'Shows whether or not the product shipping is taxable.', 'dokan-lite' ), 'type' => 'boolean', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'shipping_class' => [ 'description' => __( 'Shipping class slug.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'shipping_class_id' => [ 'description' => __( 'Shipping class ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'reviews_allowed' => [ 'description' => __( 'Allow reviews.', 'dokan-lite' ), 'type' => 'boolean', 'default' => true, 'context' => [ 'view', 'edit' ], ], 'average_rating' => [ 'description' => __( 'Reviews average rating.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'rating_count' => [ 'description' => __( 'Amount of reviews that the product have.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'related_ids' => [ 'description' => __( 'List of related products IDs.', 'dokan-lite' ), 'type' => 'array', 'items' => [ 'type' => 'integer', ], 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'upsell_ids' => [ 'description' => __( 'List of up-sell products IDs.', 'dokan-lite' ), 'type' => 'array', 'items' => [ 'type' => 'integer', ], 'context' => [ 'view', 'edit' ], ], 'cross_sell_ids' => [ 'description' => __( 'List of cross-sell products IDs.', 'dokan-lite' ), 'type' => 'array', 'items' => [ 'type' => 'integer', ], 'context' => [ 'view', 'edit' ], ], 'parent_id' => [ 'description' => __( 'Product parent ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'purchase_note' => [ 'description' => __( 'Optional note to send the customer after purchase.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'categories' => [ 'description' => __( 'List of categories.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Category ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'name' => [ 'description' => __( 'Category name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'slug' => [ 'description' => __( 'Category slug.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], ], ], ], 'tags' => [ 'description' => __( 'List of tags.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Tag ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'name' => [ 'description' => __( 'Tag name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'slug' => [ 'description' => __( 'Tag slug.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], ], ], ], 'images' => [ 'description' => __( 'List of images.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Image ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'date_created' => [ 'description' => __( "The date the image was created, in the site's timezone.", 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_created_gmt' => [ 'description' => __( 'The date the image was created, as GMT.', 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_modified' => [ 'description' => __( "The date the image was last modified, in the site's timezone.", 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'date_modified_gmt' => [ 'description' => __( 'The date the image was last modified, as GMT.', 'dokan-lite' ), 'type' => 'date-time', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'src' => [ 'description' => __( 'Image URL.', 'dokan-lite' ), 'type' => 'string', 'format' => 'uri', 'context' => [ 'view', 'edit' ], ], 'name' => [ 'description' => __( 'Image name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'alt' => [ 'description' => __( 'Image alternative text.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'position' => [ 'description' => __( 'Image position. 0 means that the image is featured.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], ], ], ], 'attributes' => [ 'description' => __( 'List of attributes.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Attribute ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'name' => [ 'description' => __( 'Attribute name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'position' => [ 'description' => __( 'Attribute position.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'visible' => [ 'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'variation' => [ 'description' => __( 'Define if the attribute can be used as variation.', 'dokan-lite' ), 'type' => 'boolean', 'default' => false, 'context' => [ 'view', 'edit' ], ], 'options' => [ 'description' => __( 'List of available term names of the attribute.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'string', ], ], ], ], ], 'default_attributes' => [ 'description' => __( 'Defaults variation attributes.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Attribute ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'name' => [ 'description' => __( 'Attribute name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'option' => [ 'description' => __( 'Selected attribute term name.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], ], ], ], 'variations' => [ 'description' => __( 'List of variations IDs.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'integer', ], 'readonly' => true, ], 'grouped_products' => [ 'description' => __( 'List of grouped products ID.', 'dokan-lite' ), 'type' => 'array', 'items' => [ 'type' => 'integer', ], 'context' => [ 'view', 'edit' ], ], 'menu_order' => [ 'description' => __( 'Menu order, used to custom sort products.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], ], 'meta_data' => [ 'description' => __( 'Meta data.', 'dokan-lite' ), 'type' => 'array', 'context' => [ 'view', 'edit' ], 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'description' => __( 'Meta ID.', 'dokan-lite' ), 'type' => 'integer', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'key' => [ 'description' => __( 'Meta key.', 'dokan-lite' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], ], 'value' => [ 'description' => __( 'Meta value.', 'dokan-lite' ), 'type' => 'mixed', 'context' => [ 'view', 'edit' ], ], ], ], ], ], ]; return $this->add_additional_fields_schema( $schema ); } }